diff --git a/android/gradle.properties b/android/gradle.properties index 6d538ee650c8ec589c0c43845e1e24c0e2e54db0..90f56e609e4f9b97af2e5aafc2a375cf2dbe1762 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,5 +1,5 @@ org.gradle.jvmargs=-Xmx1536M android.useAndroidX=true android.enableJetifier=true -app.versionName=1.0.27 -app.versionCode=28 +app.versionName=1.0.28 +app.versionCode=29 diff --git a/lib/cubit/bottom_nav_cubit.dart b/lib/cubit/bottom_nav_cubit.dart index cc714ed3e4cbf29cecd0ae0e200f72181c51a9ab..ff21cc4493ea290205ca5fe8ed0099fa3b0f619a 100644 --- a/lib/cubit/bottom_nav_cubit.dart +++ b/lib/cubit/bottom_nav_cubit.dart @@ -5,6 +5,9 @@ class BottomNavCubit extends HydratedCubit<int> { void updateIndex(int index) => emit(index); + void movePrevious() => emit((state > 0) ? state - 1 : state); + void moveNext() => emit((state < 3) ? state + 1 : state); + void getDemoPage() => emit(0); void getGraphPage() => emit(1); void getSettingsPage() => emit(2); diff --git a/lib/ui/screens/skeleton_screen.dart b/lib/ui/screens/skeleton_screen.dart index 2af9954e55c7b3c4c698e5ed1cb52f89ad729c2b..a08274b9fdec93802636e47b042623ef9a8a7032 100644 --- a/lib/ui/screens/skeleton_screen.dart +++ b/lib/ui/screens/skeleton_screen.dart @@ -33,18 +33,32 @@ class _SkeletonScreenState extends State<SkeletonScreen> { create: (BuildContext context) => SettingsCubit(), child: BlocProvider<BottomNavCubit>( create: (BuildContext context) => BottomNavCubit(), - child: Scaffold( - extendBodyBehindAppBar: false, - appBar: StandardAppBar(), - body: BlocBuilder<BottomNavCubit, int>( - builder: (BuildContext context, int state) { - return AnimatedSwitcher( - duration: const Duration(milliseconds: 300), - child: pageNavigation.elementAt(state)); - }, - ), - bottomNavigationBar: const BottomNavBar(), - backgroundColor: Theme.of(context).colorScheme.background, + child: BlocBuilder<BottomNavCubit, int>( + builder: (BuildContext context, int state) { + return GestureDetector( + onHorizontalDragEnd: (dragDetail) { + if (dragDetail.velocity.pixelsPerSecond.dx < 1) { + context.read<BottomNavCubit>().moveNext(); + } else { + context.read<BottomNavCubit>().movePrevious(); + } + }, + child: Scaffold( + extendBodyBehindAppBar: false, + appBar: StandardAppBar(), + body: BlocBuilder<BottomNavCubit, int>( + builder: (BuildContext context, int state) { + return AnimatedSwitcher( + duration: const Duration(milliseconds: 300), + child: pageNavigation.elementAt(state), + ); + }, + ), + bottomNavigationBar: const BottomNavBar(), + backgroundColor: Theme.of(context).colorScheme.background, + ), + ); + }, ), ), ); diff --git a/lib/ui/widgets/bottom_nav_bar.dart b/lib/ui/widgets/bottom_nav_bar.dart index ea33889bf698eff47c9cd4e2a5170bd11611df4b..88dd014307f08865da15d9de98d54111a05b63df 100644 --- a/lib/ui/widgets/bottom_nav_bar.dart +++ b/lib/ui/widgets/bottom_nav_bar.dart @@ -21,35 +21,37 @@ class BottomNavBar extends StatelessWidget { topRight: Radius.circular(16), ), ), - child: BlocBuilder<BottomNavCubit, int>(builder: (BuildContext context, int state) { - return BottomNavigationBar( - currentIndex: state, - onTap: (int index) => context.read<BottomNavCubit>().updateIndex(index), - type: BottomNavigationBarType.fixed, - elevation: 0, - backgroundColor: Colors.transparent, - selectedItemColor: Theme.of(context).colorScheme.primary, - unselectedItemColor: Theme.of(context).textTheme.bodySmall!.color, - items: <BottomNavigationBarItem>[ - BottomNavigationBarItem( - icon: const Icon(Ionicons.image_outline), - label: tr('bottom_nav_sample'), - ), - BottomNavigationBarItem( - icon: const Icon(Ionicons.pencil_outline), - label: tr('bottom_nav_chart'), - ), - BottomNavigationBarItem( - icon: const Icon(Ionicons.settings_outline), - label: tr('bottom_nav_settings'), - ), - BottomNavigationBarItem( - icon: const Icon(Ionicons.information_circle), - label: tr('bottom_nav_about'), - ), - ], - ); - }), + child: BlocBuilder<BottomNavCubit, int>( + builder: (BuildContext context, int state) { + return BottomNavigationBar( + currentIndex: state, + onTap: (int index) => context.read<BottomNavCubit>().updateIndex(index), + type: BottomNavigationBarType.fixed, + elevation: 0, + backgroundColor: Colors.transparent, + selectedItemColor: Theme.of(context).colorScheme.primary, + unselectedItemColor: Theme.of(context).textTheme.bodySmall!.color, + items: <BottomNavigationBarItem>[ + BottomNavigationBarItem( + icon: const Icon(Ionicons.image_outline), + label: tr('bottom_nav_sample'), + ), + BottomNavigationBarItem( + icon: const Icon(Ionicons.pencil_outline), + label: tr('bottom_nav_chart'), + ), + BottomNavigationBarItem( + icon: const Icon(Ionicons.settings_outline), + label: tr('bottom_nav_settings'), + ), + BottomNavigationBarItem( + icon: const Icon(Ionicons.information_circle), + label: tr('bottom_nav_about'), + ), + ], + ); + }, + ), ); } } diff --git a/pubspec.yaml b/pubspec.yaml index 2c42e12b84a4d63f84c4334a9ba7e7201b0871c6..ab6acea7cc0bac20882b6333e10eb06250fe6d16 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: A random application, for testing purpose only. publish_to: 'none' -version: 1.0.27+28 +version: 1.0.28+29 environment: sdk: '^3.0.0'