| @@ -1 +1 @@ | |||
| 440505e9ea1eee7043d2cbfeb318f6bc | |||
| 7c3be5aca7ff709c59cdc638def905a4 | |||
| @@ -255,4 +255,4 @@ SPEC CHECKSUMS: | |||
| PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c | |||
| COCOAPODS: 1.9.3 | |||
| COCOAPODS: 1.10.0 | |||
| @@ -374,7 +374,7 @@ | |||
| ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | |||
| CLANG_ENABLE_MODULES = YES; | |||
| CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; | |||
| CURRENT_PROJECT_VERSION = 2; | |||
| CURRENT_PROJECT_VERSION = 3; | |||
| DEVELOPMENT_TEAM = C3DTD2JH94; | |||
| ENABLE_BITCODE = NO; | |||
| FRAMEWORK_SEARCH_PATHS = ( | |||
| @@ -516,7 +516,7 @@ | |||
| ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | |||
| CLANG_ENABLE_MODULES = YES; | |||
| CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; | |||
| CURRENT_PROJECT_VERSION = 2; | |||
| CURRENT_PROJECT_VERSION = 3; | |||
| DEVELOPMENT_TEAM = C3DTD2JH94; | |||
| ENABLE_BITCODE = NO; | |||
| FRAMEWORK_SEARCH_PATHS = ( | |||
| @@ -550,7 +550,7 @@ | |||
| ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | |||
| CLANG_ENABLE_MODULES = YES; | |||
| CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; | |||
| CURRENT_PROJECT_VERSION = 2; | |||
| CURRENT_PROJECT_VERSION = 3; | |||
| DEVELOPMENT_TEAM = C3DTD2JH94; | |||
| ENABLE_BITCODE = NO; | |||
| FRAMEWORK_SEARCH_PATHS = ( | |||
| @@ -1,5 +1,4 @@ | |||
| import 'package:farm_tpf/presentation/screens/login/view/login_page.dart'; | |||
| import 'package:farm_tpf/presentation/screens/slide_menu/navigation_home_screen.dart'; | |||
| import 'package:farm_tpf/presentation/screens/splash/view/splash_page.dart'; | |||
| import 'package:farm_tpf/presentation/screens/tabbar/tabbar.dart'; | |||
| import 'package:farm_tpf/utils/const_color.dart'; | |||
| @@ -1,246 +0,0 @@ | |||
| import 'package:farm_tpf/data/repository/user_repository.dart'; | |||
| import 'package:farm_tpf/presentation/screens/notification/update_count_noti_bloc.dart'; | |||
| import 'package:farm_tpf/utils/const_color.dart'; | |||
| import 'package:farm_tpf/utils/pref.dart'; | |||
| import 'package:flutter/material.dart'; | |||
| import 'package:get/get.dart'; | |||
| import 'home_drawer.dart'; | |||
| class DrawerUserController extends StatefulWidget { | |||
| const DrawerUserController({ | |||
| Key key, | |||
| this.drawerWidth = 250, | |||
| this.onDrawerCall, | |||
| this.screenView, | |||
| this.animatedIconData = AnimatedIcons.arrow_menu, | |||
| this.menuView, | |||
| this.drawerIsOpen, | |||
| this.screenIndex, | |||
| }) : super(key: key); | |||
| final double drawerWidth; | |||
| final Function(DrawerIndex) onDrawerCall; | |||
| final Widget screenView; | |||
| final Function(bool) drawerIsOpen; | |||
| final AnimatedIconData animatedIconData; | |||
| final Widget menuView; | |||
| final DrawerIndex screenIndex; | |||
| @override | |||
| _DrawerUserControllerState createState() => _DrawerUserControllerState(); | |||
| } | |||
| class _DrawerUserControllerState extends State<DrawerUserController> | |||
| with TickerProviderStateMixin { | |||
| ScrollController scrollController; | |||
| AnimationController iconAnimationController; | |||
| AnimationController animationController; | |||
| UserRepository _userRepository = UserRepository(); | |||
| double scrolloffset = 0.0; | |||
| var pref = LocalPref(); | |||
| final updateFullName = Get.put(UpdateFullName()); | |||
| @override | |||
| void initState() { | |||
| animationController = AnimationController( | |||
| duration: const Duration(milliseconds: 2000), vsync: this); | |||
| iconAnimationController = AnimationController( | |||
| vsync: this, duration: const Duration(milliseconds: 0)); | |||
| iconAnimationController | |||
| ..animateTo(1.0, | |||
| duration: const Duration(milliseconds: 0), | |||
| curve: Curves.fastOutSlowIn); | |||
| scrollController = | |||
| ScrollController(initialScrollOffset: widget.drawerWidth); | |||
| scrollController | |||
| ..addListener(() { | |||
| if (scrollController.offset <= 0) { | |||
| if (scrolloffset != 1.0) { | |||
| setState(() { | |||
| scrolloffset = 1.0; | |||
| try { | |||
| //open Drawer | |||
| updateCountNotiBloc.getNotifications((data) {}, (err) {}); | |||
| widget.drawerIsOpen(true); | |||
| } catch (_) {} | |||
| }); | |||
| } | |||
| iconAnimationController.animateTo(0.0, | |||
| duration: const Duration(milliseconds: 0), | |||
| curve: Curves.fastOutSlowIn); | |||
| } else if (scrollController.offset > 0 && | |||
| scrollController.offset < widget.drawerWidth) { | |||
| iconAnimationController.animateTo( | |||
| (scrollController.offset * 100 / (widget.drawerWidth)) / 100, | |||
| duration: const Duration(milliseconds: 0), | |||
| curve: Curves.fastOutSlowIn); | |||
| } else if (scrollController.offset <= widget.drawerWidth) { | |||
| if (scrolloffset != 0.0) { | |||
| setState(() { | |||
| scrolloffset = 0.0; | |||
| try { | |||
| widget.drawerIsOpen(false); | |||
| } catch (_) {} | |||
| }); | |||
| } | |||
| iconAnimationController.animateTo(1.0, | |||
| duration: const Duration(milliseconds: 0), | |||
| curve: Curves.fastOutSlowIn); | |||
| } | |||
| }); | |||
| WidgetsBinding.instance.addPostFrameCallback((_) => getInitState()); | |||
| super.initState(); | |||
| } | |||
| Future<bool> getInitState() async { | |||
| scrollController.jumpTo( | |||
| widget.drawerWidth, | |||
| ); | |||
| return true; | |||
| } | |||
| @override | |||
| Widget build(BuildContext context) { | |||
| return Scaffold( | |||
| backgroundColor: AppColors.WHITE, | |||
| body: SingleChildScrollView( | |||
| controller: scrollController, | |||
| scrollDirection: Axis.horizontal, | |||
| physics: const PageScrollPhysics(parent: ClampingScrollPhysics()), | |||
| child: SizedBox( | |||
| height: MediaQuery.of(context).size.height, | |||
| width: MediaQuery.of(context).size.width + widget.drawerWidth, | |||
| //we use with as screen width and add drawerWidth (from navigation_home_screen) | |||
| child: Row( | |||
| children: <Widget>[ | |||
| SizedBox( | |||
| width: widget.drawerWidth, | |||
| //we divided first drawer Width with HomeDrawer and second full-screen Width with all home screen, we called screen View | |||
| height: MediaQuery.of(context).size.height, | |||
| child: AnimatedBuilder( | |||
| animation: iconAnimationController, | |||
| builder: (BuildContext context, Widget child) { | |||
| return Transform( | |||
| //transform we use for the stable drawer we, not need to move with scroll view | |||
| transform: Matrix4.translationValues( | |||
| scrollController.offset, 0.0, 0.0), | |||
| child: HomeDrawer( | |||
| screenIndex: widget.screenIndex == null | |||
| ? DrawerIndex.Home | |||
| : widget.screenIndex, | |||
| iconAnimationController: iconAnimationController, | |||
| callBackIndex: (DrawerIndex indexType) { | |||
| onDrawerClick(); | |||
| try { | |||
| widget.onDrawerCall(indexType); | |||
| } catch (e) {} | |||
| }, | |||
| ), | |||
| ); | |||
| }, | |||
| ), | |||
| ), | |||
| SizedBox( | |||
| width: MediaQuery.of(context).size.width, | |||
| height: MediaQuery.of(context).size.height, | |||
| //full-screen Width with widget.screenView | |||
| child: Container( | |||
| decoration: BoxDecoration( | |||
| color: AppColors.WHITE, | |||
| boxShadow: <BoxShadow>[ | |||
| BoxShadow(color: AppColors.GRAY1, blurRadius: 24), | |||
| ], | |||
| ), | |||
| child: Stack( | |||
| children: <Widget>[ | |||
| //this IgnorePointer we use as touch(user Interface) widget.screen View, for example scrolloffset == 1 means drawer is close we just allow touching all widget.screen View | |||
| IgnorePointer( | |||
| ignoring: scrolloffset == 1 || false, | |||
| child: widget.screenView, | |||
| ), | |||
| //alternative touch(user Interface) for widget.screen, for example, drawer is close we need to tap on a few home screen area and close the drawer | |||
| if (scrolloffset == 1.0) | |||
| InkWell( | |||
| onTap: () { | |||
| onDrawerClick(); | |||
| }, | |||
| ), | |||
| // this just menu and arrow icon animation | |||
| Padding( | |||
| padding: EdgeInsets.only( | |||
| top: MediaQuery.of(context).padding.top + 8, | |||
| left: 8), | |||
| child: SizedBox( | |||
| width: AppBar().preferredSize.height - 8, | |||
| height: AppBar().preferredSize.height - 8, | |||
| child: Material( | |||
| color: Colors.transparent, | |||
| child: InkWell( | |||
| borderRadius: BorderRadius.circular( | |||
| AppBar().preferredSize.height), | |||
| child: Center( | |||
| // if you use your own menu view UI you add form initialization | |||
| child: widget.menuView != null | |||
| ? widget.menuView | |||
| : AnimatedIcon( | |||
| icon: widget.animatedIconData != null | |||
| ? widget.animatedIconData | |||
| : AnimatedIcons.arrow_menu, | |||
| progress: iconAnimationController), | |||
| ), | |||
| onTap: () { | |||
| FocusScope.of(context) | |||
| .requestFocus(FocusNode()); | |||
| onDrawerClick(); | |||
| }, | |||
| ), | |||
| ), | |||
| ), | |||
| ), | |||
| ], | |||
| ), | |||
| ), | |||
| ), | |||
| ], | |||
| ), | |||
| ), | |||
| ), | |||
| ); | |||
| } | |||
| void onDrawerClick() { | |||
| getSharedPrefs(); | |||
| //if scrollcontroller.offset != 0.0 then we set to closed the drawer(with animation to offset zero position) if is not 1 then open the drawer | |||
| if (scrollController.offset != 0.0) { | |||
| scrollController.animateTo( | |||
| 0.0, | |||
| duration: const Duration(milliseconds: 400), | |||
| curve: Curves.fastOutSlowIn, | |||
| ); | |||
| } else { | |||
| scrollController.animateTo( | |||
| widget.drawerWidth, | |||
| duration: const Duration(milliseconds: 400), | |||
| curve: Curves.fastOutSlowIn, | |||
| ); | |||
| } | |||
| } | |||
| Future<Null> getSharedPrefs() async { | |||
| try { | |||
| updateFullName.init(); | |||
| var currentFullName = await pref.getString(DATA_CONST.CURRENT_FULL_NAME); | |||
| if (currentFullName.isEmpty) { | |||
| var currentUser = await _userRepository.getUser(); | |||
| pref.saveString(DATA_CONST.CURRENT_FULL_NAME, currentUser.fullName); | |||
| updateFullName.changeName(currentUser.fullName); | |||
| } else { | |||
| updateFullName.changeName(currentFullName); | |||
| } | |||
| } catch (e) { | |||
| print("error: ${e.toString()}"); | |||
| } | |||
| } | |||
| } | |||
| @@ -1,416 +0,0 @@ | |||
| import 'package:badges/badges.dart'; | |||
| import 'package:farm_tpf/authentication/authentication.dart'; | |||
| import 'package:farm_tpf/custom_model/NotificationObjectDTO.dart'; | |||
| import 'package:farm_tpf/data/repository/user_repository.dart'; | |||
| import 'package:farm_tpf/presentation/screens/notification/sc_notification.dart'; | |||
| import 'package:farm_tpf/presentation/screens/notification/update_count_noti_bloc.dart'; | |||
| import 'package:farm_tpf/presentation/screens/profile/sc_update_profile.dart'; | |||
| import 'package:farm_tpf/utils/const_color.dart'; | |||
| import 'package:farm_tpf/utils/pref.dart'; | |||
| import 'package:flutter/material.dart'; | |||
| import 'package:flutter_bloc/flutter_bloc.dart'; | |||
| import 'package:get/get.dart'; | |||
| import 'package:get/state_manager.dart'; | |||
| import '../../../main.dart'; | |||
| class HomeDrawer extends StatefulWidget { | |||
| const HomeDrawer( | |||
| {Key key, | |||
| this.screenIndex, | |||
| this.iconAnimationController, | |||
| this.callBackIndex}) | |||
| : super(key: key); | |||
| final AnimationController iconAnimationController; | |||
| final DrawerIndex screenIndex; | |||
| final Function(DrawerIndex) callBackIndex; | |||
| @override | |||
| _HomeDrawerState createState() => _HomeDrawerState(); | |||
| } | |||
| class _HomeDrawerState extends State<HomeDrawer> { | |||
| var currentDrawerIndex = DrawerIndex.Home; | |||
| var pref = LocalPref(); | |||
| UserRepository _userRepository = UserRepository(); | |||
| List<DrawerList> drawerList; | |||
| final updateFullName = Get.put(UpdateFullName()); | |||
| @override | |||
| void initState() { | |||
| setdDrawerListArray(); | |||
| super.initState(); | |||
| } | |||
| void setdDrawerListArray() { | |||
| drawerList = <DrawerList>[ | |||
| DrawerList( | |||
| index: DrawerIndex.ScanBarcode, | |||
| labelName: "Quét mã QR", | |||
| icon: Icon(Icons.camera)), | |||
| DrawerList( | |||
| index: DrawerIndex.Home, | |||
| labelName: 'Danh sách lô', | |||
| icon: Icon(Icons.home), | |||
| ), | |||
| DrawerList( | |||
| index: DrawerIndex.ControlDevice, | |||
| labelName: 'Điều khiển thiết bị', | |||
| icon: Icon(Icons.device_hub), | |||
| ) | |||
| ]; | |||
| } | |||
| @override | |||
| Widget build(BuildContext context) { | |||
| return Container( | |||
| child: Column( | |||
| crossAxisAlignment: CrossAxisAlignment.stretch, | |||
| mainAxisAlignment: MainAxisAlignment.start, | |||
| children: <Widget>[ | |||
| Container( | |||
| width: double.infinity, | |||
| padding: const EdgeInsets.only(top: 45.0), | |||
| child: Container( | |||
| padding: const EdgeInsets.all(16.0), | |||
| child: Column( | |||
| crossAxisAlignment: CrossAxisAlignment.start, | |||
| mainAxisAlignment: MainAxisAlignment.start, | |||
| children: <Widget>[ | |||
| AnimatedBuilder( | |||
| animation: widget.iconAnimationController, | |||
| builder: (BuildContext context, Widget child) { | |||
| return ScaleTransition( | |||
| scale: AlwaysStoppedAnimation<double>( | |||
| 1.0 - (widget.iconAnimationController.value) * 0.2), | |||
| child: RotationTransition( | |||
| turns: AlwaysStoppedAnimation<double>(Tween<double>( | |||
| begin: 0.0, end: 24.0) | |||
| .animate(CurvedAnimation( | |||
| parent: widget.iconAnimationController, | |||
| curve: Curves.fastOutSlowIn)) | |||
| .value / | |||
| 360), | |||
| child: Container( | |||
| height: 100, | |||
| width: 100, | |||
| decoration: BoxDecoration( | |||
| borderRadius: BorderRadius.circular(120), | |||
| border: Border.all( | |||
| width: 0.35, color: AppColors.DEFAULT), | |||
| ), | |||
| child: ClipRRect( | |||
| borderRadius: | |||
| const BorderRadius.all(Radius.circular(10.0)), | |||
| child: FlutterLogo( | |||
| size: 10, | |||
| ), | |||
| ), | |||
| ), | |||
| ), | |||
| ); | |||
| }, | |||
| ), | |||
| Padding( | |||
| padding: const EdgeInsets.only(top: 8, left: 20), | |||
| child: Text( | |||
| '${Get.find<UpdateFullName>().fullName ?? ''}', | |||
| style: TextStyle( | |||
| fontWeight: FontWeight.w600, | |||
| color: AppColors.GRAY1, | |||
| fontSize: 18, | |||
| ), | |||
| ), | |||
| ), | |||
| ], | |||
| ), | |||
| ), | |||
| ), | |||
| const SizedBox( | |||
| height: 4, | |||
| ), | |||
| Divider( | |||
| height: 1, | |||
| color: AppColors.GRAY1, | |||
| ), | |||
| Expanded( | |||
| child: ListView.builder( | |||
| physics: const BouncingScrollPhysics(), | |||
| padding: const EdgeInsets.all(0.0), | |||
| itemCount: drawerList.length, | |||
| itemBuilder: (BuildContext context, int index) { | |||
| return inkwell(drawerList[index]); | |||
| }, | |||
| ), | |||
| ), | |||
| Divider( | |||
| height: 1, | |||
| color: AppColors.GRAY1, | |||
| ), | |||
| Column( | |||
| children: <Widget>[ | |||
| ListTile( | |||
| title: Text( | |||
| 'Thông báo', | |||
| style: TextStyle( | |||
| fontWeight: FontWeight.w600, | |||
| fontSize: 16, | |||
| ), | |||
| textAlign: TextAlign.left, | |||
| ), | |||
| leading: _iconWithBadgeNotiCount(), | |||
| onTap: () { | |||
| navigationtoScreen(currentDrawerIndex); | |||
| Navigator.of(context).push( | |||
| MaterialPageRoute(builder: (_) => NotificationScreen())); | |||
| }, | |||
| ), | |||
| SizedBox( | |||
| height: 2.0, | |||
| ), | |||
| ListTile( | |||
| title: Text( | |||
| 'Cài đặt', | |||
| style: TextStyle( | |||
| fontWeight: FontWeight.w600, | |||
| fontSize: 16, | |||
| ), | |||
| textAlign: TextAlign.left, | |||
| ), | |||
| leading: Icon( | |||
| Icons.settings, | |||
| color: Colors.black, | |||
| ), | |||
| onTap: () { | |||
| navigationtoScreen(currentDrawerIndex); | |||
| Navigator.of(context).push( | |||
| MaterialPageRoute(builder: (_) => UpdateProfileScreen())); | |||
| }, | |||
| ), | |||
| SizedBox( | |||
| height: 2.0, | |||
| ), | |||
| ListTile( | |||
| title: Text( | |||
| 'Đăng xuất', | |||
| style: TextStyle( | |||
| fontWeight: FontWeight.w600, | |||
| fontSize: 16, | |||
| ), | |||
| textAlign: TextAlign.left, | |||
| ), | |||
| leading: Icon( | |||
| Icons.power_settings_new, | |||
| color: Colors.red, | |||
| ), | |||
| onTap: () { | |||
| _clickSignOut(); | |||
| }, | |||
| ), | |||
| SizedBox( | |||
| height: MediaQuery.of(context).padding.bottom, | |||
| ) | |||
| ], | |||
| ), | |||
| ], | |||
| ), | |||
| ); | |||
| } | |||
| Widget inkwell(DrawerList listData) { | |||
| return Material( | |||
| color: Colors.white, | |||
| child: InkWell( | |||
| splashColor: Colors.grey.withOpacity(0.1), | |||
| highlightColor: Colors.transparent, | |||
| onTap: () { | |||
| if (listData.index == DrawerIndex.ScanBarcode) { | |||
| scan(context); | |||
| navigationtoScreen(currentDrawerIndex); | |||
| } else { | |||
| currentDrawerIndex = listData.index; | |||
| navigationtoScreen(currentDrawerIndex); | |||
| } | |||
| }, | |||
| child: Stack( | |||
| children: <Widget>[ | |||
| Container( | |||
| padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), | |||
| child: Row( | |||
| children: <Widget>[ | |||
| Container( | |||
| width: 6.0, | |||
| height: 46.0, | |||
| ), | |||
| const Padding( | |||
| padding: EdgeInsets.all(4.0), | |||
| ), | |||
| listData.isAssetsImage | |||
| ? Container( | |||
| width: 24, | |||
| height: 24, | |||
| child: Image.asset(listData.imageName, | |||
| color: currentDrawerIndex == listData.index | |||
| ? AppColors.DEFAULT | |||
| : AppColors.BLACK), | |||
| ) | |||
| : Icon(listData.icon.icon, | |||
| color: widget.screenIndex == listData.index | |||
| ? AppColors.DEFAULT | |||
| : AppColors.BLACK), | |||
| const Padding( | |||
| padding: EdgeInsets.all(4.0), | |||
| ), | |||
| Text( | |||
| listData.labelName, | |||
| style: TextStyle( | |||
| fontWeight: FontWeight.w500, | |||
| fontSize: 16, | |||
| color: widget.screenIndex == listData.index | |||
| ? AppColors.DEFAULT | |||
| : AppColors.BLACK, | |||
| ), | |||
| textAlign: TextAlign.left, | |||
| ), | |||
| ], | |||
| ), | |||
| ), | |||
| widget.screenIndex == listData.index | |||
| ? AnimatedBuilder( | |||
| animation: widget.iconAnimationController, | |||
| builder: (BuildContext context, Widget child) { | |||
| return Transform( | |||
| transform: Matrix4.translationValues( | |||
| (MediaQuery.of(context).size.width * 0.75 - 64) * | |||
| (1.0 - | |||
| widget.iconAnimationController.value - | |||
| 1.0), | |||
| 0.0, | |||
| 0.0), | |||
| child: Padding( | |||
| padding: EdgeInsets.only(top: 8, bottom: 8), | |||
| child: Container( | |||
| width: | |||
| MediaQuery.of(context).size.width * 0.75 - 64, | |||
| height: 46, | |||
| decoration: BoxDecoration( | |||
| color: AppColors.DEFAULT.withOpacity(0.2), | |||
| borderRadius: new BorderRadius.only( | |||
| topLeft: Radius.circular(0), | |||
| topRight: Radius.circular(28), | |||
| bottomLeft: Radius.circular(0), | |||
| bottomRight: Radius.circular(28), | |||
| ), | |||
| ), | |||
| ), | |||
| ), | |||
| ); | |||
| }, | |||
| ) | |||
| : const SizedBox() | |||
| ], | |||
| ), | |||
| ), | |||
| ); | |||
| } | |||
| Future<void> navigationtoScreen(DrawerIndex indexScreen) async { | |||
| widget.callBackIndex(indexScreen); | |||
| } | |||
| _clickSignOut() async { | |||
| context.bloc<AuthenticationBloc>().add(AuthenticationLogoutRequested()); | |||
| try { | |||
| String pushKey = await pref.getString(DATA_CONST.PUSH_KEY); | |||
| if (pushKey.isNotEmpty) { | |||
| _userRepository | |||
| .deleteFcmToken(pushKey) | |||
| .then((value) {}) | |||
| .catchError((err) {}) | |||
| .whenComplete(() { | |||
| pref.saveString(DATA_CONST.TOKEN_KEY, ""); | |||
| pref.saveString(DATA_CONST.PUSH_KEY, ""); | |||
| pref.saveString(DATA_CONST.CURRENT_FULL_NAME, ""); | |||
| }); | |||
| } | |||
| } catch (e) { | |||
| pref.saveString(DATA_CONST.CURRENT_FULL_NAME, ""); | |||
| pref.saveString(DATA_CONST.TOKEN_KEY, ""); | |||
| pref.saveString(DATA_CONST.PUSH_KEY, ""); | |||
| } | |||
| } | |||
| Widget _iconWithBadgeNotiCount() { | |||
| return StreamBuilder( | |||
| stream: updateCountNotiBloc.actions, | |||
| builder: (context, AsyncSnapshot<dynamic> snapshot) { | |||
| if (snapshot.hasData) { | |||
| var noti = snapshot.data as NotificationObjectDTO; | |||
| var unreadNoti = noti.numberUnreadTotal.toString(); | |||
| return Badge( | |||
| badgeContent: Text( | |||
| '' + unreadNoti, | |||
| softWrap: true, | |||
| style: TextStyle(color: Colors.white), | |||
| ), | |||
| shape: BadgeShape.square, | |||
| badgeColor: Colors.red, | |||
| borderRadius: 20, | |||
| position: BadgePosition(top: -15, start: 10), | |||
| child: Icon( | |||
| Icons.notifications, | |||
| color: Colors.black, | |||
| ), | |||
| ); | |||
| } else { | |||
| return Badge( | |||
| badgeContent: Text( | |||
| '0', | |||
| softWrap: true, | |||
| style: TextStyle(color: Colors.white), | |||
| ), | |||
| shape: BadgeShape.square, | |||
| badgeColor: Colors.red, | |||
| borderRadius: 20, | |||
| position: BadgePosition(top: -15, start: 10), | |||
| child: Icon( | |||
| Icons.notifications, | |||
| color: Colors.black, | |||
| ), | |||
| ); | |||
| } | |||
| }, | |||
| ); | |||
| } | |||
| } | |||
| enum DrawerIndex { ScanBarcode, Home, ControlDevice } | |||
| class DrawerList { | |||
| DrawerList({ | |||
| this.isAssetsImage = false, | |||
| this.labelName = '', | |||
| this.icon, | |||
| this.index, | |||
| this.imageName = '', | |||
| }); | |||
| String labelName; | |||
| Icon icon; | |||
| bool isAssetsImage; | |||
| String imageName; | |||
| DrawerIndex index; | |||
| } | |||
| class UpdateFullName extends GetxController { | |||
| var fullName; | |||
| void init() { | |||
| fullName = ""; | |||
| } | |||
| void changeName(String name) { | |||
| fullName = name; | |||
| update(); | |||
| } | |||
| } | |||
| @@ -1,71 +0,0 @@ | |||
| import 'package:farm_tpf/main.dart'; | |||
| import 'package:farm_tpf/presentation/screens/control_device/sc_control_device.dart'; | |||
| import 'package:farm_tpf/presentation/screens/plot/sc_plot.dart'; | |||
| import 'package:farm_tpf/utils/const_color.dart'; | |||
| import 'package:flutter/material.dart'; | |||
| import 'drawer_user_controller.dart'; | |||
| import 'home_drawer.dart'; | |||
| class NavigationHomeScreen extends StatefulWidget { | |||
| static Route route() { | |||
| return MaterialPageRoute<void>(builder: (_) => NavigationHomeScreen()); | |||
| } | |||
| @override | |||
| _NavigationHomeScreenState createState() => _NavigationHomeScreenState(); | |||
| } | |||
| class _NavigationHomeScreenState extends State<NavigationHomeScreen> { | |||
| Widget screenView; | |||
| DrawerIndex drawerIndex; | |||
| @override | |||
| void initState() { | |||
| drawerIndex = DrawerIndex.Home; | |||
| screenView = PlotListScreen(); | |||
| super.initState(); | |||
| } | |||
| @override | |||
| Widget build(BuildContext context) { | |||
| return Container( | |||
| color: AppColors.DEFAULT, | |||
| child: SafeArea( | |||
| top: false, | |||
| bottom: false, | |||
| child: Scaffold( | |||
| backgroundColor: AppColors.WHITE, | |||
| body: DrawerUserController( | |||
| screenIndex: drawerIndex, | |||
| drawerWidth: MediaQuery.of(context).size.width * 0.75, | |||
| onDrawerCall: (DrawerIndex drawerIndexdata) { | |||
| changeIndex(drawerIndexdata); | |||
| //callback from drawer for replace screen as user need with passing DrawerIndex(Enum index) | |||
| }, | |||
| screenView: screenView, | |||
| //we replace screen view as we need on navigate starting screens like MyHomePage, HelpScreen, FeedbackScreen, etc... | |||
| ), | |||
| ), | |||
| ), | |||
| ); | |||
| } | |||
| void changeIndex(DrawerIndex drawerIndexdata) { | |||
| if (drawerIndex != drawerIndexdata) { | |||
| drawerIndex = drawerIndexdata; | |||
| if (drawerIndex == DrawerIndex.Home) { | |||
| setState(() { | |||
| screenView = PlotListScreen(); | |||
| }); | |||
| } else if (drawerIndex == DrawerIndex.ControlDevice) { | |||
| setState(() { | |||
| screenView = ControlDeviceScreen(); | |||
| }); | |||
| } else if (drawerIndex == DrawerIndex.ScanBarcode) { | |||
| } else { | |||
| //do in your way...... | |||
| } | |||
| } | |||
| } | |||
| } | |||