Skip to content
Snippets Groups Projects
Commit 13a8455b authored by Benoît Harrault's avatar Benoît Harrault
Browse files

Merge branch '30-allow-navigation-with-swipe' into 'master'

Resolve "Allow navigation with swipe"

Closes #30

See merge request !24
parents 305bf0d4 44d59e90
No related branches found
No related tags found
1 merge request!24Resolve "Allow navigation with swipe"
Pipeline #4561 passed
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
app.versionName=0.0.22
app.versionCode=22
app.versionName=0.0.23
app.versionCode=23
Allow swipe to navigate between pages.
Navigation entre pages par mouvement de "swipe".
......@@ -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 < 2) ? state + 1 : state);
void getHomePage() => emit(0);
void getDiscoveriesPage() => emit(1);
void getStatisticsPage() => emit(2);
......
......@@ -27,6 +27,16 @@ class _SkeletonScreenState extends State<SkeletonScreen> {
return BlocProvider<BottomNavCubit>(
create: (BuildContext context) => BottomNavCubit(),
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(
appBar: StandardAppBar(notifyParent: refresh),
extendBodyBehindAppBar: false,
......@@ -34,13 +44,17 @@ class _SkeletonScreenState extends State<SkeletonScreen> {
builder: (BuildContext context, int state) {
return AnimatedSwitcher(
duration: const Duration(milliseconds: 300),
child: pageNavigation.elementAt(state));
child: pageNavigation.elementAt(state),
);
},
),
bottomNavigationBar: const BottomNavBar(),
backgroundColor: Theme.of(context).colorScheme.background,
),
);
},
),
);
}
refresh() {
......
......@@ -21,7 +21,8 @@ class BottomNavBar extends StatelessWidget {
topRight: Radius.circular(16),
),
),
child: BlocBuilder<BottomNavCubit, int>(builder: (BuildContext context, int state) {
child: BlocBuilder<BottomNavCubit, int>(
builder: (BuildContext context, int state) {
return BottomNavigationBar(
currentIndex: state,
onTap: (int index) => context.read<BottomNavCubit>().updateIndex(index),
......@@ -45,7 +46,8 @@ class BottomNavBar extends StatelessWidget {
),
],
);
}),
},
),
);
}
}
......@@ -3,7 +3,7 @@ description: Display scrobbles data and charts
publish_to: 'none'
version: 0.0.22+22
version: 0.0.23+23
environment:
sdk: '^3.0.0'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment