diff --git a/lib/pages/home/home.dart b/lib/pages/home/home.dart index 7436f2e..eb84b4e 100644 --- a/lib/pages/home/home.dart +++ b/lib/pages/home/home.dart @@ -4,7 +4,7 @@ import 'package:didvan/pages/home/profile/profile.dart'; import 'package:didvan/pages/home/radar/radar.dart'; import 'package:didvan/pages/home/radar/radar_state.dart'; import 'package:didvan/pages/home/statistics/statistics.dart'; -import 'package:didvan/pages/home/studio/studio..dart'; +import 'package:didvan/pages/home/studio/studio.dart'; import 'package:didvan/pages/home/widgets/didvan_bnb.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; diff --git a/lib/pages/home/radar/radar.dart b/lib/pages/home/radar/radar.dart index 229258f..acd3f16 100644 --- a/lib/pages/home/radar/radar.dart +++ b/lib/pages/home/radar/radar.dart @@ -22,29 +22,7 @@ class _RadarState extends State { @override void initState() { _scrollController.addListener(() async { - if (_isAnimating) return; - final double position = _scrollController.position.pixels; - if (position > 5 && !_isColapsed) { - _isColapsed = true; - setState(() {}); - _isAnimating = true; - await _scrollController.animateTo( - 380, - duration: DesignConfig.mediumAnimationDuration, - curve: Curves.ease, - ); - _isAnimating = false; - } else if (position < 380 && _isColapsed) { - _isColapsed = false; - setState(() {}); - _isAnimating = true; - await _scrollController.animateTo( - 0, - duration: DesignConfig.mediumAnimationDuration, - curve: Curves.ease, - ); - _isAnimating = false; - } + _handleAnimations(); }); super.initState(); } @@ -103,4 +81,30 @@ class _RadarState extends State { ), ); } + + void _handleAnimations() async { + if (_isAnimating) return; + final double position = _scrollController.position.pixels; + if (position > 5 && !_isColapsed) { + _isColapsed = true; + setState(() {}); + _isAnimating = true; + await _scrollController.animateTo( + 380, + duration: DesignConfig.mediumAnimationDuration, + curve: Curves.ease, + ); + _isAnimating = false; + } else if (position < 380 && _isColapsed) { + _isColapsed = false; + setState(() {}); + _isAnimating = true; + await _scrollController.animateTo( + 0, + duration: DesignConfig.mediumAnimationDuration, + curve: Curves.ease, + ); + _isAnimating = false; + } + } } diff --git a/lib/pages/home/radar/widgets/search_field.dart b/lib/pages/home/radar/widgets/search_field.dart index f68d931..0b78189 100644 --- a/lib/pages/home/radar/widgets/search_field.dart +++ b/lib/pages/home/radar/widgets/search_field.dart @@ -2,46 +2,79 @@ import 'package:didvan/config/design_config.dart'; import 'package:didvan/constants/app_icons.dart'; import 'package:flutter/material.dart'; -class SearchField extends StatelessWidget { +class SearchField extends StatefulWidget { const SearchField({Key? key}) : super(key: key); + @override + State createState() => _SearchFieldState(); +} + +class _SearchFieldState extends State { + final FocusNode _focusNode = FocusNode(); + + @override + void initState() { + _focusNode.addListener(() { + setState(() {}); + }); + super.initState(); + } + @override Widget build(BuildContext context) { return Container( height: 40, - width: double.infinity, decoration: BoxDecoration( - color: Theme.of(context).colorScheme.surface, + color: _fillColor(), ), - child: Row( - children: [ - const Icon( - DidvanIcons.search_regular, - ), - Expanded( - child: TextField( - style: Theme.of(context).textTheme.bodyText1, - textAlignVertical: TextAlignVertical.top, - onChanged: (value) {}, - keyboardType: TextInputType.text, - textInputAction: TextInputAction.search, - decoration: InputDecoration( - contentPadding: const EdgeInsets.only( - left: 12, - right: 12, - bottom: 8, - ), - border: InputBorder.none, - hintText: 'جستجو مطلب در رادار', - hintStyle: Theme.of(context) - .textTheme - .subtitle2! - .copyWith(color: DesignConfig.greyColor5), - ), + child: TextField( + focusNode: _focusNode, + style: Theme.of(context).textTheme.bodyText1, + textAlignVertical: TextAlignVertical.center, + onChanged: (value) {}, + keyboardType: TextInputType.text, + textInputAction: TextInputAction.search, + decoration: InputDecoration( + focusedBorder: OutlineInputBorder( + borderRadius: const BorderRadius.all( + Radius.circular(4), + ), + borderSide: BorderSide( + color: Theme.of(context).primaryColor, ), ), - ], + prefixIcon: const Icon( + DidvanIcons.search_regular, + ), + enabledBorder: const OutlineInputBorder( + borderRadius: BorderRadius.all( + Radius.circular(4), + ), + borderSide: BorderSide( + color: DesignConfig.greyColor4, + ), + ), + fillColor: Colors.red, + contentPadding: const EdgeInsets.only( + left: 12, + right: 12, + bottom: 8, + ), + border: InputBorder.none, + hintText: 'جستجو مطلب در رادار', + hintStyle: Theme.of(context) + .textTheme + .subtitle2! + .copyWith(color: DesignConfig.greyColor5), + ), ), ); } + + Color _fillColor() { + if (_focusNode.hasFocus) { + return DesignConfig.lightPrimaryColor3; + } + return Theme.of(context).colorScheme.surface; + } } diff --git a/lib/pages/home/studio/studio..dart b/lib/pages/home/studio/studio.dart similarity index 100% rename from lib/pages/home/studio/studio..dart rename to lib/pages/home/studio/studio.dart diff --git a/lib/pages/home/widgets/didvan_bnb.dart b/lib/pages/home/widgets/didvan_bnb.dart index d1f3d91..d92f996 100644 --- a/lib/pages/home/widgets/didvan_bnb.dart +++ b/lib/pages/home/widgets/didvan_bnb.dart @@ -14,7 +14,7 @@ class DidvanBNB extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - height: 64, + height: 72, decoration: BoxDecoration( color: Theme.of(context).colorScheme.surface, borderRadius: const BorderRadius.vertical(top: Radius.circular(16)), diff --git a/lib/pages/splash/splash.dart b/lib/pages/splash/splash.dart index 74195cc..36dc181 100644 --- a/lib/pages/splash/splash.dart +++ b/lib/pages/splash/splash.dart @@ -2,6 +2,7 @@ import 'package:didvan/config/design_config.dart'; import 'package:didvan/routes/routes.dart'; import 'package:didvan/widgets/logos/didvan_horizontal_logo.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; class Splash extends StatefulWidget { const Splash({Key? key}) : super(key: key); @@ -24,10 +25,15 @@ class _SplashState extends State { @override Widget build(BuildContext context) { - return Container( - padding: const EdgeInsets.all(60), - color: DesignConfig.lightColorScheme.background, - child: const DidvanVerticalLogo(), + return AnnotatedRegion( + value: DesignConfig.systemUIOverlayStyle.copyWith( + systemNavigationBarColor: DesignConfig.lightPrimaryColor3, + ), + child: Container( + padding: const EdgeInsets.all(60), + color: DesignConfig.lightPrimaryColor3, + child: const DidvanVerticalLogo(), + ), ); } } diff --git a/lib/routes/route_generator.dart b/lib/routes/route_generator.dart index f904a45..fe80ea0 100644 --- a/lib/routes/route_generator.dart +++ b/lib/routes/route_generator.dart @@ -1,9 +1,8 @@ +import 'package:didvan/config/design_config.dart'; import 'package:didvan/pages/authentication/authentication.dart'; import 'package:didvan/pages/authentication/authentication_state.dart'; import 'package:didvan/pages/home/home.dart'; import 'package:didvan/pages/home/home_state.dart'; -import 'package:didvan/pages/home/radar/radar.dart'; -import 'package:didvan/pages/home/radar/radar_state.dart'; import 'package:didvan/pages/splash/splash.dart'; import 'package:didvan/pages/splash/splash_state.dart'; import 'package:didvan/routes/routes.dart'; @@ -14,21 +13,21 @@ class RouteGenerator { static Route generateRoute(RouteSettings settings) { switch (settings.name) { case Routes.splash: - return _materialPageRouteGenerator( + return _createRoute( ChangeNotifierProvider( create: (context) => SplashState(), child: const Splash(), ), ); case Routes.authenticaion: - return _materialPageRouteGenerator( + return _createRoute( ChangeNotifierProvider( create: (context) => AuthenticationState(), child: const Authentication(), ), ); case Routes.home: - return _materialPageRouteGenerator( + return _createRoute( ChangeNotifierProvider( create: (context) => HomeState(), child: const Home(), @@ -52,7 +51,13 @@ class RouteGenerator { }); } - static _materialPageRouteGenerator(pageWidget) => MaterialPageRoute( - builder: (context) => pageWidget, - ); + static Route _createRoute(page) { + return PageRouteBuilder( + pageBuilder: (context, animation, secondaryAnimation) => page, + transitionDuration: DesignConfig.mediumAnimationDuration, + transitionsBuilder: (context, animation, secondaryAnimation, child) { + return FadeTransition(opacity: animation, child: child); + }, + ); + } } diff --git a/lib/utils/actions_sheet.dart b/lib/utils/actions_sheet.dart index fa63022..64926d0 100644 --- a/lib/utils/actions_sheet.dart +++ b/lib/utils/actions_sheet.dart @@ -1,5 +1,7 @@ +import 'package:didvan/config/design_config.dart'; import 'package:didvan/constants/assets.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:rive/rive.dart'; class ActionSheetUtils { @@ -8,12 +10,23 @@ class ActionSheetUtils { static Future showLogoLoadingIndicator() async { await showDialog( context: context, - builder: (context) => Padding( - padding: EdgeInsets.symmetric( - horizontal: MediaQuery.of(context).size.width / 3, + builder: (context) => _customSystemOverlayStyle( + child: Padding( + padding: EdgeInsets.symmetric( + horizontal: MediaQuery.of(context).size.width / 3, + ), + child: const RiveAnimation.asset(Assets.logoLoadingAnimation), ), - child: const RiveAnimation.asset(Assets.logoLoadingAnimation), ), ); } + + static AnnotatedRegion _customSystemOverlayStyle({required Widget child}) { + return AnnotatedRegion( + value: DesignConfig.systemUIOverlayStyle.copyWith( + systemNavigationBarColor: Colors.black45, + ), + child: child, + ); + } }