Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analyiss #206

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# F-App 2: Electric Boogaloo

App for interacting with the fsektionen.se-api

## Setup

1. Clone the repo
2. `flutter pub get`
3. `flutter build apk` (if this doesn't work skip/try without this step, it is probably and often not needed)
4. run 'flutter pub run build_runner build'
3. run `flutter pub run build_runner build`

## Debugging

`flutter build apk` (if this doesn't work skip/try without this step, it is probably and often not needed)
3 changes: 3 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
linter:
rules:
require_trailing_commas: true
130 changes: 80 additions & 50 deletions lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@ class _FsekMobileAppState extends State<FsekMobileApp> {
_authenticationBloc!.stream.listen((AuthenticationState state) async {
if (state is AuthenticationUserFetched) {
setState(() {
_userService!.getUser().then((value) => setState(() {
this._user = value;
_userService!.getUser().then(
(value) => setState(() {
this._user = value;

setupPushNotifications();
}));
setupPushNotifications();
}),
);
});
}
/* If we have saved a language setting we use that*/
Expand Down Expand Up @@ -110,50 +112,61 @@ class _FsekMobileAppState extends State<FsekMobileApp> {
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
return BlocProvider<AuthenticationBloc>(
create: (context) => _authenticationBloc!,
child: MaterialApp(
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
AppLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [
Locale('en', ''),
Locale('sv', ''),
],
locale: _locale,
navigatorKey: locator<NavigationService>().navigatorKey,
theme: locator<ThemeService>().theme,
home: Stack(children: [
create: (context) => _authenticationBloc!,
child: MaterialApp(
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
AppLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [
Locale('en', ''),
Locale('sv', ''),
],
locale: _locale,
navigatorKey: locator<NavigationService>().navigatorKey,
theme: locator<ThemeService>().theme,
home: Stack(
children: [
AppBackground(
backgroundColors: locator<ThemeService>().backgroundColors),
backgroundColors: locator<ThemeService>().backgroundColors,
),
BlocConsumer<AuthenticationBloc, AuthenticationState>(
bloc: _authenticationBloc,
builder: (BuildContext context, AuthenticationState state) {
return AnimatedSwitcher(
duration: Duration(milliseconds: 250),
child: _buildPage(context, state,
locator<NavigationService>().navbarDestinations),
child: _buildPage(
context,
state,
locator<NavigationService>().navbarDestinations,
),
);
},
listener: (context, state) {
if (state is AuthenticationDisconnected) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ErrorPage(
authenticationBloc: _authenticationBloc,
text:
"We could not connect to Fsektionen.se. Please check your connection or try again later.")));
context,
MaterialPageRoute(
builder: (context) => ErrorPage(
authenticationBloc: _authenticationBloc,
text:
"We could not connect to Fsektionen.se. Please check your connection or try again later.",
),
),
);
}
if (state is AuthenticationError) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ErrorPage(
authenticationBloc: _authenticationBloc,
text: state.error)));
context,
MaterialPageRoute(
builder: (context) => ErrorPage(
authenticationBloc: _authenticationBloc,
text: state.error,
),
),
);
}

// Background-animation stuff
Expand All @@ -168,32 +181,49 @@ class _FsekMobileAppState extends State<FsekMobileApp> {
});
}
},
)
]),
debugShowCheckedModeBanner: false,
initialRoute: '/',
routes: {
// put named routes in main.dart please (add hot restart app if running)
}..addAll(locator<NavigationService>().routes),
));
),
],
),
debugShowCheckedModeBanner: false,
initialRoute: '/',
routes: {
// put named routes in main.dart please (add hot restart app if running)
}..addAll(locator<NavigationService>().routes),
),
);
}

Widget? _buildPage(BuildContext context, AuthenticationState state,
List<Destination> navbarDestinations) {
Widget? _buildPage(
BuildContext context,
AuthenticationState state,
List<Destination> navbarDestinations,
) {
if (state is AuthenticationUninitialized) {
return LoadingWidget();
}
if (state is AuthenticationAuthenticated) {
return ContentWrapper(navbarDestinations, null,
locator<NavigationService>().onNavigation, []);
return ContentWrapper(
navbarDestinations,
null,
locator<NavigationService>().onNavigation,
[],
);
}
if (state is AuthenticationTokenRefreshed) {
return ContentWrapper(navbarDestinations, _user,
locator<NavigationService>().onNavigation, []);
return ContentWrapper(
navbarDestinations,
_user,
locator<NavigationService>().onNavigation,
[],
);
}
if (state is AuthenticationUserFetched) {
return ContentWrapper(navbarDestinations, _user,
locator<NavigationService>().onNavigation, state.messages);
return ContentWrapper(
navbarDestinations,
_user,
locator<NavigationService>().onNavigation,
state.messages,
);
}
if (state is AuthenticationUnauthenticated) {
return LoginPage(userService: _userService);
Expand Down
44 changes: 24 additions & 20 deletions lib/app_background.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,27 @@ class _AppBackgroundState extends State<AppBackground> {

@override
Widget build(BuildContext context) {
return Stack(children: [
Container(
height: MediaQuery.of(context).size.height,
color: const Color(0xFFF1F1F1),
),
ClipPath(
clipper: TopWaveClipper(),
child: Container(
decoration: BoxDecoration(
color: Colors.orange[700],
)
// gradient: LinearGradient(
// colors: widget.backgroundColors, begin: Alignment.centerLeft, end: Alignment.centerRight),
// ),
,
height: MediaQuery.of(context).size.height / 2,
return Stack(
children: [
Container(
height: MediaQuery.of(context).size.height,
color: const Color(0xFFF1F1F1),
),
),
]);
ClipPath(
clipper: TopWaveClipper(),
child: Container(
decoration: BoxDecoration(
color: Colors.orange[700],
)
// gradient: LinearGradient(
// colors: widget.backgroundColors, begin: Alignment.centerLeft, end: Alignment.centerRight),
// ),
,
height: MediaQuery.of(context).size.height / 2,
),
),
],
);
}
}

Expand All @@ -53,10 +55,12 @@ class TopWaveClipper extends CustomClipper<Path> {
var path = Path();
path.moveTo(size.width, size.height * tweens[0]);

var firstControlPoint = new Offset(size.width * tweens[1], size.height * tweens[2]);
var firstControlPoint =
new Offset(size.width * tweens[1], size.height * tweens[2]);
var firstEndPoint = new Offset(tweens[3], size.height * tweens[4]);

path.quadraticBezierTo(firstControlPoint.dx, firstControlPoint.dy, firstEndPoint.dx, firstEndPoint.dy);
path.quadraticBezierTo(firstControlPoint.dx, firstControlPoint.dy,
firstEndPoint.dx, firstEndPoint.dy,);

///move from bottom right to top
path.lineTo(0, 0.0);
Expand Down
Loading