From 14bfa001cb1d274d54835b88caaefffe3c944415 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Beno=C3=AEt=20Harrault?= <benoit@harrault.fr>
Date: Wed, 15 Nov 2023 14:32:03 +0100
Subject: [PATCH] Add swipe left/right debug

---
 android/gradle.properties      |  4 ++--
 lib/ui/skeleton.dart           | 13 ++++++++++++-
 lib/ui/widgets/debug_bloc.dart | 28 ++++++++++++++++++++++++++++
 pubspec.yaml                   |  2 +-
 4 files changed, 43 insertions(+), 4 deletions(-)
 create mode 100644 lib/ui/widgets/debug_bloc.dart

diff --git a/android/gradle.properties b/android/gradle.properties
index c184c0b..6c74aa0 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.31
-app.versionCode=32
+app.versionName=1.0.32
+app.versionCode=33
diff --git a/lib/ui/skeleton.dart b/lib/ui/skeleton.dart
index e8493f1..01f8cca 100644
--- a/lib/ui/skeleton.dart
+++ b/lib/ui/skeleton.dart
@@ -9,6 +9,7 @@ import 'package:random/ui/screens/graph_page.dart';
 import 'package:random/ui/screens/settings_page.dart';
 import 'package:random/ui/widgets/app_bar.dart';
 import 'package:random/ui/widgets/bottom_nav_bar.dart';
+import 'package:random/ui/widgets/debug_bloc.dart';
 
 class SkeletonScreen extends StatefulWidget {
   const SkeletonScreen({super.key});
@@ -27,6 +28,8 @@ class _SkeletonScreenState extends State<SkeletonScreen> {
       AboutPage(),
     ];
 
+    String debug = '';
+
     return BlocProvider<SettingsCubit>(
       create: (BuildContext context) => SettingsCubit(),
       child: BlocProvider<BottomNavCubit>(
@@ -35,6 +38,9 @@ class _SkeletonScreenState extends State<SkeletonScreen> {
           builder: (BuildContext context, int state) {
             return GestureDetector(
               onHorizontalDragEnd: (dragDetail) {
+                debug = dragDetail.velocity.pixelsPerSecond.toString();
+                print('debug: ' + debug);
+
                 if (dragDetail.velocity.pixelsPerSecond.dx < 1) {
                   context.read<BottomNavCubit>().moveNext();
                 } else {
@@ -48,7 +54,12 @@ class _SkeletonScreenState extends State<SkeletonScreen> {
                   builder: (BuildContext context, int state) {
                     return AnimatedSwitcher(
                       duration: const Duration(milliseconds: 300),
-                      child: pageNavigation.elementAt(state),
+                      child: Stack(
+                        children: [
+                          pageNavigation.elementAt(state),
+                          debug != '' ? DebugBloc(content: debug) : SizedBox(),
+                        ],
+                      ),
                     );
                   },
                 ),
diff --git a/lib/ui/widgets/debug_bloc.dart b/lib/ui/widgets/debug_bloc.dart
new file mode 100644
index 0000000..502bacc
--- /dev/null
+++ b/lib/ui/widgets/debug_bloc.dart
@@ -0,0 +1,28 @@
+import 'package:flutter/material.dart';
+
+class DebugBloc extends StatelessWidget {
+  const DebugBloc({super.key, required this.content});
+
+  final String content;
+
+  @override
+  Widget build(BuildContext context) {
+    return Container(
+      decoration: BoxDecoration(
+        color: Colors.red,
+        border: Border.all(
+          color: Colors.grey,
+          width: 2,
+        ),
+      ),
+      child: Padding(
+        padding: EdgeInsets.all(5),
+        child: Text(
+          content,
+          textAlign: TextAlign.start,
+          style: TextStyle(fontSize: 13),
+        ),
+      ),
+    );
+  }
+}
diff --git a/pubspec.yaml b/pubspec.yaml
index f98000d..fcec926 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.31+32
+version: 1.0.32+33
 
 environment:
   sdk: '^3.0.0'
-- 
GitLab