Initial pull-down gesture for student ID
This commit is contained in:
parent
306defc6df
commit
95400d7ee2
|
@ -1,5 +1,4 @@
|
||||||
import 'package:auto_route/auto_route.dart';
|
import 'package:auto_route/auto_route.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:furman_now/src/routes/index.gr.dart';
|
import 'package:furman_now/src/routes/index.gr.dart';
|
||||||
|
|
||||||
|
@ -37,7 +36,6 @@ class _MainLayoutState extends State<MainLayout> {
|
||||||
routes: const [
|
routes: const [
|
||||||
HomeRoute(),
|
HomeRoute(),
|
||||||
MapRoute(),
|
MapRoute(),
|
||||||
StudentIdRoute(),
|
|
||||||
EventsRoute(),
|
EventsRoute(),
|
||||||
InfoRoute(),
|
InfoRoute(),
|
||||||
],
|
],
|
||||||
|
@ -71,10 +69,6 @@ class _MainLayoutState extends State<MainLayout> {
|
||||||
icon: Icon(Icons.map),
|
icon: Icon(Icons.map),
|
||||||
label: 'Map',
|
label: 'Map',
|
||||||
),
|
),
|
||||||
BottomNavigationBarItem(
|
|
||||||
icon: Icon(Icons.perm_identity),
|
|
||||||
label: 'Meal Card',
|
|
||||||
),
|
|
||||||
BottomNavigationBarItem(
|
BottomNavigationBarItem(
|
||||||
icon: Icon(Icons.calendar_month),
|
icon: Icon(Icons.calendar_month),
|
||||||
label: 'Events',
|
label: 'Events',
|
||||||
|
|
|
@ -13,10 +13,15 @@ import '../layouts/main/index.dart';
|
||||||
AutoRoute(path: "/", page: MainLayout, children: [
|
AutoRoute(path: "/", page: MainLayout, children: [
|
||||||
AutoRoute(path: "home", page: HomeScreen),
|
AutoRoute(path: "home", page: HomeScreen),
|
||||||
AutoRoute(path: "map", page: MapScreen),
|
AutoRoute(path: "map", page: MapScreen),
|
||||||
AutoRoute(path: "student-id", page: StudentIdScreen),
|
|
||||||
AutoRoute(path: "events", page: EventsScreen),
|
AutoRoute(path: "events", page: EventsScreen),
|
||||||
AutoRoute(path: "info", page: InfoScreen),
|
AutoRoute(path: "info", page: InfoScreen),
|
||||||
]),
|
]),
|
||||||
|
CustomRoute(
|
||||||
|
path: "/student-id",
|
||||||
|
page: StudentIdScreen,
|
||||||
|
transitionsBuilder: TransitionsBuilders.slideTop,
|
||||||
|
durationInMilliseconds: 200,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
class $AppRouter {}
|
class $AppRouter {}
|
|
@ -16,10 +16,10 @@ import 'package:flutter/material.dart' as _i8;
|
||||||
|
|
||||||
import '../layouts/main/index.dart' as _i1;
|
import '../layouts/main/index.dart' as _i1;
|
||||||
import '../screens/events/index.dart' as _i5;
|
import '../screens/events/index.dart' as _i5;
|
||||||
import '../screens/home/index.dart' as _i2;
|
import '../screens/home/index.dart' as _i3;
|
||||||
import '../screens/info/index.dart' as _i6;
|
import '../screens/info/index.dart' as _i6;
|
||||||
import '../screens/map/index.dart' as _i3;
|
import '../screens/map/index.dart' as _i4;
|
||||||
import '../screens/student_id/index.dart' as _i4;
|
import '../screens/student_id/index.dart' as _i2;
|
||||||
|
|
||||||
class AppRouter extends _i7.RootStackRouter {
|
class AppRouter extends _i7.RootStackRouter {
|
||||||
AppRouter([_i8.GlobalKey<_i8.NavigatorState>? navigatorKey])
|
AppRouter([_i8.GlobalKey<_i8.NavigatorState>? navigatorKey])
|
||||||
|
@ -31,17 +31,22 @@ class AppRouter extends _i7.RootStackRouter {
|
||||||
return _i7.MaterialPageX<dynamic>(
|
return _i7.MaterialPageX<dynamic>(
|
||||||
routeData: routeData, child: const _i1.MainLayout());
|
routeData: routeData, child: const _i1.MainLayout());
|
||||||
},
|
},
|
||||||
|
StudentIdRoute.name: (routeData) {
|
||||||
|
return _i7.CustomPage<dynamic>(
|
||||||
|
routeData: routeData,
|
||||||
|
child: const _i2.StudentIdScreen(),
|
||||||
|
transitionsBuilder: _i7.TransitionsBuilders.slideTop,
|
||||||
|
durationInMilliseconds: 200,
|
||||||
|
opaque: true,
|
||||||
|
barrierDismissible: false);
|
||||||
|
},
|
||||||
HomeRoute.name: (routeData) {
|
HomeRoute.name: (routeData) {
|
||||||
return _i7.MaterialPageX<dynamic>(
|
return _i7.MaterialPageX<dynamic>(
|
||||||
routeData: routeData, child: const _i2.HomeScreen());
|
routeData: routeData, child: const _i3.HomeScreen());
|
||||||
},
|
},
|
||||||
MapRoute.name: (routeData) {
|
MapRoute.name: (routeData) {
|
||||||
return _i7.MaterialPageX<dynamic>(
|
return _i7.MaterialPageX<dynamic>(
|
||||||
routeData: routeData, child: const _i3.MapScreen());
|
routeData: routeData, child: const _i4.MapScreen());
|
||||||
},
|
|
||||||
StudentIdRoute.name: (routeData) {
|
|
||||||
return _i7.MaterialPageX<dynamic>(
|
|
||||||
routeData: routeData, child: const _i4.StudentIdScreen());
|
|
||||||
},
|
},
|
||||||
EventsRoute.name: (routeData) {
|
EventsRoute.name: (routeData) {
|
||||||
return _i7.MaterialPageX<dynamic>(
|
return _i7.MaterialPageX<dynamic>(
|
||||||
|
@ -59,12 +64,11 @@ class AppRouter extends _i7.RootStackRouter {
|
||||||
_i7.RouteConfig(HomeRoute.name,
|
_i7.RouteConfig(HomeRoute.name,
|
||||||
path: 'home', parent: MainLayout.name),
|
path: 'home', parent: MainLayout.name),
|
||||||
_i7.RouteConfig(MapRoute.name, path: 'map', parent: MainLayout.name),
|
_i7.RouteConfig(MapRoute.name, path: 'map', parent: MainLayout.name),
|
||||||
_i7.RouteConfig(StudentIdRoute.name,
|
|
||||||
path: 'student-id', parent: MainLayout.name),
|
|
||||||
_i7.RouteConfig(EventsRoute.name,
|
_i7.RouteConfig(EventsRoute.name,
|
||||||
path: 'events', parent: MainLayout.name),
|
path: 'events', parent: MainLayout.name),
|
||||||
_i7.RouteConfig(InfoRoute.name, path: 'info', parent: MainLayout.name)
|
_i7.RouteConfig(InfoRoute.name, path: 'info', parent: MainLayout.name)
|
||||||
])
|
]),
|
||||||
|
_i7.RouteConfig(StudentIdRoute.name, path: '/student-id')
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +82,15 @@ class MainLayout extends _i7.PageRouteInfo<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// generated route for
|
/// generated route for
|
||||||
/// [_i2.HomeScreen]
|
/// [_i2.StudentIdScreen]
|
||||||
|
class StudentIdRoute extends _i7.PageRouteInfo<void> {
|
||||||
|
const StudentIdRoute() : super(StudentIdRoute.name, path: '/student-id');
|
||||||
|
|
||||||
|
static const String name = 'StudentIdRoute';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// generated route for
|
||||||
|
/// [_i3.HomeScreen]
|
||||||
class HomeRoute extends _i7.PageRouteInfo<void> {
|
class HomeRoute extends _i7.PageRouteInfo<void> {
|
||||||
const HomeRoute() : super(HomeRoute.name, path: 'home');
|
const HomeRoute() : super(HomeRoute.name, path: 'home');
|
||||||
|
|
||||||
|
@ -86,21 +98,13 @@ class HomeRoute extends _i7.PageRouteInfo<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// generated route for
|
/// generated route for
|
||||||
/// [_i3.MapScreen]
|
/// [_i4.MapScreen]
|
||||||
class MapRoute extends _i7.PageRouteInfo<void> {
|
class MapRoute extends _i7.PageRouteInfo<void> {
|
||||||
const MapRoute() : super(MapRoute.name, path: 'map');
|
const MapRoute() : super(MapRoute.name, path: 'map');
|
||||||
|
|
||||||
static const String name = 'MapRoute';
|
static const String name = 'MapRoute';
|
||||||
}
|
}
|
||||||
|
|
||||||
/// generated route for
|
|
||||||
/// [_i4.StudentIdScreen]
|
|
||||||
class StudentIdRoute extends _i7.PageRouteInfo<void> {
|
|
||||||
const StudentIdRoute() : super(StudentIdRoute.name, path: 'student-id');
|
|
||||||
|
|
||||||
static const String name = 'StudentIdRoute';
|
|
||||||
}
|
|
||||||
|
|
||||||
/// generated route for
|
/// generated route for
|
||||||
/// [_i5.EventsScreen]
|
/// [_i5.EventsScreen]
|
||||||
class EventsRoute extends _i7.PageRouteInfo<void> {
|
class EventsRoute extends _i7.PageRouteInfo<void> {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:auto_route/auto_route.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:furman_now/src/routes/index.gr.dart';
|
import 'package:furman_now/src/routes/index.gr.dart';
|
||||||
import 'package:furman_now/src/utils/greeting.dart';
|
import 'package:furman_now/src/utils/greeting.dart';
|
||||||
|
@ -54,7 +55,20 @@ class HomeScreen extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
ScrollViewWithHeight(
|
NotificationListener<ScrollNotification>(
|
||||||
|
onNotification: (notification) {
|
||||||
|
if (notification is ScrollUpdateNotification) {
|
||||||
|
final offset = notification.metrics.pixels;
|
||||||
|
if (offset < 0) {
|
||||||
|
var offsetAmount = offset.abs();
|
||||||
|
if (offsetAmount > 50) {
|
||||||
|
context.router.navigate(const StudentIdRoute());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
child: ScrollViewWithHeight(
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
|
@ -85,6 +99,7 @@ class HomeScreen extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:auto_route/auto_route.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:barcode_widget/barcode_widget.dart';
|
import 'package:barcode_widget/barcode_widget.dart';
|
||||||
|
import 'package:furman_now/src/routes/index.gr.dart';
|
||||||
import 'package:furman_now/src/services/get_app/barcode/barcode_service.dart';
|
import 'package:furman_now/src/services/get_app/barcode/barcode_service.dart';
|
||||||
import 'package:furman_now/src/utils/theme.dart';
|
import 'package:furman_now/src/utils/theme.dart';
|
||||||
|
|
||||||
|
@ -26,6 +28,12 @@ class _StudentIdScreenState extends State<StudentIdScreen> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
timer?.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
void updateBarcode(Timer timer) {
|
void updateBarcode(Timer timer) {
|
||||||
setState(() {
|
setState(() {
|
||||||
barcodeNumber = BarcodeService.generateGetBarcode();
|
barcodeNumber = BarcodeService.generateGetBarcode();
|
||||||
|
@ -35,7 +43,16 @@ class _StudentIdScreenState extends State<StudentIdScreen> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Container(
|
body: Listener(
|
||||||
|
onPointerMove: (details) {
|
||||||
|
int sensitivity = 8;
|
||||||
|
if (details.delta.dy > sensitivity) {
|
||||||
|
// Down Swipe
|
||||||
|
} else if (details.delta.dy < -sensitivity) {
|
||||||
|
context.router.navigate(const MainLayout());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
color: const Color(0xffb7acc9),
|
color: const Color(0xffb7acc9),
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
child: ListView(
|
child: ListView(
|
||||||
|
@ -67,6 +84,7 @@ class _StudentIdScreenState extends State<StudentIdScreen> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,14 @@ class ScrollViewWithHeight extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
|
return LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
|
physics: const BouncingScrollPhysics(
|
||||||
|
parent: AlwaysScrollableScrollPhysics()
|
||||||
|
),
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints: constraints.copyWith(minHeight: constraints.maxHeight, maxHeight: double.infinity),
|
constraints: constraints.copyWith(
|
||||||
|
minHeight: constraints.maxHeight,
|
||||||
|
maxHeight: double.infinity
|
||||||
|
),
|
||||||
child: child,
|
child: child,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue