Initial pull-down gesture for student ID

This commit is contained in:
Michael Thomas 2022-09-03 18:05:53 -04:00
parent 306defc6df
commit 95400d7ee2
6 changed files with 127 additions and 85 deletions

View File

@ -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',

View File

@ -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 {}

View File

@ -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> {

View File

@ -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,34 +55,48 @@ class HomeScreen extends StatelessWidget {
), ),
), ),
), ),
ScrollViewWithHeight( NotificationListener<ScrollNotification>(
child: Container( onNotification: (notification) {
decoration: const BoxDecoration( if (notification is ScrollUpdateNotification) {
color: Colors.white, final offset = notification.metrics.pixels;
borderRadius: BorderRadius.vertical(top: Radius.circular(30)), if (offset < 0) {
), var offsetAmount = offset.abs();
padding: const EdgeInsets.symmetric(vertical: 20), if (offsetAmount > 50) {
margin: const EdgeInsets.only(top: 200), context.router.navigate(const StudentIdRoute());
width: double.infinity, }
child: Column( }
crossAxisAlignment: CrossAxisAlignment.start, }
children: [ return true;
const HeaderWidget( },
title: "Today's Events", child: ScrollViewWithHeight(
link: HeaderLink(text: "View more", href: EventsRoute()), child: Container(
), decoration: const BoxDecoration(
Padding( color: Colors.white,
padding: const EdgeInsets.symmetric(horizontal: 20), borderRadius: BorderRadius.vertical(top: Radius.circular(30)),
child: EventsList(), ),
), padding: const EdgeInsets.symmetric(vertical: 20),
const HeaderWidget(title: "Food & Dining"), margin: const EdgeInsets.only(top: 200),
const RestaurantsList(), width: double.infinity,
const HeaderWidget(title: "Transportation"), child: Column(
const Padding( crossAxisAlignment: CrossAxisAlignment.start,
padding: EdgeInsets.symmetric(horizontal: 20), children: [
child: TransportationCard(), const HeaderWidget(
), title: "Today's Events",
], link: HeaderLink(text: "View more", href: EventsRoute()),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: EventsList(),
),
const HeaderWidget(title: "Food & Dining"),
const RestaurantsList(),
const HeaderWidget(title: "Transportation"),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 20),
child: TransportationCard(),
),
],
),
), ),
), ),
), ),

View File

@ -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,35 +43,45 @@ class _StudentIdScreenState extends State<StudentIdScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
body: Container( body: Listener(
color: const Color(0xffb7acc9), onPointerMove: (details) {
child: SafeArea( int sensitivity = 8;
child: ListView( if (details.delta.dy > sensitivity) {
padding: const EdgeInsets.all(40), // Down Swipe
children: [ } else if (details.delta.dy < -sensitivity) {
Text( context.router.navigate(const MainLayout());
"Furman ID", }
style: furmanTextStyle(const TextStyle(color: Color(0xff26183d), fontSize: 36, fontWeight: FontWeight.w800)), },
), child: Container(
const SizedBox(height: 200), color: const Color(0xffb7acc9),
Container( child: SafeArea(
decoration: const BoxDecoration( child: ListView(
color: Colors.white, padding: const EdgeInsets.all(40),
borderRadius: BorderRadius.all(Radius.circular(10)), children: [
Text(
"Furman ID",
style: furmanTextStyle(const TextStyle(color: Color(0xff26183d), fontSize: 36, fontWeight: FontWeight.w800)),
), ),
// hack since the barcode has a weird intrinsic size for some reason const SizedBox(height: 200),
child: LayoutBuilder( Container(
builder: (BuildContext context, BoxConstraints constraints) { decoration: const BoxDecoration(
return BarcodeWidget( color: Colors.white,
barcode: Barcode.pdf417(moduleHeight: 4), borderRadius: BorderRadius.all(Radius.circular(10)),
data: barcodeNumber, ),
margin: const EdgeInsets.all(10), // hack since the barcode has a weird intrinsic size for some reason
height: constraints.maxWidth / 3, child: LayoutBuilder(
); builder: (BuildContext context, BoxConstraints constraints) {
}, return BarcodeWidget(
barcode: Barcode.pdf417(moduleHeight: 4),
data: barcodeNumber,
margin: const EdgeInsets.all(10),
height: constraints.maxWidth / 3,
);
},
),
), ),
), ],
], ),
), ),
), ),
), ),

View File

@ -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,
), ),
); );