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:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:furman_now/src/routes/index.gr.dart';
|
||||
|
||||
|
@ -37,7 +36,6 @@ class _MainLayoutState extends State<MainLayout> {
|
|||
routes: const [
|
||||
HomeRoute(),
|
||||
MapRoute(),
|
||||
StudentIdRoute(),
|
||||
EventsRoute(),
|
||||
InfoRoute(),
|
||||
],
|
||||
|
@ -71,10 +69,6 @@ class _MainLayoutState extends State<MainLayout> {
|
|||
icon: Icon(Icons.map),
|
||||
label: 'Map',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.perm_identity),
|
||||
label: 'Meal Card',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.calendar_month),
|
||||
label: 'Events',
|
||||
|
|
|
@ -13,10 +13,15 @@ import '../layouts/main/index.dart';
|
|||
AutoRoute(path: "/", page: MainLayout, children: [
|
||||
AutoRoute(path: "home", page: HomeScreen),
|
||||
AutoRoute(path: "map", page: MapScreen),
|
||||
AutoRoute(path: "student-id", page: StudentIdScreen),
|
||||
AutoRoute(path: "events", page: EventsScreen),
|
||||
AutoRoute(path: "info", page: InfoScreen),
|
||||
]),
|
||||
CustomRoute(
|
||||
path: "/student-id",
|
||||
page: StudentIdScreen,
|
||||
transitionsBuilder: TransitionsBuilders.slideTop,
|
||||
durationInMilliseconds: 200,
|
||||
),
|
||||
],
|
||||
)
|
||||
class $AppRouter {}
|
|
@ -16,10 +16,10 @@ import 'package:flutter/material.dart' as _i8;
|
|||
|
||||
import '../layouts/main/index.dart' as _i1;
|
||||
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/map/index.dart' as _i3;
|
||||
import '../screens/student_id/index.dart' as _i4;
|
||||
import '../screens/map/index.dart' as _i4;
|
||||
import '../screens/student_id/index.dart' as _i2;
|
||||
|
||||
class AppRouter extends _i7.RootStackRouter {
|
||||
AppRouter([_i8.GlobalKey<_i8.NavigatorState>? navigatorKey])
|
||||
|
@ -31,17 +31,22 @@ class AppRouter extends _i7.RootStackRouter {
|
|||
return _i7.MaterialPageX<dynamic>(
|
||||
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) {
|
||||
return _i7.MaterialPageX<dynamic>(
|
||||
routeData: routeData, child: const _i2.HomeScreen());
|
||||
routeData: routeData, child: const _i3.HomeScreen());
|
||||
},
|
||||
MapRoute.name: (routeData) {
|
||||
return _i7.MaterialPageX<dynamic>(
|
||||
routeData: routeData, child: const _i3.MapScreen());
|
||||
},
|
||||
StudentIdRoute.name: (routeData) {
|
||||
return _i7.MaterialPageX<dynamic>(
|
||||
routeData: routeData, child: const _i4.StudentIdScreen());
|
||||
routeData: routeData, child: const _i4.MapScreen());
|
||||
},
|
||||
EventsRoute.name: (routeData) {
|
||||
return _i7.MaterialPageX<dynamic>(
|
||||
|
@ -59,12 +64,11 @@ class AppRouter extends _i7.RootStackRouter {
|
|||
_i7.RouteConfig(HomeRoute.name,
|
||||
path: 'home', 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,
|
||||
path: 'events', 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
|
||||
/// [_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> {
|
||||
const HomeRoute() : super(HomeRoute.name, path: 'home');
|
||||
|
||||
|
@ -86,21 +98,13 @@ class HomeRoute extends _i7.PageRouteInfo<void> {
|
|||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i3.MapScreen]
|
||||
/// [_i4.MapScreen]
|
||||
class MapRoute extends _i7.PageRouteInfo<void> {
|
||||
const MapRoute() : super(MapRoute.name, path: 'map');
|
||||
|
||||
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
|
||||
/// [_i5.EventsScreen]
|
||||
class EventsRoute extends _i7.PageRouteInfo<void> {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:furman_now/src/routes/index.gr.dart';
|
||||
import 'package:furman_now/src/utils/greeting.dart';
|
||||
|
@ -54,34 +55,48 @@ class HomeScreen extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
),
|
||||
ScrollViewWithHeight(
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(30)),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(vertical: 20),
|
||||
margin: const EdgeInsets.only(top: 200),
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
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(),
|
||||
),
|
||||
],
|
||||
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(
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(30)),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(vertical: 20),
|
||||
margin: const EdgeInsets.only(top: 200),
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
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(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/material.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/utils/theme.dart';
|
||||
|
||||
|
@ -26,6 +28,12 @@ class _StudentIdScreenState extends State<StudentIdScreen> {
|
|||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
timer?.cancel();
|
||||
}
|
||||
|
||||
void updateBarcode(Timer timer) {
|
||||
setState(() {
|
||||
barcodeNumber = BarcodeService.generateGetBarcode();
|
||||
|
@ -35,35 +43,45 @@ class _StudentIdScreenState extends State<StudentIdScreen> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
color: const Color(0xffb7acc9),
|
||||
child: SafeArea(
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.all(40),
|
||||
children: [
|
||||
Text(
|
||||
"Furman ID",
|
||||
style: furmanTextStyle(const TextStyle(color: Color(0xff26183d), fontSize: 36, fontWeight: FontWeight.w800)),
|
||||
),
|
||||
const SizedBox(height: 200),
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||
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),
|
||||
child: SafeArea(
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.all(40),
|
||||
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
|
||||
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,
|
||||
);
|
||||
},
|
||||
const SizedBox(height: 200),
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||
),
|
||||
// hack since the barcode has a weird intrinsic size for some reason
|
||||
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,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -12,8 +12,14 @@ class ScrollViewWithHeight extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
|
||||
return SingleChildScrollView(
|
||||
physics: const BouncingScrollPhysics(
|
||||
parent: AlwaysScrollableScrollPhysics()
|
||||
),
|
||||
child: ConstrainedBox(
|
||||
constraints: constraints.copyWith(minHeight: constraints.maxHeight, maxHeight: double.infinity),
|
||||
constraints: constraints.copyWith(
|
||||
minHeight: constraints.maxHeight,
|
||||
maxHeight: double.infinity
|
||||
),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue