Skip to content

Commit

Permalink
[App] bump versionName, versionCode; update Changelog.md; add Black t…
Browse files Browse the repository at this point in the history
…heme
  • Loading branch information
tastelessjolt committed Jan 17, 2019
1 parent c3671c9 commit ffd859d
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 20 deletions.
10 changes: 10 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## Unreleased

* Nothing here

## v1.2-beta

* Now support dark and black themes, and also you can select the colors to theme the app as well
* Implemented NewComplaintsPage (should debug image uploading though)
* Tested on an iPad, everything works fine except the creating a new complaint.

## v1.0-beta

* Implemented SettingsPage, EventEditPage, MapPage
Expand Down
15 changes: 6 additions & 9 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,37 +77,34 @@ class MyAppState extends State<MyApp> {


canvasColor:
widget.bloc.brightness == Brightness.dark ? Colors.black : null,
// bottomAppBarColor: widget.bloc.brightness == Brightness.dark
// ? Colors.grey[850]
// : null,
widget.bloc.brightness == AppBrightness.black ? Colors.black : null,


bottomAppBarColor: widget.bloc.primaryColor,
brightness: widget.bloc.brightness,
brightness: widget.bloc.brightness.toBrightness(),

textTheme: TextTheme(
display1: TextStyle(
fontFamily: "SourceSansPro",
color: widget.bloc.brightness == Brightness.light
color: widget.bloc.brightness == AppBrightness.light
? Colors.black
: Colors.white,
),
display2: TextStyle(
fontFamily: "SourceSansPro",
color: widget.bloc.brightness == Brightness.light
color: widget.bloc.brightness == AppBrightness.light
? Colors.black
: Colors.white,
),
display3: TextStyle(
fontFamily: "SourceSansPro",
color: widget.bloc.brightness == Brightness.light
color: widget.bloc.brightness == AppBrightness.light
? Colors.black
: Colors.white,
),
display4: TextStyle(
fontFamily: "SourceSansPro",
color: widget.bloc.brightness == Brightness.light
color: widget.bloc.brightness == AppBrightness.light
? Colors.black
: Colors.white,
),
Expand Down
60 changes: 55 additions & 5 deletions lib/src/blocs/ia_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,55 @@ import 'package:http/io_client.dart';
import 'package:jaguar_retrofit/jaguar_retrofit.dart';
import 'package:shared_preferences/shared_preferences.dart';

/// Describes the contrast needs of a color.
class AppBrightness {
final index;
const AppBrightness._internal(this.index);
toString() => 'AppBrightness.$index';

/// The color is dark and will require a light text color to achieve readable
/// contrast.
///
/// For example, the color might be dark grey, requiring white text.
static const dark = const AppBrightness._internal(0);

/// The color is light and will require a dark text color to achieve readable
/// contrast.
///
/// For example, the color might be bright white, requiring black text.
static const light = const AppBrightness._internal(1);

/// The color is black and will require a light text color to achieve readable
/// contrast.
///
/// For example, the color might be black, requiring white text.
static const black = const AppBrightness._internal(2);

static const values = [dark, light, black];

Brightness toBrightness() {
return index == 2 ? Brightness.dark : Brightness.values[index];
}

// // You should generally implement operator == if you
// // override hashCode.
// @override
// bool operator ==(dynamic other) {
// if (other is! AppBrightness) {
// if (other is! Brightness) {
// return false;
// }
// Brightness brightness = other;
// return brightness.index == index || (index == 2 && brightness.index == 1);
// }
// AppBrightness appBrightness = other;
// return appBrightness.index == index;
// }

}

class InstiAppBloc {
// Different Streams for the state
Stream<UnmodifiableListView<Hostel>> get hostels => _hostelsSubject.stream;
Expand Down Expand Up @@ -50,15 +99,15 @@ class InstiAppBloc {
String homepageName = "/mess";

// default theme
Brightness _brightness = Brightness.light;
AppBrightness _brightness = AppBrightness.light;
// Color _primaryColor = Color.fromARGB(255, 63, 81, 181);
Color _primaryColor = Color.fromARGB(255, 0, 98, 255);
Color _accentColor = Color.fromARGB(255, 239, 83, 80);
// Color _accentColor = Color.fromARGB(255, 139, 195, 74);

Brightness get brightness => _brightness;
AppBrightness get brightness => _brightness;

set brightness(Brightness newBrightness) {
set brightness(AppBrightness newBrightness) {
if (newBrightness != _brightness) {
wholeAppKey.currentState.setTheme(() => _brightness = newBrightness);
SharedPreferences.getInstance().then((s) {
Expand Down Expand Up @@ -103,7 +152,7 @@ class InstiAppBloc {
'/quicklinks': 9,
'/settings': 10,
};

// MaterialApp reference
GlobalKey<MyAppState> wholeAppKey;

Expand Down Expand Up @@ -131,7 +180,8 @@ class InstiAppBloc {
drawerState.setPageIndex(pageToIndex[homepageName]);
}
if (prefs.getKeys().contains("brightness")) {
_brightness = Brightness.values[prefs.getInt("brightness")] ?? _brightness;
_brightness =
AppBrightness.values[prefs.getInt("brightness")] ?? _brightness;
}
if (prefs.getKeys().contains("accentColor")) {
_accentColor = Color(prefs.getInt("accentColor")) ?? _accentColor;
Expand Down
17 changes: 13 additions & 4 deletions lib/src/routes/settingspage.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:InstiApp/src/api/model/user.dart';
import 'package:InstiApp/src/bloc_provider.dart';
import 'package:InstiApp/src/blocs/ia_bloc.dart';
import 'package:InstiApp/src/drawer.dart';
import 'package:InstiApp/src/utils/common_widgets.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -111,17 +112,25 @@ class _SettingsPageState extends State<SettingsPage> {
.copyWith(fontWeight: FontWeight.bold),
),
),
RadioListTile<Brightness>(
RadioListTile<AppBrightness>(
title: const Text("Light"),
value: Brightness.light,
value: AppBrightness.light,
groupValue: bloc.brightness,
onChanged: (v) {
bloc.brightness = v;
},
),
RadioListTile<Brightness>(
RadioListTile<AppBrightness>(
title: const Text("Dark"),
value: Brightness.dark,
value: AppBrightness.dark,
groupValue: bloc.brightness,
onChanged: (v) {
bloc.brightness = v;
},
),
RadioListTile<AppBrightness>(
title: const Text("Black"),
value: AppBrightness.black,
groupValue: bloc.brightness,
onChanged: (v) {
bloc.brightness = v;
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: Flutter App for Indian Institute of Technology, Bombay
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# Read more about versioning at semver.org.
version: 1.0.0+15
version: 1.2.0+17

environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
Expand Down Expand Up @@ -41,7 +41,7 @@ dependencies:
flutter_material_color_picker: ^0.0.3+1
flutter_typeahead: ^0.5.1
image_picker: ^0.4.12

dev_dependencies:
flutter_test:
sdk: flutter
Expand Down

0 comments on commit ffd859d

Please sign in to comment.