|
@@ -1,5 +1,8 @@
|
|
|
|
+import 'dart:io';
|
|
|
|
+
|
|
import 'package:adaptive_theme/adaptive_theme.dart';
|
|
import 'package:adaptive_theme/adaptive_theme.dart';
|
|
import 'package:background_fetch/background_fetch.dart';
|
|
import 'package:background_fetch/background_fetch.dart';
|
|
|
|
+import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
@@ -15,25 +18,70 @@ final lightThemeData = ThemeData(
|
|
fontFamily: 'Inter',
|
|
fontFamily: 'Inter',
|
|
brightness: Brightness.light,
|
|
brightness: Brightness.light,
|
|
hintColor: Colors.grey,
|
|
hintColor: Colors.grey,
|
|
|
|
+ primaryColor: Colors.deepOrangeAccent,
|
|
iconTheme: IconThemeData(color: Colors.black),
|
|
iconTheme: IconThemeData(color: Colors.black),
|
|
primaryIconTheme: IconThemeData(color: Colors.red, opacity: 1.0, size: 50.0),
|
|
primaryIconTheme: IconThemeData(color: Colors.red, opacity: 1.0, size: 50.0),
|
|
colorScheme: ColorScheme.light(primary: Colors.black),
|
|
colorScheme: ColorScheme.light(primary: Colors.black),
|
|
accentColor: Color.fromRGBO(45, 194, 98, 0.2),
|
|
accentColor: Color.fromRGBO(45, 194, 98, 0.2),
|
|
buttonColor: Color.fromRGBO(45, 194, 98, 1.0),
|
|
buttonColor: Color.fromRGBO(45, 194, 98, 1.0),
|
|
- buttonTheme: ButtonThemeData().copyWith(
|
|
|
|
- buttonColor: Color.fromRGBO(45, 194, 98, 1.0),
|
|
|
|
|
|
+ outlinedButtonTheme: OutlinedButtonThemeData(
|
|
|
|
+ style: OutlinedButton.styleFrom(
|
|
|
|
+ shape: RoundedRectangleBorder(
|
|
|
|
+ borderRadius: BorderRadius.circular(8),
|
|
|
|
+ ),
|
|
|
|
+ padding: EdgeInsets.fromLTRB(50, 16, 50, 16),
|
|
|
|
+ alignment: Alignment.center,
|
|
|
|
+ textStyle: TextStyle(
|
|
|
|
+ fontWeight: FontWeight.w600,
|
|
|
|
+ fontFamily: 'Inter-SemiBold',
|
|
|
|
+ fontSize: 18,
|
|
|
|
+ ),
|
|
|
|
+ ).copyWith(
|
|
|
|
+ backgroundColor: MaterialStateProperty.resolveWith<Color>(
|
|
|
|
+ (Set<MaterialState> states) {
|
|
|
|
+ if (states.contains(MaterialState.disabled)) {
|
|
|
|
+ return Colors.grey.shade500;
|
|
|
|
+ }
|
|
|
|
+ return Colors.black;
|
|
|
|
+ },
|
|
|
|
+ ),
|
|
|
|
+ foregroundColor: MaterialStateProperty.resolveWith<Color>(
|
|
|
|
+ (Set<MaterialState> states) {
|
|
|
|
+ if (states.contains(MaterialState.disabled)) {
|
|
|
|
+ return Colors.white;
|
|
|
|
+ }
|
|
|
|
+ return Colors.white;
|
|
|
|
+ },
|
|
|
|
+ ),
|
|
|
|
+ alignment: Alignment.center,
|
|
|
|
+ ),
|
|
),
|
|
),
|
|
toggleableActiveColor: Colors.red[400],
|
|
toggleableActiveColor: Colors.red[400],
|
|
scaffoldBackgroundColor: Colors.white,
|
|
scaffoldBackgroundColor: Colors.white,
|
|
bottomAppBarColor: Color.fromRGBO(196, 196, 196, 1.0),
|
|
bottomAppBarColor: Color.fromRGBO(196, 196, 196, 1.0),
|
|
backgroundColor: Colors.white,
|
|
backgroundColor: Colors.white,
|
|
- appBarTheme: AppBarTheme().copyWith(color: Colors.blue),
|
|
|
|
|
|
+ appBarTheme: AppBarTheme().copyWith(
|
|
|
|
+ backgroundColor: Colors.white,
|
|
|
|
+ iconTheme: IconThemeData(color: Colors.black)),
|
|
//https://api.flutter.dev/flutter/material/TextTheme-class.html
|
|
//https://api.flutter.dev/flutter/material/TextTheme-class.html
|
|
textTheme: TextTheme().copyWith(
|
|
textTheme: TextTheme().copyWith(
|
|
|
|
+ headline4: TextStyle(
|
|
|
|
+ fontFamily: 'Inter-SemiBold',
|
|
|
|
+ color: Colors.black,
|
|
|
|
+ fontSize: 32,
|
|
|
|
+ fontWeight: FontWeight.w600),
|
|
headline6: TextStyle(
|
|
headline6: TextStyle(
|
|
color: Colors.black, fontSize: 18, fontWeight: FontWeight.w600),
|
|
color: Colors.black, fontSize: 18, fontWeight: FontWeight.w600),
|
|
subtitle1: TextStyle(
|
|
subtitle1: TextStyle(
|
|
- color: Colors.black, fontSize: 15, fontWeight: FontWeight.w500),
|
|
|
|
|
|
+ fontFamily: 'Inter-Medium',
|
|
|
|
+ color: Colors.black,
|
|
|
|
+ fontSize: 16,
|
|
|
|
+ fontWeight: FontWeight.w500),
|
|
|
|
+ bodyText1: TextStyle(
|
|
|
|
+ fontFamily: 'Inter-Medium',
|
|
|
|
+ color: Colors.black,
|
|
|
|
+ fontSize: 16,
|
|
|
|
+ fontWeight: FontWeight.w400),
|
|
caption: TextStyle(color: Colors.black.withOpacity(0.7), fontSize: 14),
|
|
caption: TextStyle(color: Colors.black.withOpacity(0.7), fontSize: 14),
|
|
overline: TextStyle(color: Colors.black.withOpacity(0.8), fontSize: 12)),
|
|
overline: TextStyle(color: Colors.black.withOpacity(0.8), fontSize: 12)),
|
|
|
|
|
|
@@ -41,7 +89,6 @@ final lightThemeData = ThemeData(
|
|
bodyText2: TextStyle(color: Colors.yellow),
|
|
bodyText2: TextStyle(color: Colors.yellow),
|
|
bodyText1: TextStyle(color: Colors.orange)),
|
|
bodyText1: TextStyle(color: Colors.orange)),
|
|
cardColor: Color.fromRGBO(250, 250, 250, 1.0),
|
|
cardColor: Color.fromRGBO(250, 250, 250, 1.0),
|
|
- //
|
|
|
|
dialogTheme: DialogTheme().copyWith(
|
|
dialogTheme: DialogTheme().copyWith(
|
|
backgroundColor: Color.fromRGBO(250, 250, 250, 1.0), //
|
|
backgroundColor: Color.fromRGBO(250, 250, 250, 1.0), //
|
|
),
|
|
),
|
|
@@ -73,10 +120,23 @@ final darkThemeData = ThemeData(
|
|
),
|
|
),
|
|
// primaryColor: Colors.red,
|
|
// primaryColor: Colors.red,
|
|
textTheme: TextTheme().copyWith(
|
|
textTheme: TextTheme().copyWith(
|
|
|
|
+ headline4: TextStyle(
|
|
|
|
+ fontFamily: 'Inter-SemiBold',
|
|
|
|
+ color: Colors.white,
|
|
|
|
+ fontSize: 32,
|
|
|
|
+ fontWeight: FontWeight.w600),
|
|
headline6: TextStyle(
|
|
headline6: TextStyle(
|
|
color: Colors.white, fontSize: 18, fontWeight: FontWeight.w600),
|
|
color: Colors.white, fontSize: 18, fontWeight: FontWeight.w600),
|
|
subtitle1: TextStyle(
|
|
subtitle1: TextStyle(
|
|
- color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
|
|
|
|
|
|
+ color: Colors.white,
|
|
|
|
+ fontFamily: 'Inter-Medium',
|
|
|
|
+ fontSize: 16,
|
|
|
|
+ fontWeight: FontWeight.w500),
|
|
|
|
+ bodyText1: TextStyle(
|
|
|
|
+ fontFamily: 'Inter-Medium',
|
|
|
|
+ color: Colors.white,
|
|
|
|
+ fontSize: 16,
|
|
|
|
+ fontWeight: FontWeight.w400),
|
|
caption: TextStyle(
|
|
caption: TextStyle(
|
|
color: Colors.white.withOpacity(0.6),
|
|
color: Colors.white.withOpacity(0.6),
|
|
fontSize: 14,
|
|
fontSize: 14,
|
|
@@ -86,6 +146,38 @@ final darkThemeData = ThemeData(
|
|
fontSize: 12,
|
|
fontSize: 12,
|
|
)),
|
|
)),
|
|
toggleableActiveColor: Colors.green[400],
|
|
toggleableActiveColor: Colors.green[400],
|
|
|
|
+ outlinedButtonTheme: OutlinedButtonThemeData(
|
|
|
|
+ style: OutlinedButton.styleFrom(
|
|
|
|
+ shape: RoundedRectangleBorder(
|
|
|
|
+ borderRadius: BorderRadius.circular(8),
|
|
|
|
+ ),
|
|
|
|
+ alignment: Alignment.center,
|
|
|
|
+ padding: EdgeInsets.fromLTRB(50, 16, 50, 16),
|
|
|
|
+ textStyle: TextStyle(
|
|
|
|
+ fontWeight: FontWeight.w600,
|
|
|
|
+ fontFamily: 'Inter-SemiBold',
|
|
|
|
+ fontSize: 18,
|
|
|
|
+ ),
|
|
|
|
+ ).copyWith(
|
|
|
|
+ backgroundColor: MaterialStateProperty.resolveWith<Color>(
|
|
|
|
+ (Set<MaterialState> states) {
|
|
|
|
+ if (states.contains(MaterialState.disabled)) {
|
|
|
|
+ return Colors.grey.shade500;
|
|
|
|
+ }
|
|
|
|
+ return Colors.white;
|
|
|
|
+ },
|
|
|
|
+ ),
|
|
|
|
+ foregroundColor: MaterialStateProperty.resolveWith<Color>(
|
|
|
|
+ (Set<MaterialState> states) {
|
|
|
|
+ if (states.contains(MaterialState.disabled)) {
|
|
|
|
+ return Colors.white;
|
|
|
|
+ }
|
|
|
|
+ return Colors.black;
|
|
|
|
+ },
|
|
|
|
+ ),
|
|
|
|
+ alignment: Alignment.center,
|
|
|
|
+ ),
|
|
|
|
+ ),
|
|
scaffoldBackgroundColor: Colors.black,
|
|
scaffoldBackgroundColor: Colors.black,
|
|
backgroundColor: Colors.black,
|
|
backgroundColor: Colors.black,
|
|
appBarTheme: AppBarTheme().copyWith(
|
|
appBarTheme: AppBarTheme().copyWith(
|
|
@@ -107,11 +199,6 @@ final darkThemeData = ThemeData(
|
|
),
|
|
),
|
|
);
|
|
);
|
|
|
|
|
|
-extension CustomColorScheme on ColorScheme {
|
|
|
|
- Color get defaultTextColor =>
|
|
|
|
- brightness == Brightness.light ? Colors.black : Colors.white;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
class EnteApp extends StatefulWidget {
|
|
class EnteApp extends StatefulWidget {
|
|
static const _homeWidget = HomeWidget();
|
|
static const _homeWidget = HomeWidget();
|
|
|
|
|
|
@@ -133,19 +220,44 @@ class _EnteAppState extends State<EnteApp> with WidgetsBindingObserver {
|
|
|
|
|
|
@override
|
|
@override
|
|
void initState() {
|
|
void initState() {
|
|
|
|
+ _logger.info('init App');
|
|
super.initState();
|
|
super.initState();
|
|
WidgetsBinding.instance.addObserver(this);
|
|
WidgetsBinding.instance.addObserver(this);
|
|
_configureBackgroundFetch();
|
|
_configureBackgroundFetch();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ Widget debugBuild(BuildContext context) {
|
|
|
|
+ return MaterialApp(
|
|
|
|
+ title: "ente",
|
|
|
|
+ themeMode: ThemeMode.system,
|
|
|
|
+ theme: lightThemeData,
|
|
|
|
+ darkTheme: darkThemeData,
|
|
|
|
+ home: EnteApp._homeWidget,
|
|
|
|
+ debugShowCheckedModeBanner: false,
|
|
|
|
+ navigatorKey: Network.instance.getAlice().getNavigatorKey(),
|
|
|
|
+ builder: EasyLoading.init(),
|
|
|
|
+ supportedLocales: L10n.all,
|
|
|
|
+ localizationsDelegates: const [
|
|
|
|
+ AppLocalizations.delegate,
|
|
|
|
+ GlobalMaterialLocalizations.delegate,
|
|
|
|
+ GlobalCupertinoLocalizations.delegate,
|
|
|
|
+ GlobalWidgetsLocalizations.delegate,
|
|
|
|
+ ],
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
@override
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Widget build(BuildContext context) {
|
|
|
|
+ if (kDebugMode && Platform.isIOS) {
|
|
|
|
+ return debugBuild(context);
|
|
|
|
+ }
|
|
return AdaptiveTheme(
|
|
return AdaptiveTheme(
|
|
light: lightThemeData,
|
|
light: lightThemeData,
|
|
dark: darkThemeData,
|
|
dark: darkThemeData,
|
|
initial: AdaptiveThemeMode.dark,
|
|
initial: AdaptiveThemeMode.dark,
|
|
builder: (lightTheme, dartTheme) => MaterialApp(
|
|
builder: (lightTheme, dartTheme) => MaterialApp(
|
|
title: "ente",
|
|
title: "ente",
|
|
|
|
+ themeMode: ThemeMode.system,
|
|
theme: lightTheme,
|
|
theme: lightTheme,
|
|
darkTheme: dartTheme,
|
|
darkTheme: dartTheme,
|
|
home: EnteApp._homeWidget,
|
|
home: EnteApp._homeWidget,
|
|
@@ -170,11 +282,13 @@ class _EnteAppState extends State<EnteApp> with WidgetsBindingObserver {
|
|
|
|
|
|
@override
|
|
@override
|
|
void didChangeAppLifecycleState(AppLifecycleState state) {
|
|
void didChangeAppLifecycleState(AppLifecycleState state) {
|
|
|
|
+ final String stateChangeReason = 'app -> $state';
|
|
if (state == AppLifecycleState.resumed) {
|
|
if (state == AppLifecycleState.resumed) {
|
|
- AppLifecycleService.instance.onAppInForeground();
|
|
|
|
|
|
+ AppLifecycleService.instance
|
|
|
|
+ .onAppInForeground(stateChangeReason + ': sync now');
|
|
SyncService.instance.sync();
|
|
SyncService.instance.sync();
|
|
} else {
|
|
} else {
|
|
- AppLifecycleService.instance.onAppInBackground();
|
|
|
|
|
|
+ AppLifecycleService.instance.onAppInBackground(stateChangeReason);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -194,7 +308,7 @@ class _EnteAppState extends State<EnteApp> with WidgetsBindingObserver {
|
|
), (String taskId) async {
|
|
), (String taskId) async {
|
|
await widget.runBackgroundTask(taskId);
|
|
await widget.runBackgroundTask(taskId);
|
|
}, (taskId) {
|
|
}, (taskId) {
|
|
- _logger.info("BG task timeout");
|
|
|
|
|
|
+ _logger.info("BG task timeout taskID: $taskId");
|
|
widget.killBackgroundTask(taskId);
|
|
widget.killBackgroundTask(taskId);
|
|
}).then((int status) {
|
|
}).then((int status) {
|
|
_logger.info('[BackgroundFetch] configure success: $status');
|
|
_logger.info('[BackgroundFetch] configure success: $status');
|