Add theme configuration and update color scheme in recovery key and lock screen pages
This commit is contained in:
@@ -30,6 +30,7 @@ import 'package:ente_lock_screen/ui/lock_screen.dart';
|
||||
import 'package:ente_logging/logging.dart';
|
||||
import 'package:ente_network/network.dart';
|
||||
import 'package:ente_strings/l10n/strings_localizations.dart';
|
||||
import 'package:ente_ui/theme/theme_config.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import "package:flutter/material.dart";
|
||||
import 'package:flutter_displaymode/flutter_displaymode.dart';
|
||||
@@ -90,6 +91,7 @@ void main() async {
|
||||
}
|
||||
|
||||
Future<void> _runInForeground() async {
|
||||
AppThemeConfig.initialize(EnteApp.auth);
|
||||
final savedThemeMode = _themeMode(await AdaptiveTheme.getThemeMode());
|
||||
final configuration = Configuration.instance;
|
||||
return await _runWithLogs(() async {
|
||||
|
||||
@@ -149,7 +149,7 @@ class _RecoveryKeyPageState extends State<RecoveryKeyPage> {
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
getEnteColorScheme(context).primary500,
|
||||
getEnteColorScheme(context).primary700,
|
||||
getEnteColorScheme(context).primary300,
|
||||
],
|
||||
stops: const [0.0, 0.9753],
|
||||
@@ -248,7 +248,7 @@ class _RecoveryKeyPageState extends State<RecoveryKeyPage> {
|
||||
childrens.add(
|
||||
SizedBox(
|
||||
height: 56,
|
||||
child: OutlinedButton(
|
||||
child: ElevatedButton(
|
||||
onPressed: () async {
|
||||
await _saveKeys();
|
||||
},
|
||||
|
||||
@@ -86,7 +86,7 @@ class _LockScreenConfirmPinState extends State<LockScreenConfirmPin> {
|
||||
width: 48,
|
||||
padding: const EdgeInsets.only(top: 6.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: colorTheme.primary500),
|
||||
border: Border.all(color: const Color.fromRGBO(45, 194, 98, 1.0)),
|
||||
borderRadius: BorderRadius.circular(15.0),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -130,7 +130,7 @@ class _LockScreenPinState extends State<LockScreenPin> {
|
||||
width: 48,
|
||||
padding: const EdgeInsets.only(top: 6.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: colorTheme.primary500),
|
||||
border: Border.all(color: const Color.fromRGBO(45, 194, 98, 1.0)),
|
||||
borderRadius: BorderRadius.circular(15.0),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import "package:ente_ui/theme/theme_config.dart";
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// This color scheme provides all the colors needed for a modern Flutter app,
|
||||
@@ -24,6 +25,54 @@ import 'package:flutter/material.dart';
|
||||
/// );
|
||||
/// ```
|
||||
class EnteColorScheme extends ThemeExtension<EnteColorScheme> {
|
||||
factory EnteColorScheme.fromApp(
|
||||
EnteApp app, {
|
||||
Brightness brightness = Brightness.light,
|
||||
}) {
|
||||
final appColors = switch (app) {
|
||||
EnteApp.auth => (
|
||||
primary700: const Color.fromARGB(255, 164, 0, 182),
|
||||
primary500: const Color.fromARGB(255, 204, 10, 101),
|
||||
primary400: const Color.fromARGB(255, 122, 41, 193),
|
||||
primary300: const Color.fromARGB(255, 152, 77, 244),
|
||||
gradientButtonBgColor: const Color(0xFF531DAB),
|
||||
gradientButtonBgColors: const [
|
||||
Color.fromARGB(255, 122, 41, 193),
|
||||
Color.fromARGB(255, 122, 41, 193),
|
||||
],
|
||||
),
|
||||
EnteApp.locker => (
|
||||
primary700: const Color.fromARGB(255, 0, 122, 255),
|
||||
primary400: const Color.fromARGB(255, 52, 152, 255),
|
||||
primary500: const Color.fromARGB(255, 102, 178, 255),
|
||||
primary300: const Color.fromARGB(255, 153, 204, 255),
|
||||
gradientButtonBgColor: const Color.fromRGBO(0, 122, 255, 1),
|
||||
gradientButtonBgColors: const [
|
||||
Color.fromRGBO(0, 122, 255, 1),
|
||||
Color.fromRGBO(52, 152, 255, 1),
|
||||
],
|
||||
),
|
||||
};
|
||||
|
||||
return brightness == Brightness.light
|
||||
? EnteColorScheme.light(
|
||||
primary700: appColors.primary700,
|
||||
primary500: appColors.primary500,
|
||||
primary400: appColors.primary400,
|
||||
primary300: appColors.primary300,
|
||||
gradientButtonBgColor: appColors.gradientButtonBgColor,
|
||||
gradientButtonBgColors: appColors.gradientButtonBgColors,
|
||||
)
|
||||
: EnteColorScheme.dark(
|
||||
primary700: appColors.primary700,
|
||||
primary500: appColors.primary500,
|
||||
primary400: appColors.primary400,
|
||||
primary300: appColors.primary300,
|
||||
gradientButtonBgColor: appColors.gradientButtonBgColor,
|
||||
gradientButtonBgColors: appColors.gradientButtonBgColors,
|
||||
);
|
||||
}
|
||||
|
||||
// Background Colors
|
||||
final Color backgroundBase;
|
||||
final Color backgroundElevated;
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:ente_ui/theme/colors.dart';
|
||||
import 'package:ente_ui/theme/effects.dart';
|
||||
import "package:ente_ui/theme/ente_theme_data.dart";
|
||||
import 'package:ente_ui/theme/text_style.dart';
|
||||
import "package:ente_ui/theme/theme_config.dart";
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class EnteTheme {
|
||||
@@ -49,10 +50,12 @@ EnteColorScheme getEnteColorScheme(
|
||||
return colorScheme;
|
||||
}
|
||||
|
||||
// Fallback to old system if new system is not available
|
||||
return inverse
|
||||
? Theme.of(context).colorScheme.inverseEnteTheme.colorScheme
|
||||
: Theme.of(context).colorScheme.enteTheme.colorScheme;
|
||||
final brightness = Theme.of(context).brightness;
|
||||
|
||||
return EnteColorScheme.fromApp(
|
||||
AppThemeConfig.currentApp,
|
||||
brightness: brightness,
|
||||
);
|
||||
}
|
||||
|
||||
EnteTextTheme getEnteTextTheme(
|
||||
|
||||
14
mobile/packages/ui/lib/theme/theme_config.dart
Normal file
14
mobile/packages/ui/lib/theme/theme_config.dart
Normal file
@@ -0,0 +1,14 @@
|
||||
enum EnteApp {
|
||||
auth,
|
||||
locker;
|
||||
}
|
||||
|
||||
class AppThemeConfig {
|
||||
static EnteApp? _currentApp;
|
||||
|
||||
static void initialize(EnteApp app) {
|
||||
_currentApp = app;
|
||||
}
|
||||
|
||||
static EnteApp get currentApp => _currentApp ?? EnteApp.auth;
|
||||
}
|
||||
Reference in New Issue
Block a user