cwtch-ui/lib/themes/opaque.dart

226 lines
9.2 KiB
Dart
Raw Normal View History

2021-12-07 01:40:10 +00:00
import 'dart:ui';
import 'dart:core';
import 'package:cwtch/themes/cwtch.dart';
2021-12-15 17:25:29 +00:00
import 'package:cwtch/themes/mermaid.dart';
import 'package:cwtch/themes/neon1.dart';
2021-12-15 17:25:29 +00:00
import 'package:cwtch/themes/pumpkin.dart';
import 'package:cwtch/themes/vampire.dart';
import 'package:cwtch/themes/witch.dart';
2021-12-07 01:40:10 +00:00
import 'package:flutter/material.dart';
import 'package:cwtch/settings.dart';
2022-01-04 20:52:43 +00:00
import 'package:flutter/services.dart';
2021-12-07 01:40:10 +00:00
2021-12-15 17:25:29 +00:00
import 'ghost.dart';
import 'midnight.dart';
import 'neon2.dart';
const mode_light = "light";
const mode_dark = "dark";
2021-12-15 22:29:27 +00:00
final themes = {
cwtch_theme: {mode_light: CwtchLight(), mode_dark: CwtchDark()},
2021-12-15 17:25:29 +00:00
ghost_theme: {mode_light: GhostLight(), mode_dark: GhostDark()},
mermaid_theme: {mode_light: MermaidLight(), mode_dark: MermaidDark()},
midnight_theme: {mode_light: MidnightLight(), mode_dark: MidnightDark()},
neon1_theme: {mode_light: Neon1Light(), mode_dark: Neon1Dark()},
2021-12-15 17:25:29 +00:00
neon2_theme: {mode_light: Neon2Light(), mode_dark: Neon2Dark()},
pumpkin_theme: {mode_light: PumpkinLight(), mode_dark: PumpkinDark()},
witch_theme: {mode_light: WitchLight(), mode_dark: WitchDark()},
vampire_theme: {mode_light: VampireLight(), mode_dark: VampireDark()},
};
2021-12-07 01:40:10 +00:00
OpaqueThemeType getTheme(String themeId, String mode) {
if (themeId == "") {
themeId = cwtch_theme;
2021-12-07 01:40:10 +00:00
}
if (themeId == mode_light) {
themeId = cwtch_theme;
mode = mode_light;
2021-12-07 01:40:10 +00:00
}
if (themeId == mode_dark) {
themeId = cwtch_theme;
mode = mode_dark;
2021-12-07 01:40:10 +00:00
}
var theme = themes[themeId]?[mode];
return theme ?? CwtchDark();
}
Color lighten(Color color, [double amount = 0.15]) {
final hsl = HSLColor.fromColor(color);
final hslLight = hsl.withLightness((hsl.lightness + amount).clamp(0.0, 1.0));
2021-12-07 01:40:10 +00:00
return hslLight.toColor();
}
2021-12-07 01:40:10 +00:00
Color darken(Color color, [double amount = 0.15]) {
final hsl = HSLColor.fromColor(color);
final hslDarken = hsl.withLightness((hsl.lightness - amount).clamp(0.0, 1.0));
2021-12-07 01:40:10 +00:00
return hslDarken.toColor();
}
2021-12-07 01:40:10 +00:00
abstract class OpaqueThemeType {
static final Color red = Color(0xFFFF0000);
2021-12-07 01:40:10 +00:00
get theme => "dummy";
get mode => mode_light;
2021-12-07 01:40:10 +00:00
// Main screen background color (message pane, item rows)
get backgroundMainColor => red;
2021-12-07 01:40:10 +00:00
// pane colors (settings)
get backgroundPaneColor => red;
2021-12-07 01:40:10 +00:00
get topbarColor => red;
get mainTextColor => red;
2021-12-07 01:40:10 +00:00
// pressed row, offline heart
get hilightElementColor => red;
// Selected Row
get backgroundHilightElementColor => red;
// Faded text color for suggestions in textfields
// Todo: implement way more places
get sendHintTextColor => red;
get defaultButtonColor => red;
get defaultButtonActiveColor => /*mode == mode_light ? darken(defaultButtonColor) :*/ lighten(defaultButtonColor);
get defaultButtonTextColor => red;
get defaultButtonDisabledColor => red;
get textfieldBackgroundColor => red;
get textfieldBorderColor => red;
get textfieldHintColor => red;
get textfieldErrorColor => red;
get scrollbarDefaultColor => red;
get portraitBackgroundColor => red;
get portraitOnlineBorderColor => red;
get portraitOfflineBorderColor => red;
get portraitBlockedBorderColor => red;
get portraitBlockedTextColor => red;
get portraitContactBadgeColor => red;
get portraitContactBadgeTextColor => red;
get portraitProfileBadgeColor => red;
get portraitProfileBadgeTextColor => red;
2021-12-07 01:40:10 +00:00
// dropshaddpow
// todo: probably should not be reply icon color in messagerow
get dropShadowColor => red;
2021-12-07 01:40:10 +00:00
get toolbarIconColor => red;
get messageFromMeBackgroundColor => red;
get messageFromMeTextColor => red;
get messageFromOtherBackgroundColor => red;
get messageFromOtherTextColor => red;
2021-12-07 01:40:10 +00:00
// Sizes
double contactOnionTextSize() {
return 18;
}
}
ThemeData mkThemeData(Settings opaque) {
return ThemeData(
visualDensity: VisualDensity.adaptivePlatformDensity,
primarySwatch: Colors.red,
primaryIconTheme: IconThemeData(
color: opaque.current().mainTextColor,
2021-12-07 01:40:10 +00:00
),
primaryColor: opaque.current().mainTextColor,
canvasColor: opaque.current().backgroundMainColor,
backgroundColor: opaque.current().backgroundMainColor,
highlightColor: opaque.current().hilightElementColor,
2021-12-07 01:40:10 +00:00
iconTheme: IconThemeData(
color: opaque.current().toolbarIconColor,
2021-12-07 01:40:10 +00:00
),
cardColor: opaque.current().backgroundMainColor,
2021-12-07 01:40:10 +00:00
appBarTheme: AppBarTheme(
2022-01-04 20:52:43 +00:00
systemOverlayStyle: SystemUiOverlayStyle(
// Status bar color
2022-01-10 20:28:12 +00:00
statusBarColor: opaque.current().topbarColor,
2022-01-04 20:52:43 +00:00
// Status bar brightness (optional)
statusBarIconBrightness: opaque.current().mode == mode_light ? Brightness.dark : Brightness.light, // For Android (dark icons)
statusBarBrightness: opaque.current().mode == mode_light ? Brightness.dark : Brightness.light, // For iOS (dark icons)
),
backgroundColor: opaque.current().topbarColor,
2021-12-07 01:40:10 +00:00
iconTheme: IconThemeData(
color: opaque.current().mainTextColor,
2021-12-07 01:40:10 +00:00
),
titleTextStyle: TextStyle(
color: opaque.current().mainTextColor,
2021-12-07 01:40:10 +00:00
),
actionsIconTheme: IconThemeData(
color: opaque.current().mainTextColor,
2021-12-07 01:40:10 +00:00
)),
//bottomNavigationBarTheme: BottomNavigationBarThemeData(type: BottomNavigationBarType.fixed, backgroundColor: opaque.current().backgroundHilightElementColor), // Can't determine current use
2021-12-07 01:40:10 +00:00
textButtonTheme: TextButtonThemeData(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(opaque.current().defaultButtonColor),
foregroundColor: MaterialStateProperty.all(opaque.current().defaultButtonTextColor),
overlayColor: MaterialStateProperty.all(opaque.current().defaultButtonActiveColor),
2021-12-07 01:40:10 +00:00
padding: MaterialStateProperty.all(EdgeInsets.all(20))),
),
hintColor: opaque.current().textfieldHintColor,
2021-12-07 01:40:10 +00:00
elevatedButtonTheme: ElevatedButtonThemeData(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.resolveWith((states) => states.contains(MaterialState.disabled) ? opaque.current().defaultButtonDisabledColor : opaque.current().defaultButtonColor),
foregroundColor: MaterialStateProperty.all(opaque.current().defaultButtonTextColor),
2021-12-07 01:40:10 +00:00
overlayColor: MaterialStateProperty.resolveWith((states) => (states.contains(MaterialState.pressed) && states.contains(MaterialState.hovered))
? opaque.current().defaultButtonActiveColor
2021-12-07 01:40:10 +00:00
: states.contains(MaterialState.disabled)
? opaque.current().defaultButtonDisabledColor
2021-12-07 01:40:10 +00:00
: null),
enableFeedback: true,
splashFactory: InkRipple.splashFactory,
padding: MaterialStateProperty.all(EdgeInsets.all(20)),
shape: MaterialStateProperty.all(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6.0),
2021-12-07 01:40:10 +00:00
)),
),
),
2021-12-15 22:29:27 +00:00
scrollbarTheme: ScrollbarThemeData(isAlwaysShown: false, thumbColor: MaterialStateProperty.all(opaque.current().scrollbarDefaultColor)),
tabBarTheme: TabBarTheme(
labelColor: opaque.current().mainTextColor,
unselectedLabelColor: opaque.current().mainTextColor,
indicator: UnderlineTabIndicator(borderSide: BorderSide(color: opaque.current().defaultButtonActiveColor))),
2021-12-07 01:40:10 +00:00
dialogTheme: DialogTheme(
backgroundColor: opaque.current().backgroundPaneColor,
titleTextStyle: TextStyle(color: opaque.current().mainTextColor),
contentTextStyle: TextStyle(
color: opaque.current().mainTextColor,
)),
2021-12-07 01:40:10 +00:00
textTheme: TextTheme(
headline1: TextStyle(color: opaque.current().mainTextColor),
headline2: TextStyle(color: opaque.current().mainTextColor),
headline3: TextStyle(color: opaque.current().mainTextColor),
headline4: TextStyle(color: opaque.current().mainTextColor),
headline5: TextStyle(color: opaque.current().mainTextColor),
headline6: TextStyle(color: opaque.current().mainTextColor),
bodyText1: TextStyle(color: opaque.current().mainTextColor),
bodyText2: TextStyle(color: opaque.current().mainTextColor),
subtitle1: TextStyle(color: opaque.current().mainTextColor),
subtitle2: TextStyle(color: opaque.current().mainTextColor),
caption: TextStyle(color: opaque.current().mainTextColor),
button: TextStyle(color: opaque.current().mainTextColor),
overline: TextStyle(color: opaque.current().mainTextColor)),
2021-12-07 01:40:10 +00:00
switchTheme: SwitchThemeData(
overlayColor: MaterialStateProperty.all(opaque.current().defaultButtonActiveColor),
thumbColor: MaterialStateProperty.all(opaque.current().mainTextColor),
trackColor: MaterialStateProperty.all(opaque.current().dropShadowColor),
2021-12-07 01:40:10 +00:00
),
// the only way to change the text Selection Context Menu Color ?!
brightness: opaque.current().mode == mode_dark ? Brightness.dark : Brightness.light,
2021-12-07 01:40:10 +00:00
floatingActionButtonTheme: FloatingActionButtonThemeData(
foregroundColor: opaque.current().mainTextColor,
backgroundColor: opaque.current().defaultButtonColor,
hoverColor: opaque.current().defaultButtonActiveColor,
enableFeedback: true,
splashColor: opaque.current().defaultButtonActiveColor),
2021-12-07 01:40:10 +00:00
textSelectionTheme: TextSelectionThemeData(
cursorColor: opaque.current().defaultButtonActiveColor, selectionColor: opaque.current().defaultButtonActiveColor, selectionHandleColor: opaque.current().defaultButtonActiveColor),
2021-12-07 01:40:10 +00:00
);
}