Untitled
unknown
plain_text
2 years ago
5.1 kB
6
Indexable
import 'package:convex_bottom_bar/convex_bottom_bar.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:golf_flutter/service/firebase/firebase_notification_service.dart'; import 'package:golf_flutter/service/local_service.dart'; import 'package:grock/grock.dart'; import '../../assets.dart'; import '../../constants/colors.dart'; import '../../riverpod/base_scaffold_riverpod.dart'; import '../friends-requests/friends_requests_view.dart'; final baseScaffoldAppRiverpod = ChangeNotifierProvider((ref) => BaseScaffoldRiverpod()); class SkeletonView extends ConsumerStatefulWidget { const SkeletonView({Key? key}) : super(key: key); @override ConsumerState<ConsumerStatefulWidget> createState() => _SkeletonViewState(); } class _SkeletonViewState extends ConsumerState<SkeletonView> { final _service = FirebaseNotificationService(); @override void initState() { super.initState(); _service.connectNotification(); ref.read(baseScaffoldAppRiverpod).currentIndex = 0; } @override Widget build(BuildContext context) { var read = ref.read(baseScaffoldAppRiverpod); var watch = ref.watch(baseScaffoldAppRiverpod); return Scaffold( body: LocalService().loginType == 0 ? watch.bodyTournament() : LocalService().loginType == 1 ? watch.bodyManager() : watch.body(), bottomNavigationBar: LocalService().loginType == 0 ? _bottomBarTournament(read, watch) : LocalService().loginType == 1 ? _bottomBarManager(read, watch) : _bottomBar(read, watch), ); } Widget _bottomBar(BaseScaffoldRiverpod read, BaseScaffoldRiverpod watch) { return ConvexAppBar( onTap: (int index) => read.setCurrentIndex(index), activeColor: AppColor.mainGreen, backgroundColor: Colors.white, color: AppColor.grey, curveSize: 0, elevation: 1, style: TabStyle.reactCircle, items: [ TabItem( icon: inActiveTabIcon(Assets.icons.icHomeSVG), activeIcon: activeTabIcon(Assets.icons.icHomeSVG), isIconBlend: true, ), TabItem( icon: inActiveTabIcon(Assets.icons.icCourthouseSVG), activeIcon: activeTabIcon(Assets.icons.icCourthouseSVG), isIconBlend: true, ), TabItem( icon: inActiveTabIcon(Assets.icons.icPhotosSVG), activeIcon: activeTabIcon(Assets.icons.icPhotosSVG), isIconBlend: true, ), TabItem( icon: inActiveTabIcon(Assets.icons.icPersonSVG), activeIcon: activeTabIcon(Assets.icons.icPersonSVG), isIconBlend: true, ), ], initialActiveIndex: watch.currentIndex, ); } Widget _bottomBarTournament( BaseScaffoldRiverpod read, BaseScaffoldRiverpod watch) { return ConvexAppBar( onTap: (int index) => read.setCurrentIndex(index), activeColor: AppColor.mainGreen, backgroundColor: Colors.white, color: AppColor.grey, curveSize: 0, elevation: 1, style: TabStyle.reactCircle, items: [ TabItem( icon: inActiveTabIcon(Assets.icons.icHomeSVG), activeIcon: activeTabIcon(Assets.icons.icHomeSVG), isIconBlend: true, ), TabItem( icon: inActiveTabIcon(Assets.icons.icBellSVG), activeIcon: activeTabIcon(Assets.icons.icBellSVG), isIconBlend: true, ), TabItem( icon: inActiveTabIcon(Assets.icons.icPersonSVG), activeIcon: activeTabIcon(Assets.icons.icPersonSVG), isIconBlend: true, ), ], initialActiveIndex: watch.currentIndex, ); } Widget _bottomBarManager( BaseScaffoldRiverpod read, BaseScaffoldRiverpod watch) { return ConvexAppBar( onTap: (int index) => read.setCurrentIndex(index), activeColor: AppColor.mainGreen, backgroundColor: Colors.white, color: AppColor.grey, curveSize: 0, elevation: 1, style: TabStyle.reactCircle, items: [ TabItem( icon: inActiveTabIcon(Assets.icons.icHomeSVG), activeIcon: activeTabIcon(Assets.icons.icHomeSVG), isIconBlend: true, ), TabItem( icon: inActiveTabIcon(Assets.icons.icBellSVG), activeIcon: activeTabIcon(Assets.icons.icBellSVG), isIconBlend: true, ), TabItem( icon: inActiveTabIcon(Assets.icons.icPersonSVG), activeIcon: activeTabIcon(Assets.icons.icPersonSVG), isIconBlend: true, ), ], initialActiveIndex: watch.currentIndex, ); } Widget inActiveTabIcon(String iconPath) => SizedBox(width: 22, child: SvgPicture.asset(iconPath)); Widget activeTabIcon(String iconPath) => Padding(padding: 20.allP, child: SvgPicture.asset(iconPath)); }
Editor is loading...