Skip to content

Commit

Permalink
Overlay in schedule settings (#168)
Browse files Browse the repository at this point in the history
* Fix bug

* Update tag

* Extract color brightness

* [CI UPDATE GOLDENS]

* Update golden files

* Fix quicklinks goldens

* Remove blank

Co-authored-by: camillebrulotte <[email protected]>
Co-authored-by: Samuel Montambault <[email protected]>
  • Loading branch information
3 people authored Jul 25, 2021
1 parent 08fd695 commit 4770eea
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 49 deletions.
8 changes: 8 additions & 0 deletions lib/core/utils/utils.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// FLUTTER / DART / THIRD-PARTIES
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
Expand Down Expand Up @@ -31,4 +32,11 @@ class Utils {
Fluttertoast.showToast(msg: intl.no_connectivity);
}
}

static Color getColorByBrightness(
BuildContext context, Color lightColor, Color darkColor) {
return Theme.of(context).brightness == Brightness.light
? lightColor
: darkColor;
}
}
4 changes: 4 additions & 0 deletions lib/ui/utils/app_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class AppTheme {
static const Color etsDarkGrey = Color(0xff636467);
static const Color etsBlack = Color(0xff2e2a25);

// Backgrounds
static const Color darkThemeBackground = Color(0xff303030);
static const Color lightThemeBackground = Color(0xfffafafa);

// App|ETS colors
static const Color appletsPurple = Color(0xff19375f);
static const Color appletsDarkPurple = Color(0xff122743);
Expand Down
18 changes: 9 additions & 9 deletions lib/ui/views/choose_language_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import 'package:flutter/material.dart';
import 'package:stacked/stacked.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

// UTILS
import 'package:notredame/core/utils/utils.dart';

// VIEWMODELS
import 'package:notredame/core/viewmodels/choose_language_viewmodel.dart';

Expand All @@ -23,9 +26,8 @@ class _ChooseLanguageViewState extends State<ChooseLanguageView> {
itemCount: model.languages.length,
itemBuilder: (BuildContext context, int index) {
return Card(
color: Theme.of(context).brightness == Brightness.light
? Colors.white
: Colors.grey[900],
color: Utils.getColorByBrightness(
context, Colors.white, Colors.grey[900]),
child: Column(mainAxisSize: MainAxisSize.min, children: <Widget>[
ListTile(
title: Text(model.languages[index]),
Expand All @@ -46,19 +48,17 @@ class _ChooseLanguageViewState extends State<ChooseLanguageView> {
viewModelBuilder: () =>
ChooseLanguageViewModel(intl: AppIntl.of(context)),
builder: (context, model, child) => Scaffold(
backgroundColor: Theme.of(context).brightness == Brightness.light
? AppTheme.etsLightRed
: AppTheme.primaryDark,
backgroundColor: Utils.getColorByBrightness(
context, AppTheme.etsLightRed, AppTheme.primaryDark),
body: Center(
child: ListView(
shrinkWrap: true,
children: <Widget>[
Icon(
Icons.language,
size: 80,
color: Theme.of(context).brightness == Brightness.light
? Colors.white
: AppTheme.etsLightRed,
color: Utils.getColorByBrightness(
context, Colors.white, AppTheme.etsLightRed),
),
Padding(
padding: const EdgeInsets.only(left: 20, top: 60),
Expand Down
23 changes: 11 additions & 12 deletions lib/ui/views/login_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import 'package:flutter_svg/flutter_svg.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:stacked/stacked.dart';

// UTILS
import 'package:notredame/core/utils/utils.dart';

// VIEW MODEL
import 'package:notredame/core/viewmodels/login_viewmodel.dart';

Expand Down Expand Up @@ -32,9 +35,8 @@ class _LoginViewState extends State<LoginView> {
ViewModelBuilder<LoginViewModel>.reactive(
viewModelBuilder: () => LoginViewModel(intl: AppIntl.of(context)),
builder: (context, model, child) => Scaffold(
backgroundColor: Theme.of(context).brightness == Brightness.light
? AppTheme.etsLightRed
: AppTheme.primaryDark,
backgroundColor: Utils.getColorByBrightness(
context, AppTheme.etsLightRed, AppTheme.primaryDark),
resizeToAvoidBottomInset: false,
body: Builder(
builder: (BuildContext context) => SafeArea(
Expand Down Expand Up @@ -183,15 +185,12 @@ class _LoginViewState extends State<LoginView> {
super.dispose();
}

Color get errorTextColor => Theme.of(context).brightness == Brightness.light
? Colors.amberAccent
: Colors.redAccent;
Color get errorTextColor =>
Utils.getColorByBrightness(context, Colors.amberAccent, Colors.redAccent);

Color get colorButton => Theme.of(context).brightness == Brightness.light
? Colors.white
: AppTheme.etsLightRed;
Color get colorButton =>
Utils.getColorByBrightness(context, Colors.white, AppTheme.etsLightRed);

Color get submitTextColor => Theme.of(context).brightness == Brightness.light
? AppTheme.etsLightRed
: Colors.white;
Color get submitTextColor =>
Utils.getColorByBrightness(context, AppTheme.etsLightRed, Colors.white);
}
9 changes: 5 additions & 4 deletions lib/ui/views/startup_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:stacked/stacked.dart';

// UTILS
import 'package:notredame/core/utils/utils.dart';

// VIEW MODEL
import 'package:notredame/core/viewmodels/startup_viewmodel.dart';

Expand All @@ -16,10 +19,8 @@ class StartUpView extends StatelessWidget {
viewModelBuilder: () => StartUpViewModel(),
onModelReady: (StartUpViewModel model) => model.handleStartUp(),
builder: (context, model, child) => Scaffold(
backgroundColor:
Theme.of(context).brightness == Brightness.light
? AppTheme.etsLightRed
: AppTheme.primaryDark,
backgroundColor: Utils.getColorByBrightness(
context, AppTheme.etsLightRed, AppTheme.primaryDark),
body: SafeArea(
minimum: const EdgeInsets.all(20),
child: Center(
Expand Down
18 changes: 8 additions & 10 deletions lib/ui/widgets/grade_evaluation_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,10 @@ class _GradeEvaluationTileState extends State<GradeEvaluationTile>
widget.evaluation.title,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 16,
color:
Theme.of(context).brightness == Brightness.light
? Colors.black
: Colors.white),
fontSize: 16,
color: Utils.getColorByBrightness(
context, Colors.black, Colors.white),
),
),
),
Padding(
Expand All @@ -117,11 +116,10 @@ class _GradeEvaluationTileState extends State<GradeEvaluationTile>
AppIntl.of(context)
.grades_weight(widget.evaluation.weight),
style: TextStyle(
fontSize: 14,
color:
Theme.of(context).brightness == Brightness.light
? Colors.black
: Colors.white),
fontSize: 14,
color: Utils.getColorByBrightness(
context, Colors.black, Colors.white),
),
),
),
],
Expand Down
52 changes: 39 additions & 13 deletions lib/ui/widgets/schedule_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import 'package:stacked/stacked.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:table_calendar/table_calendar.dart';

// UTILS
import 'package:notredame/core/utils/utils.dart';

// VIEWMODELS
import 'package:notredame/core/viewmodels/schedule_settings_viewmodel.dart';

Expand All @@ -29,22 +32,45 @@ class _ScheduleSettingsState extends State<ScheduleSettings> {
child: Column(
children: [
if (widget.showHandle)
Center(
child: Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Container(
height: 5,
width: 50,
decoration: const BoxDecoration(
color: Colors.grey,
borderRadius: BorderRadius.all(Radius.circular(8.0))),
Container(
decoration: BoxDecoration(
color: Utils.getColorByBrightness(
context,
AppTheme.lightThemeBackground,
AppTheme.darkThemeBackground),
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(40.0),
topRight: Radius.circular(40.0),
)),
child: Center(
child: Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Container(
height: 5,
width: 50,
decoration: const BoxDecoration(
color: Colors.grey,
borderRadius:
BorderRadius.all(Radius.circular(8.0))),
),
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(15, 20, 20, 20),
child: Text(AppIntl.of(context).schedule_settings_title,
style: Theme.of(context).textTheme.headline6)),
Container(
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
color: Utils.getColorByBrightness(
context,
AppTheme.lightThemeBackground,
AppTheme.darkThemeBackground),
),
child: Center(
child: Padding(
padding: const EdgeInsets.fromLTRB(15, 20, 20, 20),
child: Text(AppIntl.of(context).schedule_settings_title,
style: Theme.of(context).textTheme.headline6)),
),
),
Expanded(
child: ListTileTheme(
selectedColor: Theme.of(context).textTheme.bodyText1.color,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 4.1.2+1
version: 4.1.3+1

environment:
sdk: ">=2.10.0 <3.0.0"
Expand Down

0 comments on commit 4770eea

Please sign in to comment.