Update pull down gesture to be much smoother, refactor home page routing, load weather from OpenWeatherMap
This commit is contained in:
parent
9b78ae40d0
commit
1e5382e8f1
|
@ -45,5 +45,7 @@
|
||||||
<false/>
|
<false/>
|
||||||
<key>CADisableMinimumFrameDurationOnPhone</key>
|
<key>CADisableMinimumFrameDurationOnPhone</key>
|
||||||
<true/>
|
<true/>
|
||||||
|
<key>NSLocationWhenInUseUsageDescription</key>
|
||||||
|
<string>Your location will be used to provide weather and map data.</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import 'package:auto_route/auto_route.dart';
|
import 'package:auto_route/auto_route.dart';
|
||||||
import 'package:furman_now/src/screens/events/index.dart';
|
import 'package:furman_now/src/screens/events/index.dart';
|
||||||
|
import 'package:furman_now/src/screens/home/home_header.dart';
|
||||||
import 'package:furman_now/src/screens/home/index.dart';
|
import 'package:furman_now/src/screens/home/index.dart';
|
||||||
import 'package:furman_now/src/screens/info/index.dart';
|
import 'package:furman_now/src/screens/info/index.dart';
|
||||||
import 'package:furman_now/src/screens/map/index.dart';
|
import 'package:furman_now/src/screens/map/index.dart';
|
||||||
import 'package:furman_now/src/screens/student_id/index.dart';
|
import 'package:furman_now/src/screens/student_id/index.dart';
|
||||||
import 'package:furman_now/src/utils/hero_empty_router_page.dart';
|
|
||||||
|
|
||||||
import '../layouts/main/index.dart';
|
import '../layouts/main/index.dart';
|
||||||
|
|
||||||
|
@ -12,16 +12,17 @@ import '../layouts/main/index.dart';
|
||||||
replaceInRouteName: 'Screen,Route',
|
replaceInRouteName: 'Screen,Route',
|
||||||
routes: <AutoRoute>[
|
routes: <AutoRoute>[
|
||||||
AutoRoute(path: "/", page: MainLayout, children: [
|
AutoRoute(path: "/", page: MainLayout, children: [
|
||||||
AutoRoute(path: "home", name: "HomePageRouter", page: HeroEmptyRouterPage, children: [
|
AutoRoute(path: "home", name: "HomePageRouter", page: HomeScreen, children: [
|
||||||
CustomRoute(
|
CustomRoute(
|
||||||
path: "",
|
path: "",
|
||||||
page: HomeScreen,
|
page: HomePageHeader,
|
||||||
transitionsBuilder: TransitionsBuilders.noTransition,
|
name: "HomeRoute",
|
||||||
|
transitionsBuilder: TransitionsBuilders.fadeIn,
|
||||||
),
|
),
|
||||||
CustomRoute(
|
CustomRoute(
|
||||||
path: "student-id",
|
path: "student-id",
|
||||||
page: StudentIdScreen,
|
page: StudentIdScreen,
|
||||||
transitionsBuilder: TransitionsBuilders.noTransition,
|
transitionsBuilder: TransitionsBuilders.fadeIn,
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
AutoRoute(path: "map", page: MapScreen),
|
AutoRoute(path: "map", page: MapScreen),
|
||||||
|
|
|
@ -16,11 +16,11 @@ import 'package:flutter/material.dart' as _i9;
|
||||||
|
|
||||||
import '../layouts/main/index.dart' as _i1;
|
import '../layouts/main/index.dart' as _i1;
|
||||||
import '../screens/events/index.dart' as _i4;
|
import '../screens/events/index.dart' as _i4;
|
||||||
import '../screens/home/index.dart' as _i6;
|
import '../screens/home/home_header.dart' as _i6;
|
||||||
|
import '../screens/home/index.dart' as _i2;
|
||||||
import '../screens/info/index.dart' as _i5;
|
import '../screens/info/index.dart' as _i5;
|
||||||
import '../screens/map/index.dart' as _i3;
|
import '../screens/map/index.dart' as _i3;
|
||||||
import '../screens/student_id/index.dart' as _i7;
|
import '../screens/student_id/index.dart' as _i7;
|
||||||
import '../utils/hero_empty_router_page.dart' as _i2;
|
|
||||||
|
|
||||||
class AppRouter extends _i8.RootStackRouter {
|
class AppRouter extends _i8.RootStackRouter {
|
||||||
AppRouter([_i9.GlobalKey<_i9.NavigatorState>? navigatorKey])
|
AppRouter([_i9.GlobalKey<_i9.NavigatorState>? navigatorKey])
|
||||||
|
@ -34,7 +34,7 @@ class AppRouter extends _i8.RootStackRouter {
|
||||||
},
|
},
|
||||||
HomePageRouter.name: (routeData) {
|
HomePageRouter.name: (routeData) {
|
||||||
return _i8.MaterialPageX<dynamic>(
|
return _i8.MaterialPageX<dynamic>(
|
||||||
routeData: routeData, child: const _i2.HeroEmptyRouterPage());
|
routeData: routeData, child: const _i2.HomeScreen());
|
||||||
},
|
},
|
||||||
MapRoute.name: (routeData) {
|
MapRoute.name: (routeData) {
|
||||||
return _i8.MaterialPageX<dynamic>(
|
return _i8.MaterialPageX<dynamic>(
|
||||||
|
@ -51,8 +51,8 @@ class AppRouter extends _i8.RootStackRouter {
|
||||||
HomeRoute.name: (routeData) {
|
HomeRoute.name: (routeData) {
|
||||||
return _i8.CustomPage<dynamic>(
|
return _i8.CustomPage<dynamic>(
|
||||||
routeData: routeData,
|
routeData: routeData,
|
||||||
child: const _i6.HomeScreen(),
|
child: const _i6.HomePageHeader(),
|
||||||
transitionsBuilder: _i8.TransitionsBuilders.noTransition,
|
transitionsBuilder: _i8.TransitionsBuilders.fadeIn,
|
||||||
opaque: true,
|
opaque: true,
|
||||||
barrierDismissible: false);
|
barrierDismissible: false);
|
||||||
},
|
},
|
||||||
|
@ -60,7 +60,7 @@ class AppRouter extends _i8.RootStackRouter {
|
||||||
return _i8.CustomPage<dynamic>(
|
return _i8.CustomPage<dynamic>(
|
||||||
routeData: routeData,
|
routeData: routeData,
|
||||||
child: const _i7.StudentIdScreen(),
|
child: const _i7.StudentIdScreen(),
|
||||||
transitionsBuilder: _i8.TransitionsBuilders.noTransition,
|
transitionsBuilder: _i8.TransitionsBuilders.fadeIn,
|
||||||
opaque: true,
|
opaque: true,
|
||||||
barrierDismissible: false);
|
barrierDismissible: false);
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ class MainLayout extends _i8.PageRouteInfo<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// generated route for
|
/// generated route for
|
||||||
/// [_i2.HeroEmptyRouterPage]
|
/// [_i2.HomeScreen]
|
||||||
class HomePageRouter extends _i8.PageRouteInfo<void> {
|
class HomePageRouter extends _i8.PageRouteInfo<void> {
|
||||||
const HomePageRouter({List<_i8.PageRouteInfo>? children})
|
const HomePageRouter({List<_i8.PageRouteInfo>? children})
|
||||||
: super(HomePageRouter.name, path: 'home', initialChildren: children);
|
: super(HomePageRouter.name, path: 'home', initialChildren: children);
|
||||||
|
@ -129,7 +129,7 @@ class InfoRoute extends _i8.PageRouteInfo<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// generated route for
|
/// generated route for
|
||||||
/// [_i6.HomeScreen]
|
/// [_i6.HomePageHeader]
|
||||||
class HomeRoute extends _i8.PageRouteInfo<void> {
|
class HomeRoute extends _i8.PageRouteInfo<void> {
|
||||||
const HomeRoute() : super(HomeRoute.name, path: '');
|
const HomeRoute() : super(HomeRoute.name, path: '');
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,107 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:furman_now/src/routes/index.gr.dart';
|
||||||
|
import 'package:furman_now/src/utils/conditional_parent_widget.dart';
|
||||||
|
import 'package:furman_now/src/widgets/events/events_list.dart';
|
||||||
|
import 'package:furman_now/src/widgets/header.dart';
|
||||||
|
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 HomeContent extends StatefulWidget {
|
||||||
|
final bool collapse;
|
||||||
|
|
||||||
|
const HomeContent({
|
||||||
|
required this.collapse,
|
||||||
|
Key? key,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<HomeContent> createState() => _HomeContentState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _HomeContentState extends State<HomeContent> {
|
||||||
|
final ScrollController _controller = ScrollController();
|
||||||
|
bool _collapse = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
if (widget.collapse != _collapse) {
|
||||||
|
_controller.animateTo(
|
||||||
|
0,
|
||||||
|
duration: const Duration(milliseconds: 400),
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
);
|
||||||
|
_collapse = widget.collapse;
|
||||||
|
}
|
||||||
|
|
||||||
|
return LayoutBuilder(
|
||||||
|
builder: (context, constraints) => ScrollViewWithHeight(
|
||||||
|
controller: _controller,
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.bottomCenter,
|
||||||
|
child: TweenAnimationBuilder<double>(
|
||||||
|
tween: widget.collapse
|
||||||
|
? Tween<double>(begin: 200, end: constraints.maxHeight - 75)
|
||||||
|
: Tween<double>(begin: constraints.maxHeight - 75, end: 200),
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
duration: const Duration(milliseconds: 200),
|
||||||
|
builder: (context, margin, _) => Stack(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius:
|
||||||
|
BorderRadius.vertical(top: Radius.circular(30)),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.only(bottom: 15),
|
||||||
|
margin: EdgeInsets.only(top: margin),
|
||||||
|
width: double.infinity,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
AnimatedContainer(
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
height: widget.collapse ? 55 : 0,
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.topCenter,
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.symmetric(vertical: 15),
|
||||||
|
width: 60,
|
||||||
|
height: 5,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.grey[300],
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
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(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,92 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:furman_now/src/screens/home/state.dart';
|
||||||
|
import 'package:furman_now/src/services/weather/weather_service.dart';
|
||||||
|
import 'package:furman_now/src/utils/greeting.dart';
|
||||||
|
import 'package:furman_now/src/utils/theme.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class HomePageHeader extends StatelessWidget {
|
||||||
|
const HomePageHeader({ Key? key }) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 300,
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
colors: <Color>[
|
||||||
|
Color(0xffb7acc9),
|
||||||
|
Color(0xffb7acc9),
|
||||||
|
],
|
||||||
|
tileMode: TileMode.mirror,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.topLeft,
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(40),
|
||||||
|
width: double.infinity,
|
||||||
|
height: 200,
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
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: 8),
|
||||||
|
Consumer<HomePageState>(
|
||||||
|
builder: (context, state, _) => AnimatedCrossFade(
|
||||||
|
crossFadeState:
|
||||||
|
state.showScrollMessage
|
||||||
|
? CrossFadeState.showSecond
|
||||||
|
: CrossFadeState.showFirst,
|
||||||
|
duration: const Duration(milliseconds: 100),
|
||||||
|
firstChild: FutureBuilder<String>(
|
||||||
|
future: WeatherService.getWeatherMessage(),
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
if(snapshot.hasData) {
|
||||||
|
return Text(
|
||||||
|
snapshot.data!,
|
||||||
|
// "It's 76º and partly cloudy",
|
||||||
|
style: furmanTextStyle(const TextStyle
|
||||||
|
(
|
||||||
|
color: Color(0xff26183d),
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return const SizedBox(height: 0);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
secondChild: Text("Pull down to view your Meal ID",
|
||||||
|
style: furmanTextStyle(const TextStyle(
|
||||||
|
color: Color(0xff26183d),
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w500
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +1,9 @@
|
||||||
import 'package:auto_route/auto_route.dart';
|
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/screens/home/content.dart';
|
||||||
import 'package:furman_now/src/utils/theme.dart';
|
import 'package:furman_now/src/screens/home/state.dart';
|
||||||
import 'package:furman_now/src/widgets/header.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:furman_now/src/widgets/events/events_list.dart';
|
|
||||||
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 StatefulWidget {
|
class HomeScreen extends StatefulWidget {
|
||||||
const HomeScreen({Key? key}) : super(key: key);
|
const HomeScreen({Key? key}) : super(key: key);
|
||||||
|
@ -17,151 +13,71 @@ class HomeScreen extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _HomeScreenState extends State<HomeScreen> {
|
class _HomeScreenState extends State<HomeScreen> {
|
||||||
CrossFadeState _showScrollMessage = CrossFadeState.showFirst;
|
bool _collapse = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return ChangeNotifierProvider(
|
||||||
body: Container(
|
create: (context) => HomePageState(),
|
||||||
color: const Color(0xffb7acc9),
|
builder: (context, _) => Scaffold(
|
||||||
child: SafeArea(
|
body: Container(
|
||||||
child: Container(
|
color: const Color(0xffb7acc9),
|
||||||
color: Colors.grey[100],
|
child: SafeArea(
|
||||||
child: Stack(
|
child: Container(
|
||||||
fit: StackFit.loose,
|
color: const Color(0xffb7acc9),
|
||||||
children: [
|
child: Stack(
|
||||||
Container(
|
fit: StackFit.loose,
|
||||||
width: double.infinity,
|
children: [
|
||||||
height: 300,
|
const AutoTabsRouter(
|
||||||
decoration: const BoxDecoration(
|
routes: [
|
||||||
gradient: LinearGradient(
|
HomeRoute(),
|
||||||
begin: Alignment.topCenter,
|
StudentIdRoute(),
|
||||||
end: Alignment.bottomCenter,
|
],
|
||||||
colors: <Color>[
|
|
||||||
Color(0xffb7acc9),
|
|
||||||
Color(0xffb7acc9),
|
|
||||||
],
|
|
||||||
tileMode: TileMode.mirror,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
child: Align(
|
NotificationListener<ScrollNotification>(
|
||||||
alignment: Alignment.topLeft,
|
onNotification: (notification) {
|
||||||
child: Container(
|
if (notification is ScrollUpdateNotification) {
|
||||||
padding: const EdgeInsets.all(40),
|
final offset = notification.metrics.pixels;
|
||||||
width: double.infinity,
|
const scrollMessageSensitivity = 20;
|
||||||
height: 200,
|
const pageSwitchSensitivity = 60;
|
||||||
child: Column(
|
if (offset < 0) {
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
var offsetAmount = offset.abs();
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
if (offsetAmount > pageSwitchSensitivity) {
|
||||||
children: [
|
context.router.navigate(const StudentIdRoute());
|
||||||
Hero(
|
setState(() {
|
||||||
tag: "title",
|
_collapse = true;
|
||||||
child: Material(
|
});
|
||||||
type: MaterialType.transparency,
|
} else if (offsetAmount > scrollMessageSensitivity) {
|
||||||
child: Text(
|
if (!context.read<HomePageState>().showScrollMessage) {
|
||||||
"${greeting()},\nMichael",
|
context.read<HomePageState>().showScrollMessage = true;
|
||||||
style: furmanTextStyle(const TextStyle(
|
}
|
||||||
color: Color(0xff26183d),
|
} else {
|
||||||
fontSize: 36,
|
if (context.read<HomePageState>().showScrollMessage) {
|
||||||
fontWeight: FontWeight.w800,
|
context.read<HomePageState>().showScrollMessage = false;
|
||||||
)),
|
}
|
||||||
),
|
}
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 5),
|
|
||||||
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)
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
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());
|
|
||||||
} else if (offsetAmount > 20) {
|
|
||||||
setState(() {
|
|
||||||
_showScrollMessage = CrossFadeState.showSecond;
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
var offsetAmount = offset.abs();
|
||||||
_showScrollMessage = CrossFadeState.showFirst;
|
if (offsetAmount > pageSwitchSensitivity) {
|
||||||
});
|
context.router.navigate(const HomeRoute());
|
||||||
}
|
setState(() {
|
||||||
} else {
|
_collapse = false;
|
||||||
if (_showScrollMessage != CrossFadeState.showFirst) {
|
});
|
||||||
setState(() {
|
} else {
|
||||||
_showScrollMessage = CrossFadeState.showFirst;
|
if (context.read<HomePageState>().showScrollMessage) {
|
||||||
});
|
context.read<HomePageState>().showScrollMessage = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return true;
|
||||||
return true;
|
},
|
||||||
},
|
child: ClipRect(child: HomeContent(
|
||||||
child: ScrollViewWithHeight(
|
collapse: _collapse,
|
||||||
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: 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(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class HomePageState extends ChangeNotifier {
|
||||||
|
bool _showScrollMessage = false;
|
||||||
|
|
||||||
|
bool get showScrollMessage {
|
||||||
|
return _showScrollMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
set showScrollMessage(bool value) {
|
||||||
|
_showScrollMessage = value;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
|
@ -50,7 +50,7 @@ class _StudentIdScreenState extends State<StudentIdScreen> {
|
||||||
if (details.delta.dy > sensitivity) {
|
if (details.delta.dy > sensitivity) {
|
||||||
// Down Swipe
|
// Down Swipe
|
||||||
} else if (details.delta.dy < -sensitivity) {
|
} else if (details.delta.dy < -sensitivity) {
|
||||||
context.router.navigate(const HomeRoute());
|
context.router.navigate(HomeRoute());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Stack(
|
child: Stack(
|
||||||
|
@ -61,19 +61,13 @@ class _StudentIdScreenState extends State<StudentIdScreen> {
|
||||||
child: ListView(
|
child: ListView(
|
||||||
padding: const EdgeInsets.all(40),
|
padding: const EdgeInsets.all(40),
|
||||||
children: [
|
children: [
|
||||||
Hero(
|
Text(
|
||||||
tag: "title",
|
"Furman ID",
|
||||||
child: Material(
|
style: furmanTextStyle(const TextStyle(
|
||||||
type: MaterialType.transparency,
|
color: Color(0xff26183d),
|
||||||
child: Text(
|
fontSize: 36,
|
||||||
"Furman ID",
|
fontWeight: FontWeight.w800
|
||||||
style: furmanTextStyle(const TextStyle(
|
)),
|
||||||
color: Color(0xff26183d),
|
|
||||||
fontSize: 36,
|
|
||||||
fontWeight: FontWeight.w800
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
Center(
|
Center(
|
||||||
|
@ -131,37 +125,6 @@ class _StudentIdScreenState extends State<StudentIdScreen> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
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),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
import 'package:furman_now/secrets.dart';
|
||||||
|
import 'package:geolocator/geolocator.dart';
|
||||||
|
import 'package:weather/weather.dart';
|
||||||
|
|
||||||
|
class WeatherService {
|
||||||
|
static final WeatherFactory _factory = WeatherFactory(Secrets.openWeatherMapKey);
|
||||||
|
|
||||||
|
static Future<String> getWeatherMessage() async {
|
||||||
|
var position = await _determinePosition();
|
||||||
|
var weather = await _factory.currentWeatherByLocation(
|
||||||
|
position.latitude,
|
||||||
|
position.longitude,
|
||||||
|
);
|
||||||
|
return "It's ${weather.temperature?.fahrenheit?.round()}º with ${weather.weatherDescription}";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Determine the current position of the device.
|
||||||
|
///
|
||||||
|
/// When the location services are not enabled or permissions
|
||||||
|
/// are denied the `Future` will return an error.
|
||||||
|
static Future<Position> _determinePosition() async {
|
||||||
|
bool serviceEnabled;
|
||||||
|
LocationPermission permission;
|
||||||
|
|
||||||
|
// Test if location services are enabled.
|
||||||
|
serviceEnabled = await Geolocator.isLocationServiceEnabled();
|
||||||
|
if (!serviceEnabled) {
|
||||||
|
// Location services are not enabled don't continue
|
||||||
|
// accessing the position and request users of the
|
||||||
|
// App to enable the location services.
|
||||||
|
return Future.error('Location services are disabled.');
|
||||||
|
}
|
||||||
|
|
||||||
|
permission = await Geolocator.checkPermission();
|
||||||
|
if (permission == LocationPermission.denied) {
|
||||||
|
permission = await Geolocator.requestPermission();
|
||||||
|
if (permission == LocationPermission.denied) {
|
||||||
|
// Permissions are denied, next time you could try
|
||||||
|
// requesting permissions again (this is also where
|
||||||
|
// Android's shouldShowRequestPermissionRationale
|
||||||
|
// returned true. According to Android guidelines
|
||||||
|
// your App should show an explanatory UI now.
|
||||||
|
return Future.error('Location permissions are denied');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (permission == LocationPermission.deniedForever) {
|
||||||
|
// Permissions are denied forever, handle appropriately.
|
||||||
|
return Future.error(
|
||||||
|
'Location permissions are permanently denied, we cannot request permissions.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// When we reach here, permissions are granted and we can
|
||||||
|
// continue accessing the position of the device.
|
||||||
|
return await Geolocator.getCurrentPosition();
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,9 +2,11 @@ import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class ScrollViewWithHeight extends StatelessWidget {
|
class ScrollViewWithHeight extends StatelessWidget {
|
||||||
final Widget child;
|
final Widget child;
|
||||||
|
final ScrollController? controller;
|
||||||
|
|
||||||
const ScrollViewWithHeight({
|
const ScrollViewWithHeight({
|
||||||
required this.child,
|
required this.child,
|
||||||
|
this.controller,
|
||||||
Key? key,
|
Key? key,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@ -12,6 +14,7 @@ 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(
|
||||||
|
controller: controller,
|
||||||
physics: const BouncingScrollPhysics(
|
physics: const BouncingScrollPhysics(
|
||||||
parent: AlwaysScrollableScrollPhysics()
|
parent: AlwaysScrollableScrollPhysics()
|
||||||
),
|
),
|
||||||
|
|
44
pubspec.lock
44
pubspec.lock
|
@ -7,14 +7,21 @@ packages:
|
||||||
name: _fe_analyzer_shared
|
name: _fe_analyzer_shared
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "46.0.0"
|
version: "47.0.0"
|
||||||
analyzer:
|
analyzer:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: analyzer
|
name: analyzer
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.6.0"
|
version: "4.7.0"
|
||||||
|
animated_stack_widget:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: animated_stack_widget
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.0.4"
|
||||||
args:
|
args:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -265,6 +272,20 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.1.4"
|
version: "4.1.4"
|
||||||
|
flutter_map_marker_cluster:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_map_marker_cluster
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.5.4"
|
||||||
|
flutter_map_marker_popup:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_map_marker_popup
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "3.2.0"
|
||||||
flutter_remix:
|
flutter_remix:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -297,7 +318,7 @@ packages:
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.3"
|
version: "2.1.3"
|
||||||
geolocator:
|
geolocator:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: geolocator
|
name: geolocator
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
|
@ -533,7 +554,7 @@ packages:
|
||||||
name: path_provider_android
|
name: path_provider_android
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.19"
|
version: "2.0.20"
|
||||||
path_provider_ios:
|
path_provider_ios:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -568,7 +589,7 @@ packages:
|
||||||
name: path_provider_windows
|
name: path_provider_windows
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.2"
|
version: "2.1.3"
|
||||||
petitparser:
|
petitparser:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -833,6 +854,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.1"
|
version: "1.0.1"
|
||||||
|
weather:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: weather
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.1"
|
||||||
web_socket_channel:
|
web_socket_channel:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -846,14 +874,14 @@ packages:
|
||||||
name: webkit_inspection_protocol
|
name: webkit_inspection_protocol
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.2.0"
|
||||||
win32:
|
win32:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: win32
|
name: win32
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.7.0"
|
version: "3.0.0"
|
||||||
wkt_parser:
|
wkt_parser:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -867,7 +895,7 @@ packages:
|
||||||
name: xdg_directories
|
name: xdg_directories
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.0+1"
|
version: "0.2.0+2"
|
||||||
xml:
|
xml:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -50,6 +50,9 @@ dependencies:
|
||||||
salomon_bottom_bar: ^3.3.1
|
salomon_bottom_bar: ^3.3.1
|
||||||
flutter_remix: ^0.0.3
|
flutter_remix: ^0.0.3
|
||||||
provider: ^6.0.3
|
provider: ^6.0.3
|
||||||
|
weather: ^2.0.1
|
||||||
|
geolocator: ^9.0.1
|
||||||
|
flutter_map_marker_cluster: ^0.5.4
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
Loading…
Reference in New Issue