mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-25 05:58:42 +01:00
* Add Black theme * Fix black theme * Add WixMadefor Font * feat: Enhance theme setup This change: - Adds support for custom themes - Updates theme retrieval logic to ensure the right theme is used based on user preferences(especially for custom themes). * Add black custom colors * Add custom accent colors * feat: Restructure custom colors handling for themes * feat: Integrate new custom colors structure across various components - WIP * feat: Integrate new custom colors structure across various components, black theme now ready for tests * feat: Add new accent color themes and update theme selection UI - Enhanced theme selection UI in display settings to support accent color choices. - Updated theme handling logic to accommodate new accent color variants. * Minor updates to display_settings_page.dart * Update settings_theme_choice.dart * Revert accidental change in display_settings_page.dart * Revert WixMadeFor font, fix SVG colors for CakeImageWidget, and test some color changes * Update Monero Orange * fix: Remove unused custom colors * Test outline * Test spacing and colors * Add padding * Remove outline * Add other accent colors * Update display_settings_view_model.dart * Update names and fix switch case * Add outline and update dark_theme.dart colors * Add gradient to option_tile.dart * Update icons * Update some colors * Switch option_tile.dart to TextButton * Add updated icons * Fix icon resolution * Cleanup old icons + Update pubspec_base.yaml * Remove unused fonts * Update more icons * Update image paths * Remove more icons + update some component colors * Add back DAI icon * Fix errors * feat: Implement OLED mode for BlackTheme * feat: Add OLED mode for BlackTheme and localizations * feat: Implement OLED mode for Black Theme * refactor: Remove unused theme parameters and set up easy access to toggleKnob custom colors * fix: Cleanup UI and overflows * feat: Persist black theme selection if OS theme mode while app is in system mode * fix: OS theme change when app is in background restrict pin screen from proceed * Fix theme picker sizing * Update lib/src/screens/dashboard/desktop_widgets/desktop_wallet_selection_dropdown.dart Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * refactor: Enhance theme access by introducing ThemeX extension for easier retrieval of current theme and custom colors * refactor: Remove currentTheme parameter from GradientBackground widget and adjust across affected widgets * refactor: Remove currentTheme parameter from StandardSwitch and SettingsSwitcherCell, using ThemeX extension for theme access * refactor: Remove currentTheme parameter from various widgets dependent on SettingsSwitcherCell and StandardxSwitcher, using ThemeX extension for theme access * refactor: Remove currentTheme in bottomsheets and related widgets, switching to theme extension * refactor: Remove constructor theme access in OptionTile and related widgets, switching to theme extension * refactor: Switch bottomsheet related widgets to use theme extension instead of constructor access * refactor: Migrate currentTheme access from constructor based to extension base * refactor: Switch theme access from constructor base to extension base [skip ci] * refactor: Migrate more widgets to use extension based theme access and clean up code * refactor: Update theme access across multiple widgets to use the new theme extension * refactor: Clean up theme access in various widgets, moving to extension-based theme usage * refactor: Make theme picker preview responsive * fix: Persist saved black theme accent when app is put in background and brought back * remove unused variables [skip ci] --------- Co-authored-by: Blazebrain <davidadegoke16@gmail.com> Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
224 lines
7.0 KiB
Dart
224 lines
7.0 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:cake_wallet/store/settings_store.dart';
|
|
import 'package:cake_wallet/themes/core/material_base_theme.dart';
|
|
import 'package:cake_wallet/themes/core/theme_store.dart';
|
|
import 'package:cake_wallet/utils/route_aware.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:cake_wallet/di.dart';
|
|
import 'package:cake_wallet/src/widgets/nav_bar.dart';
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
|
|
|
enum AppBarStyle { regular, withShadow, transparent, completelyTransparent }
|
|
|
|
abstract class BasePage extends StatelessWidget {
|
|
BasePage() : _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
final GlobalKey<ScaffoldState> _scaffoldKey;
|
|
|
|
final Image closeButtonImage = Image.asset('assets/images/close_button.png');
|
|
final Image closeButtonImageDarkTheme = Image.asset('assets/images/close_button_dark_theme.png');
|
|
|
|
String? get title => null;
|
|
|
|
Color? get backgroundLightColor => null;
|
|
|
|
Color? get backgroundDarkColor => null;
|
|
|
|
bool get gradientBackground => false;
|
|
|
|
bool get gradientAll => false;
|
|
|
|
bool get resizeToAvoidBottomInset => true;
|
|
|
|
bool get extendBodyBehindAppBar => false;
|
|
|
|
Widget? get endDrawer => null;
|
|
|
|
Function(BuildContext context)? get pushToWidget => null;
|
|
|
|
Function(BuildContext context)? get pushToNextWidget => null;
|
|
|
|
Function(BuildContext context)? get popWidget => null;
|
|
|
|
Function(BuildContext context)? get popNextWidget => null;
|
|
|
|
AppBarStyle get appBarStyle => AppBarStyle.regular;
|
|
|
|
Widget Function(BuildContext, Widget)? get rootWrapper => null;
|
|
|
|
MaterialThemeBase get currentTheme => getIt.get<ThemeStore>().currentTheme;
|
|
|
|
void onOpenEndDrawer() => _scaffoldKey.currentState!.openEndDrawer();
|
|
|
|
void onClose(BuildContext context) => Navigator.of(context).pop();
|
|
|
|
Color pageBackgroundColor(BuildContext context) =>
|
|
(currentTheme.isDark ? backgroundDarkColor : backgroundLightColor) ??
|
|
(gradientBackground ? Colors.transparent : Theme.of(context).colorScheme.surface);
|
|
|
|
Color titleColor(BuildContext context) => Theme.of(context).colorScheme.onSurface;
|
|
|
|
Color? pageIconColor(BuildContext context) => titleColor(context);
|
|
|
|
Widget closeButton(BuildContext context) => Image.asset(
|
|
currentTheme.isDark
|
|
? 'assets/images/close_button_dark_theme.png'
|
|
: 'assets/images/close_button.png',
|
|
color: pageIconColor(context),
|
|
height: 16,
|
|
);
|
|
|
|
Widget backButton(BuildContext context) => Icon(
|
|
Icons.arrow_back_ios,
|
|
color: Theme.of(context).colorScheme.primary,
|
|
size: 16,
|
|
);
|
|
|
|
Widget? leading(BuildContext context) {
|
|
if (ModalRoute.of(context)?.isFirst ?? true) {
|
|
return null;
|
|
}
|
|
|
|
return MergeSemantics(
|
|
child: SizedBox(
|
|
height: 37,
|
|
width: 37,
|
|
child: ButtonTheme(
|
|
minWidth: double.minPositive,
|
|
child: Semantics(
|
|
label: S.of(context).seed_alert_back,
|
|
child: TextButton(
|
|
style: TextButton.styleFrom(
|
|
foregroundColor: Theme.of(context).colorScheme.onSurface,
|
|
overlayColor: WidgetStateColor.resolveWith((states) => Colors.transparent),
|
|
),
|
|
onPressed: () => onClose(context),
|
|
child: backButton(context),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget? middle(BuildContext context) {
|
|
return title == null
|
|
? null
|
|
: Text(
|
|
title!,
|
|
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
|
fontSize: 18.0,
|
|
fontWeight: FontWeight.w600,
|
|
color: titleColor(context),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget? trailing(BuildContext context) => null;
|
|
|
|
Widget? floatingActionButton(BuildContext context) => null;
|
|
|
|
PreferredSizeWidget appBar(BuildContext context) {
|
|
final appBarColor = pageBackgroundColor(context);
|
|
|
|
switch (appBarStyle) {
|
|
case AppBarStyle.regular:
|
|
// FIX-ME: NavBar no context
|
|
return NavBar(
|
|
// context: context,
|
|
leading: leading(context),
|
|
middle: middle(context),
|
|
trailing: trailing(context),
|
|
backgroundColor: appBarColor);
|
|
|
|
case AppBarStyle.withShadow:
|
|
// FIX-ME: NavBar no context
|
|
return NavBar.withShadow(
|
|
// context: context,
|
|
leading: leading(context),
|
|
middle: middle(context),
|
|
trailing: trailing(context),
|
|
backgroundColor: appBarColor);
|
|
|
|
case AppBarStyle.transparent:
|
|
return CupertinoNavigationBar(
|
|
leading: leading(context),
|
|
middle: middle(context),
|
|
trailing: trailing(context),
|
|
backgroundColor: Colors.transparent,
|
|
border: null,
|
|
);
|
|
|
|
case AppBarStyle.completelyTransparent:
|
|
return AppBar(
|
|
leading: leading(context),
|
|
title: middle(context),
|
|
actions: <Widget>[if (trailing(context) != null) trailing(context)!],
|
|
backgroundColor: Colors.transparent,
|
|
elevation: 0,
|
|
centerTitle: true,
|
|
);
|
|
|
|
default:
|
|
// FIX-ME: NavBar no context
|
|
return NavBar(
|
|
// context: context,
|
|
leading: leading(context),
|
|
middle: middle(context),
|
|
trailing: trailing(context),
|
|
backgroundColor: appBarColor);
|
|
}
|
|
}
|
|
|
|
Widget body(BuildContext context);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final root = RouteAwareWidget(
|
|
child: Observer(
|
|
builder: (context) {
|
|
final backgroundImage = getIt.get<SettingsStore>().backgroundImage;
|
|
|
|
return Container(
|
|
width: double.infinity,
|
|
height: double.infinity,
|
|
decoration: BoxDecoration(
|
|
image: backgroundImage.isNotEmpty
|
|
? DecorationImage(
|
|
image: FileImage(File(backgroundImage)),
|
|
fit: BoxFit.cover,
|
|
)
|
|
: null,
|
|
// color: Colors.grey[200],
|
|
),
|
|
child: Scaffold(
|
|
key: _scaffoldKey,
|
|
backgroundColor: pageBackgroundColor(context),
|
|
resizeToAvoidBottomInset: resizeToAvoidBottomInset,
|
|
extendBodyBehindAppBar: extendBodyBehindAppBar,
|
|
endDrawer: endDrawer,
|
|
appBar: appBar(context),
|
|
body: SafeArea(
|
|
left: false,
|
|
right: false,
|
|
top: false,
|
|
bottom: Platform.isAndroid,
|
|
child: body(context),
|
|
),
|
|
floatingActionButton: floatingActionButton(context),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
pushToWidget: (context) => pushToWidget?.call(context),
|
|
pushToNextWidget: (context) => pushToNextWidget?.call(context),
|
|
popWidget: (context) => popWidget?.call(context),
|
|
popNextWidget: (context) => popNextWidget?.call(context),
|
|
);
|
|
|
|
return rootWrapper?.call(context, root) ?? root;
|
|
}
|
|
}
|