Skip to content

Commit ffd859d

Browse files
committed
[App] bump versionName, versionCode; update Changelog.md; add Black theme
1 parent c3671c9 commit ffd859d

File tree

5 files changed

+86
-20
lines changed

5 files changed

+86
-20
lines changed

Changelog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
* Nothing here
6+
7+
## v1.2-beta
8+
9+
* Now support dark and black themes, and also you can select the colors to theme the app as well
10+
* Implemented NewComplaintsPage (should debug image uploading though)
11+
* Tested on an iPad, everything works fine except the creating a new complaint.
12+
313
## v1.0-beta
414

515
* Implemented SettingsPage, EventEditPage, MapPage

lib/main.dart

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,37 +77,34 @@ class MyAppState extends State<MyApp> {
7777

7878

7979
canvasColor:
80-
widget.bloc.brightness == Brightness.dark ? Colors.black : null,
81-
// bottomAppBarColor: widget.bloc.brightness == Brightness.dark
82-
// ? Colors.grey[850]
83-
// : null,
80+
widget.bloc.brightness == AppBrightness.black ? Colors.black : null,
8481

8582

8683
bottomAppBarColor: widget.bloc.primaryColor,
87-
brightness: widget.bloc.brightness,
84+
brightness: widget.bloc.brightness.toBrightness(),
8885

8986
textTheme: TextTheme(
9087
display1: TextStyle(
9188
fontFamily: "SourceSansPro",
92-
color: widget.bloc.brightness == Brightness.light
89+
color: widget.bloc.brightness == AppBrightness.light
9390
? Colors.black
9491
: Colors.white,
9592
),
9693
display2: TextStyle(
9794
fontFamily: "SourceSansPro",
98-
color: widget.bloc.brightness == Brightness.light
95+
color: widget.bloc.brightness == AppBrightness.light
9996
? Colors.black
10097
: Colors.white,
10198
),
10299
display3: TextStyle(
103100
fontFamily: "SourceSansPro",
104-
color: widget.bloc.brightness == Brightness.light
101+
color: widget.bloc.brightness == AppBrightness.light
105102
? Colors.black
106103
: Colors.white,
107104
),
108105
display4: TextStyle(
109106
fontFamily: "SourceSansPro",
110-
color: widget.bloc.brightness == Brightness.light
107+
color: widget.bloc.brightness == AppBrightness.light
111108
? Colors.black
112109
: Colors.white,
113110
),

lib/src/blocs/ia_bloc.dart

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,55 @@ import 'package:http/io_client.dart';
1818
import 'package:jaguar_retrofit/jaguar_retrofit.dart';
1919
import 'package:shared_preferences/shared_preferences.dart';
2020

21+
/// Describes the contrast needs of a color.
22+
class AppBrightness {
23+
final index;
24+
const AppBrightness._internal(this.index);
25+
toString() => 'AppBrightness.$index';
26+
27+
/// The color is dark and will require a light text color to achieve readable
28+
/// contrast.
29+
///
30+
/// For example, the color might be dark grey, requiring white text.
31+
32+
static const dark = const AppBrightness._internal(0);
33+
34+
/// The color is light and will require a dark text color to achieve readable
35+
/// contrast.
36+
///
37+
/// For example, the color might be bright white, requiring black text.
38+
39+
static const light = const AppBrightness._internal(1);
40+
41+
/// The color is black and will require a light text color to achieve readable
42+
/// contrast.
43+
///
44+
/// For example, the color might be black, requiring white text.
45+
static const black = const AppBrightness._internal(2);
46+
47+
static const values = [dark, light, black];
48+
49+
Brightness toBrightness() {
50+
return index == 2 ? Brightness.dark : Brightness.values[index];
51+
}
52+
53+
// // You should generally implement operator == if you
54+
// // override hashCode.
55+
// @override
56+
// bool operator ==(dynamic other) {
57+
// if (other is! AppBrightness) {
58+
// if (other is! Brightness) {
59+
// return false;
60+
// }
61+
// Brightness brightness = other;
62+
// return brightness.index == index || (index == 2 && brightness.index == 1);
63+
// }
64+
// AppBrightness appBrightness = other;
65+
// return appBrightness.index == index;
66+
// }
67+
68+
}
69+
2170
class InstiAppBloc {
2271
// Different Streams for the state
2372
Stream<UnmodifiableListView<Hostel>> get hostels => _hostelsSubject.stream;
@@ -50,15 +99,15 @@ class InstiAppBloc {
5099
String homepageName = "/mess";
51100

52101
// default theme
53-
Brightness _brightness = Brightness.light;
102+
AppBrightness _brightness = AppBrightness.light;
54103
// Color _primaryColor = Color.fromARGB(255, 63, 81, 181);
55104
Color _primaryColor = Color.fromARGB(255, 0, 98, 255);
56105
Color _accentColor = Color.fromARGB(255, 239, 83, 80);
57106
// Color _accentColor = Color.fromARGB(255, 139, 195, 74);
58107

59-
Brightness get brightness => _brightness;
108+
AppBrightness get brightness => _brightness;
60109

61-
set brightness(Brightness newBrightness) {
110+
set brightness(AppBrightness newBrightness) {
62111
if (newBrightness != _brightness) {
63112
wholeAppKey.currentState.setTheme(() => _brightness = newBrightness);
64113
SharedPreferences.getInstance().then((s) {
@@ -103,7 +152,7 @@ class InstiAppBloc {
103152
'/quicklinks': 9,
104153
'/settings': 10,
105154
};
106-
155+
107156
// MaterialApp reference
108157
GlobalKey<MyAppState> wholeAppKey;
109158

@@ -131,7 +180,8 @@ class InstiAppBloc {
131180
drawerState.setPageIndex(pageToIndex[homepageName]);
132181
}
133182
if (prefs.getKeys().contains("brightness")) {
134-
_brightness = Brightness.values[prefs.getInt("brightness")] ?? _brightness;
183+
_brightness =
184+
AppBrightness.values[prefs.getInt("brightness")] ?? _brightness;
135185
}
136186
if (prefs.getKeys().contains("accentColor")) {
137187
_accentColor = Color(prefs.getInt("accentColor")) ?? _accentColor;

lib/src/routes/settingspage.dart

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:InstiApp/src/api/model/user.dart';
22
import 'package:InstiApp/src/bloc_provider.dart';
3+
import 'package:InstiApp/src/blocs/ia_bloc.dart';
34
import 'package:InstiApp/src/drawer.dart';
45
import 'package:InstiApp/src/utils/common_widgets.dart';
56
import 'package:flutter/material.dart';
@@ -111,17 +112,25 @@ class _SettingsPageState extends State<SettingsPage> {
111112
.copyWith(fontWeight: FontWeight.bold),
112113
),
113114
),
114-
RadioListTile<Brightness>(
115+
RadioListTile<AppBrightness>(
115116
title: const Text("Light"),
116-
value: Brightness.light,
117+
value: AppBrightness.light,
117118
groupValue: bloc.brightness,
118119
onChanged: (v) {
119120
bloc.brightness = v;
120121
},
121122
),
122-
RadioListTile<Brightness>(
123+
RadioListTile<AppBrightness>(
123124
title: const Text("Dark"),
124-
value: Brightness.dark,
125+
value: AppBrightness.dark,
126+
groupValue: bloc.brightness,
127+
onChanged: (v) {
128+
bloc.brightness = v;
129+
},
130+
),
131+
RadioListTile<AppBrightness>(
132+
title: const Text("Black"),
133+
value: AppBrightness.black,
125134
groupValue: bloc.brightness,
126135
onChanged: (v) {
127136
bloc.brightness = v;

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: Flutter App for Indian Institute of Technology, Bombay
77
# Both the version and the builder number may be overridden in flutter
88
# build by specifying --build-name and --build-number, respectively.
99
# Read more about versioning at semver.org.
10-
version: 1.0.0+15
10+
version: 1.2.0+17
1111

1212
environment:
1313
sdk: ">=2.0.0-dev.68.0 <3.0.0"
@@ -41,7 +41,7 @@ dependencies:
4141
flutter_material_color_picker: ^0.0.3+1
4242
flutter_typeahead: ^0.5.1
4343
image_picker: ^0.4.12
44-
44+
4545
dev_dependencies:
4646
flutter_test:
4747
sdk: flutter

0 commit comments

Comments
 (0)