Merge branch 'dev' into notifications
This commit is contained in:
@@ -45,11 +45,10 @@ const settingsDB = DatabaseStruct("settings", {
|
||||
"show_breaks": int,
|
||||
"font_family": String,
|
||||
"plus_session_id": String,
|
||||
"cal_sync_room_location": String,
|
||||
"cal_sync_show_exams": int,
|
||||
"cal_sync_show_teacher": int,
|
||||
"cal_sync_renamed": int,
|
||||
"cal_sync_room_location": String, "cal_sync_show_exams": int,
|
||||
"cal_sync_show_teacher": int, "cal_sync_renamed": int,
|
||||
"calendar_id": String,
|
||||
"nav_shadow": int,
|
||||
});
|
||||
// DON'T FORGET TO UPDATE DEFAULT VALUES IN `initDB` MIGRATION OR ELSE PARENTS WILL COMPLAIN ABOUT THEIR CHILDREN MISSING
|
||||
// YOU'VE BEEN WARNED!!!
|
||||
|
||||
@@ -15,7 +15,6 @@ import 'package:refilc/utils/service_locator.dart';
|
||||
import 'package:refilc_mobile_ui/screens/error_screen.dart';
|
||||
import 'package:refilc_mobile_ui/screens/error_report_screen.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:flutter_stripe/flutter_stripe.dart' as stripe;
|
||||
// import 'package:firebase_core/firebase_core.dart';
|
||||
|
||||
// import 'firebase_options.dart';
|
||||
@@ -35,6 +34,7 @@ void main() async {
|
||||
|
||||
// Custom error page
|
||||
ErrorWidget.builder = errorBuilder;
|
||||
|
||||
// initialize stripe key
|
||||
stripe.Stripe.publishableKey =
|
||||
'pk_test_51Oo7iUBS0FxsTGxKjGZSQqzDKWHY5ZFYM9XeI0qSdIh2w8jWy6GhHlYpT7GLTzgpl1xhE5YP4BXpA4gMZqPmgMId00cGFYFzbh';
|
||||
|
||||
@@ -98,6 +98,7 @@ class SettingsProvider extends ChangeNotifier {
|
||||
bool _calSyncShowTeacher;
|
||||
bool _calSyncRenamed;
|
||||
String _calendarId;
|
||||
bool _navShadow;
|
||||
|
||||
SettingsProvider({
|
||||
DatabaseProvider? database,
|
||||
@@ -161,6 +162,7 @@ class SettingsProvider extends ChangeNotifier {
|
||||
required bool calSyncShowTeacher,
|
||||
required bool calSyncRenamed,
|
||||
required String calendarId,
|
||||
required bool navShadow,
|
||||
}) : _database = database,
|
||||
_language = language,
|
||||
_startPage = startPage,
|
||||
@@ -221,7 +223,8 @@ class SettingsProvider extends ChangeNotifier {
|
||||
_calSyncShowExams = calSyncShowExams,
|
||||
_calSyncShowTeacher = calSyncShowTeacher,
|
||||
_calSyncRenamed = calSyncRenamed,
|
||||
_calendarId = calendarId;
|
||||
_calendarId = calendarId,
|
||||
_navShadow = navShadow;
|
||||
|
||||
factory SettingsProvider.fromMap(Map map,
|
||||
{required DatabaseProvider database}) {
|
||||
@@ -302,6 +305,7 @@ class SettingsProvider extends ChangeNotifier {
|
||||
calSyncShowTeacher: map['cal_sync_show_teacher'] == 1,
|
||||
calSyncRenamed: map['cal_sync_renamed'] == 1,
|
||||
calendarId: map['calendar_id'],
|
||||
navShadow: map['nav_shadow'] == 1,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -370,6 +374,7 @@ class SettingsProvider extends ChangeNotifier {
|
||||
"cal_sync_show_teacher": _calSyncShowTeacher ? 1 : 0,
|
||||
"cal_sync_renamed": _calSyncRenamed ? 1 : 0,
|
||||
"calendar_id": _calendarId,
|
||||
"nav_shadow": _navShadow ? 1 : 0,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -442,6 +447,7 @@ class SettingsProvider extends ChangeNotifier {
|
||||
calSyncShowTeacher: true,
|
||||
calSyncRenamed: false,
|
||||
calendarId: '',
|
||||
navShadow: true,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -505,6 +511,7 @@ class SettingsProvider extends ChangeNotifier {
|
||||
bool get calSyncShowTeacher => _calSyncShowTeacher;
|
||||
bool get calSyncRenamed => _calSyncRenamed;
|
||||
String get calendarId => _calendarId;
|
||||
bool get navShadow => _navShadow;
|
||||
|
||||
Future<void> update({
|
||||
bool store = true,
|
||||
@@ -564,6 +571,7 @@ class SettingsProvider extends ChangeNotifier {
|
||||
bool? calSyncShowTeacher,
|
||||
bool? calSyncRenamed,
|
||||
String? calendarId,
|
||||
bool? navShadow,
|
||||
}) async {
|
||||
if (language != null && language != _language) _language = language;
|
||||
if (startPage != null && startPage != _startPage) _startPage = startPage;
|
||||
@@ -731,6 +739,9 @@ class SettingsProvider extends ChangeNotifier {
|
||||
if (calendarId != null && calendarId != _calendarId) {
|
||||
_calendarId = calendarId;
|
||||
}
|
||||
if (navShadow != null && navShadow != _navShadow) {
|
||||
_navShadow = navShadow;
|
||||
}
|
||||
// store or not
|
||||
if (store) await _database?.store.storeSettings(this);
|
||||
notifyListeners();
|
||||
|
||||
22
refilc/lib/theme/colors/utils.dart
Normal file
22
refilc/lib/theme/colors/utils.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ColorsUtils {
|
||||
Color darken(Color color, {double amount = .1}) {
|
||||
assert(amount >= 0 && amount <= 1);
|
||||
|
||||
final hsl = HSLColor.fromColor(color);
|
||||
final hslDark = hsl.withLightness((hsl.lightness - amount).clamp(0.0, 1.0));
|
||||
|
||||
return hslDark.toColor();
|
||||
}
|
||||
|
||||
Color lighten(Color color, {double amount = .1}) {
|
||||
assert(amount >= 0 && amount <= 1);
|
||||
|
||||
final hsl = HSLColor.fromColor(color);
|
||||
final hslLight =
|
||||
hsl.withLightness((hsl.lightness + amount).clamp(0.0, 1.0));
|
||||
|
||||
return hslLight.toColor();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,20 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:home_widget/home_widget.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
Future<bool?> updateWidget() async {
|
||||
try {
|
||||
return HomeWidget.updateWidget(name: 'widget_timetable.WidgetTimetable');
|
||||
} on PlatformException catch (exception) {
|
||||
if (kDebugMode) {
|
||||
print('Error Updating Widget After changeTheme. $exception');
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
class ThemeModeObserver extends ChangeNotifier {
|
||||
ThemeMode _themeMode;
|
||||
@@ -13,6 +29,7 @@ class ThemeModeObserver extends ChangeNotifier {
|
||||
void changeTheme(ThemeMode mode, {bool updateNavbarColor = true}) {
|
||||
_themeMode = mode;
|
||||
_updateNavbarColor = updateNavbarColor;
|
||||
if (Platform.isAndroid) updateWidget();
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:refilc/models/settings.dart';
|
||||
import 'package:refilc/theme/colors/accent.dart';
|
||||
import 'package:refilc/theme/colors/colors.dart';
|
||||
import 'package:refilc/theme/colors/utils.dart';
|
||||
import 'package:refilc/theme/observer.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:material_color_utilities/material_color_utilities.dart';
|
||||
@@ -61,6 +62,10 @@ class AppTheme {
|
||||
: _paletteHighlightLight(palette)) ??
|
||||
lightColors.highlight;
|
||||
|
||||
Color newSecondary = ColorsUtils().darken(accent, amount: 0.4);
|
||||
// Color newScaffoldBg = ColorsUtils().lighten(accent, amount: 0.4);
|
||||
Color newTertiary = ColorsUtils().darken(accent, amount: 0.5);
|
||||
|
||||
return ThemeData(
|
||||
brightness: Brightness.light,
|
||||
useMaterial3: true,
|
||||
@@ -74,9 +79,14 @@ class AppTheme {
|
||||
onPrimary:
|
||||
(accent.computeLuminance() > 0.5 ? Colors.black : Colors.white)
|
||||
.withOpacity(.9),
|
||||
secondary: accent,
|
||||
onSecondary:
|
||||
(accent.computeLuminance() > 0.5 ? Colors.black : Colors.white)
|
||||
secondary: newSecondary,
|
||||
onSecondary: (newSecondary.computeLuminance() > 0.5
|
||||
? Colors.black
|
||||
: Colors.white)
|
||||
.withOpacity(.9),
|
||||
tertiary: newTertiary,
|
||||
onTertiary:
|
||||
(newTertiary.computeLuminance() > 0.5 ? Colors.black : Colors.white)
|
||||
.withOpacity(.9),
|
||||
background: highlightColor,
|
||||
onBackground: Colors.black.withOpacity(.9),
|
||||
@@ -145,6 +155,9 @@ class AppTheme {
|
||||
: _paletteHighlightDark(palette)) ??
|
||||
darkColors.highlight;
|
||||
|
||||
Color newSecondary = ColorsUtils().lighten(accent, amount: 0.4);
|
||||
Color newTertiary = ColorsUtils().lighten(accent, amount: 0.5);
|
||||
|
||||
return ThemeData(
|
||||
brightness: Brightness.dark,
|
||||
useMaterial3: true,
|
||||
@@ -158,9 +171,14 @@ class AppTheme {
|
||||
onPrimary:
|
||||
(accent.computeLuminance() > 0.5 ? Colors.black : Colors.white)
|
||||
.withOpacity(.9),
|
||||
secondary: accent,
|
||||
onSecondary:
|
||||
(accent.computeLuminance() > 0.5 ? Colors.black : Colors.white)
|
||||
secondary: newSecondary,
|
||||
onSecondary: (newSecondary.computeLuminance() > 0.5
|
||||
? Colors.black
|
||||
: Colors.white)
|
||||
.withOpacity(.9),
|
||||
tertiary: newTertiary,
|
||||
onTertiary:
|
||||
(newTertiary.computeLuminance() > 0.5 ? Colors.black : Colors.white)
|
||||
.withOpacity(.9),
|
||||
background: highlightColor,
|
||||
onBackground: Colors.white.withOpacity(.9),
|
||||
|
||||
Reference in New Issue
Block a user