Pull-down student id gesture, salmon bar navigation, global state

This commit is contained in:
2022-09-07 13:34:03 -04:00
parent 95400d7ee2
commit 9b78ae40d0
13 changed files with 516 additions and 244 deletions

View File

@@ -9,9 +9,16 @@ import 'package:furman_now/src/widgets/home/restaurants/restaurants_list.dart';
import 'package:furman_now/src/widgets/home/transportation/transportation_card.dart';
import 'package:furman_now/src/widgets/scroll_view_height.dart';
class HomeScreen extends StatelessWidget {
class HomeScreen extends StatefulWidget {
const HomeScreen({Key? key}) : super(key: key);
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
CrossFadeState _showScrollMessage = CrossFadeState.showFirst;
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -25,7 +32,7 @@ class HomeScreen extends StatelessWidget {
children: [
Container(
width: double.infinity,
height: double.infinity,
height: 300,
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
@@ -33,7 +40,7 @@ class HomeScreen extends StatelessWidget {
colors: <Color>[
Color(0xffb7acc9),
Color(0xffb7acc9),
], // Gradient from https://learnui.design/tools/gradient-generator.html
],
tileMode: TileMode.mirror,
),
),
@@ -47,9 +54,39 @@ class HomeScreen extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("${greeting()},\nMichael", style: furmanTextStyle(const TextStyle(color: Color(0xff26183d), fontSize: 36, fontWeight: FontWeight.w800))),
Hero(
tag: "title",
child: Material(
type: MaterialType.transparency,
child: Text(
"${greeting()},\nMichael",
style: furmanTextStyle(const TextStyle(
color: Color(0xff26183d),
fontSize: 36,
fontWeight: FontWeight.w800,
)),
),
),
),
const SizedBox(height: 5),
Text("It's 76º and partly cloudy", style: furmanTextStyle(const TextStyle(color: Color(0xff26183d), fontSize: 16, fontWeight: FontWeight.w500))),
AnimatedCrossFade(
crossFadeState: _showScrollMessage,
duration: const Duration(milliseconds: 100),
firstChild: Text("It's 76º and partly cloudy",
style: furmanTextStyle(const TextStyle(
color: Color(0xff26183d),
fontSize: 16,
fontWeight: FontWeight.w500)
),
),
secondChild: Text("Pull down to view your Meal ID",
style: furmanTextStyle(const TextStyle(
color: Color(0xff26183d),
fontSize: 16,
fontWeight: FontWeight.w500)
),
),
),
],
),
),
@@ -63,39 +100,63 @@ class HomeScreen extends StatelessWidget {
var offsetAmount = offset.abs();
if (offsetAmount > 50) {
context.router.navigate(const StudentIdRoute());
} else if (offsetAmount > 20) {
setState(() {
_showScrollMessage = CrossFadeState.showSecond;
});
} else {
setState(() {
_showScrollMessage = CrossFadeState.showFirst;
});
}
} else {
if (_showScrollMessage != CrossFadeState.showFirst) {
setState(() {
_showScrollMessage = CrossFadeState.showFirst;
});
}
}
}
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()),
child: Hero(
tag: "card",
child: Material(
type: MaterialType.transparency,
child: Container(
decoration: const BoxDecoration(
color: Colors.white,
borderRadius:
BorderRadius.vertical(top: Radius.circular(30)),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: EventsList(),
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(),
),
],
),
const HeaderWidget(title: "Food & Dining"),
const RestaurantsList(),
const HeaderWidget(title: "Transportation"),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 20),
child: TransportationCard(),
),
],
),
),
),
),

View File

@@ -3,6 +3,7 @@ import 'dart:async';
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:barcode_widget/barcode_widget.dart';
import 'package:flutter_remix/flutter_remix.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';
@@ -49,40 +50,119 @@ class _StudentIdScreenState extends State<StudentIdScreen> {
if (details.delta.dy > sensitivity) {
// Down Swipe
} else if (details.delta.dy < -sensitivity) {
context.router.navigate(const MainLayout());
context.router.navigate(const HomeRoute());
}
},
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)),
child: Stack(
children: [
Container(
color: const Color(0xffb7acc9),
child: SafeArea(
child: ListView(
padding: const EdgeInsets.all(40),
children: [
Hero(
tag: "title",
child: Material(
type: MaterialType.transparency,
child: Text(
"Furman ID",
style: furmanTextStyle(const TextStyle(
color: Color(0xff26183d),
fontSize: 36,
fontWeight: FontWeight.w800
)),
),
),
),
const SizedBox(height: 30),
Center(
child: Container(
height: 200,
width: 200,
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: BorderRadius.circular(40),
),
child: Icon(
FlutterRemix.user_3_line,
size: 120,
color: Colors.grey[400],
),
),
),
const SizedBox(height: 20),
Center(child: Text(
"Michael Thomas",
style: furmanTextStyle(const TextStyle(
color: Color(0xff26183d),
fontSize: 28,
fontWeight: FontWeight.w700
)),
)),
const SizedBox(height: 5),
Center(child: Text(
"5001962",
style: furmanTextStyle(const TextStyle(
color: Color(0xff26183d),
fontSize: 20,
fontWeight: FontWeight.w500
)),
)),
const SizedBox(height: 20),
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,
);
},
),
),
],
),
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,
);
},
),
),
],
),
),
),
Align(
alignment: Alignment.bottomCenter,
child: Hero(
tag: "card",
child: Material(
type: MaterialType.transparency,
child: Container(
height: 75,
width: double.infinity,
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.vertical(
top: Radius.circular(30),
),
),
child: Align(
alignment: Alignment.topCenter,
child: Container(
margin: const EdgeInsets.only(top: 10),
width: 40,
height: 5,
decoration: BoxDecoration(
color: Colors.grey[400],
borderRadius: BorderRadius.circular(20),
)
),
),
),
),
),
),
],
),
),
);