Skip to content

Commit 4770eea

Browse files
Overlay in schedule settings (#168)
* Fix bug * Update tag * Extract color brightness * [CI UPDATE GOLDENS] * Update golden files * Fix quicklinks goldens * Remove blank Co-authored-by: camillebrulotte <camillebrulotte@users.noreply.github.com> Co-authored-by: Samuel Montambault <mont.samuel@outlook.com>
1 parent 08fd695 commit 4770eea

File tree

8 files changed

+85
-49
lines changed

8 files changed

+85
-49
lines changed

lib/core/utils/utils.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// FLUTTER / DART / THIRD-PARTIES
2+
import 'package:flutter/material.dart';
23
import 'package:fluttertoast/fluttertoast.dart';
34
import 'package:url_launcher/url_launcher.dart';
45
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
@@ -31,4 +32,11 @@ class Utils {
3132
Fluttertoast.showToast(msg: intl.no_connectivity);
3233
}
3334
}
35+
36+
static Color getColorByBrightness(
37+
BuildContext context, Color lightColor, Color darkColor) {
38+
return Theme.of(context).brightness == Brightness.light
39+
? lightColor
40+
: darkColor;
41+
}
3442
}

lib/ui/utils/app_theme.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ class AppTheme {
1111
static const Color etsDarkGrey = Color(0xff636467);
1212
static const Color etsBlack = Color(0xff2e2a25);
1313

14+
// Backgrounds
15+
static const Color darkThemeBackground = Color(0xff303030);
16+
static const Color lightThemeBackground = Color(0xfffafafa);
17+
1418
// App|ETS colors
1519
static const Color appletsPurple = Color(0xff19375f);
1620
static const Color appletsDarkPurple = Color(0xff122743);

lib/ui/views/choose_language_view.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import 'package:flutter/material.dart';
33
import 'package:stacked/stacked.dart';
44
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
55

6+
// UTILS
7+
import 'package:notredame/core/utils/utils.dart';
8+
69
// VIEWMODELS
710
import 'package:notredame/core/viewmodels/choose_language_viewmodel.dart';
811

@@ -23,9 +26,8 @@ class _ChooseLanguageViewState extends State<ChooseLanguageView> {
2326
itemCount: model.languages.length,
2427
itemBuilder: (BuildContext context, int index) {
2528
return Card(
26-
color: Theme.of(context).brightness == Brightness.light
27-
? Colors.white
28-
: Colors.grey[900],
29+
color: Utils.getColorByBrightness(
30+
context, Colors.white, Colors.grey[900]),
2931
child: Column(mainAxisSize: MainAxisSize.min, children: <Widget>[
3032
ListTile(
3133
title: Text(model.languages[index]),
@@ -46,19 +48,17 @@ class _ChooseLanguageViewState extends State<ChooseLanguageView> {
4648
viewModelBuilder: () =>
4749
ChooseLanguageViewModel(intl: AppIntl.of(context)),
4850
builder: (context, model, child) => Scaffold(
49-
backgroundColor: Theme.of(context).brightness == Brightness.light
50-
? AppTheme.etsLightRed
51-
: AppTheme.primaryDark,
51+
backgroundColor: Utils.getColorByBrightness(
52+
context, AppTheme.etsLightRed, AppTheme.primaryDark),
5253
body: Center(
5354
child: ListView(
5455
shrinkWrap: true,
5556
children: <Widget>[
5657
Icon(
5758
Icons.language,
5859
size: 80,
59-
color: Theme.of(context).brightness == Brightness.light
60-
? Colors.white
61-
: AppTheme.etsLightRed,
60+
color: Utils.getColorByBrightness(
61+
context, Colors.white, AppTheme.etsLightRed),
6262
),
6363
Padding(
6464
padding: const EdgeInsets.only(left: 20, top: 60),

lib/ui/views/login_view.dart

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import 'package:flutter_svg/flutter_svg.dart';
55
import 'package:fluttertoast/fluttertoast.dart';
66
import 'package:stacked/stacked.dart';
77

8+
// UTILS
9+
import 'package:notredame/core/utils/utils.dart';
10+
811
// VIEW MODEL
912
import 'package:notredame/core/viewmodels/login_viewmodel.dart';
1013

@@ -32,9 +35,8 @@ class _LoginViewState extends State<LoginView> {
3235
ViewModelBuilder<LoginViewModel>.reactive(
3336
viewModelBuilder: () => LoginViewModel(intl: AppIntl.of(context)),
3437
builder: (context, model, child) => Scaffold(
35-
backgroundColor: Theme.of(context).brightness == Brightness.light
36-
? AppTheme.etsLightRed
37-
: AppTheme.primaryDark,
38+
backgroundColor: Utils.getColorByBrightness(
39+
context, AppTheme.etsLightRed, AppTheme.primaryDark),
3840
resizeToAvoidBottomInset: false,
3941
body: Builder(
4042
builder: (BuildContext context) => SafeArea(
@@ -183,15 +185,12 @@ class _LoginViewState extends State<LoginView> {
183185
super.dispose();
184186
}
185187

186-
Color get errorTextColor => Theme.of(context).brightness == Brightness.light
187-
? Colors.amberAccent
188-
: Colors.redAccent;
188+
Color get errorTextColor =>
189+
Utils.getColorByBrightness(context, Colors.amberAccent, Colors.redAccent);
189190

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

194-
Color get submitTextColor => Theme.of(context).brightness == Brightness.light
195-
? AppTheme.etsLightRed
196-
: Colors.white;
194+
Color get submitTextColor =>
195+
Utils.getColorByBrightness(context, AppTheme.etsLightRed, Colors.white);
197196
}

lib/ui/views/startup_view.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import 'package:flutter/material.dart';
33
import 'package:flutter_svg/flutter_svg.dart';
44
import 'package:stacked/stacked.dart';
55

6+
// UTILS
7+
import 'package:notredame/core/utils/utils.dart';
8+
69
// VIEW MODEL
710
import 'package:notredame/core/viewmodels/startup_viewmodel.dart';
811

@@ -16,10 +19,8 @@ class StartUpView extends StatelessWidget {
1619
viewModelBuilder: () => StartUpViewModel(),
1720
onModelReady: (StartUpViewModel model) => model.handleStartUp(),
1821
builder: (context, model, child) => Scaffold(
19-
backgroundColor:
20-
Theme.of(context).brightness == Brightness.light
21-
? AppTheme.etsLightRed
22-
: AppTheme.primaryDark,
22+
backgroundColor: Utils.getColorByBrightness(
23+
context, AppTheme.etsLightRed, AppTheme.primaryDark),
2324
body: SafeArea(
2425
minimum: const EdgeInsets.all(20),
2526
child: Center(

lib/ui/widgets/grade_evaluation_tile.dart

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,10 @@ class _GradeEvaluationTileState extends State<GradeEvaluationTile>
104104
widget.evaluation.title,
105105
overflow: TextOverflow.ellipsis,
106106
style: TextStyle(
107-
fontSize: 16,
108-
color:
109-
Theme.of(context).brightness == Brightness.light
110-
? Colors.black
111-
: Colors.white),
107+
fontSize: 16,
108+
color: Utils.getColorByBrightness(
109+
context, Colors.black, Colors.white),
110+
),
112111
),
113112
),
114113
Padding(
@@ -117,11 +116,10 @@ class _GradeEvaluationTileState extends State<GradeEvaluationTile>
117116
AppIntl.of(context)
118117
.grades_weight(widget.evaluation.weight),
119118
style: TextStyle(
120-
fontSize: 14,
121-
color:
122-
Theme.of(context).brightness == Brightness.light
123-
? Colors.black
124-
: Colors.white),
119+
fontSize: 14,
120+
color: Utils.getColorByBrightness(
121+
context, Colors.black, Colors.white),
122+
),
125123
),
126124
),
127125
],

lib/ui/widgets/schedule_settings.dart

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import 'package:stacked/stacked.dart';
33
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
44
import 'package:table_calendar/table_calendar.dart';
55

6+
// UTILS
7+
import 'package:notredame/core/utils/utils.dart';
8+
69
// VIEWMODELS
710
import 'package:notredame/core/viewmodels/schedule_settings_viewmodel.dart';
811

@@ -29,22 +32,45 @@ class _ScheduleSettingsState extends State<ScheduleSettings> {
2932
child: Column(
3033
children: [
3134
if (widget.showHandle)
32-
Center(
33-
child: Padding(
34-
padding: const EdgeInsets.only(top: 8.0),
35-
child: Container(
36-
height: 5,
37-
width: 50,
38-
decoration: const BoxDecoration(
39-
color: Colors.grey,
40-
borderRadius: BorderRadius.all(Radius.circular(8.0))),
35+
Container(
36+
decoration: BoxDecoration(
37+
color: Utils.getColorByBrightness(
38+
context,
39+
AppTheme.lightThemeBackground,
40+
AppTheme.darkThemeBackground),
41+
borderRadius: const BorderRadius.only(
42+
topLeft: Radius.circular(40.0),
43+
topRight: Radius.circular(40.0),
44+
)),
45+
child: Center(
46+
child: Padding(
47+
padding: const EdgeInsets.only(top: 8.0),
48+
child: Container(
49+
height: 5,
50+
width: 50,
51+
decoration: const BoxDecoration(
52+
color: Colors.grey,
53+
borderRadius:
54+
BorderRadius.all(Radius.circular(8.0))),
55+
),
4156
),
4257
),
4358
),
44-
Padding(
45-
padding: const EdgeInsets.fromLTRB(15, 20, 20, 20),
46-
child: Text(AppIntl.of(context).schedule_settings_title,
47-
style: Theme.of(context).textTheme.headline6)),
59+
Container(
60+
width: MediaQuery.of(context).size.width,
61+
decoration: BoxDecoration(
62+
color: Utils.getColorByBrightness(
63+
context,
64+
AppTheme.lightThemeBackground,
65+
AppTheme.darkThemeBackground),
66+
),
67+
child: Center(
68+
child: Padding(
69+
padding: const EdgeInsets.fromLTRB(15, 20, 20, 20),
70+
child: Text(AppIntl.of(context).schedule_settings_title,
71+
style: Theme.of(context).textTheme.headline6)),
72+
),
73+
),
4874
Expanded(
4975
child: ListTileTheme(
5076
selectedColor: Theme.of(context).textTheme.bodyText1.color,

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
1515
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
1616
# Read more about iOS versioning at
1717
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
18-
version: 4.1.2+1
18+
version: 4.1.3+1
1919

2020
environment:
2121
sdk: ">=2.10.0 <3.0.0"

0 commit comments

Comments
 (0)