Skip to content

Commit

Permalink
chore: allow monochrome colors
Browse files Browse the repository at this point in the history
  • Loading branch information
MSOB7YY committed Feb 23, 2025
1 parent a6739fd commit 7c3424f
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 15 deletions.
8 changes: 8 additions & 0 deletions lib/controller/current_color.dart
Original file line number Diff line number Diff line change
Expand Up @@ -538,13 +538,21 @@ class CurrentColor {
}

extension ColorUtils on Color {
bool _isNearWhiteOrBlack() {
final luminance = computeLuminance();
return luminance <= 0.1 || luminance >= 0.9;
}

Color get delightned {
if (_isNearWhiteOrBlack()) return this;

final hslColor = HSLColor.fromColor(this);
final modifiedColor = hslColor.withLightness(0.4).toColor();
return modifiedColor;
}

Color get lighter {
if (_isNearWhiteOrBlack()) return this;
final hslColor = HSLColor.fromColor(this);
final modifiedColor = hslColor.withLightness(0.64).toColor();
return modifiedColor;
Expand Down
2 changes: 2 additions & 0 deletions lib/controller/file_browser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:namida/core/constants.dart';
import 'package:namida/core/extensions.dart';
import 'package:namida/core/icon_fonts/broken_icons.dart';
import 'package:namida/core/namida_converter_ext.dart';
import 'package:namida/core/themes.dart';
import 'package:namida/core/translations/language.dart';
import 'package:namida/core/utils.dart';
import 'package:namida/packages/three_arched_circle.dart';
Expand Down Expand Up @@ -1321,6 +1322,7 @@ class _NamidaFileBrowserState<T extends FileSystemEntity> extends State<_NamidaF
child: const Icon(
Broken.tick_square,
size: 32.0,
color: AppThemes.fabForegroundColor,
),
)
: const SizedBox(),
Expand Down
31 changes: 21 additions & 10 deletions lib/core/themes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class AppThemes {
static final AppThemes _instance = AppThemes._internal();
AppThemes._internal();

static const fabForegroundColor = Color.fromRGBO(255, 255, 255, 0.8);

ThemeData getAppTheme([Color? color, bool? light, bool lighterDialog = true]) {
color ??= CurrentColor.inst.color;
light ??= namida.theme.brightness == Brightness.light;
Expand Down Expand Up @@ -41,10 +43,16 @@ class AppThemes {

const fontFallback = ['sans-serif', 'Roboto'];

final brightness = light ? Brightness.light : Brightness.dark;
return ThemeData(
brightness: light ? Brightness.light : Brightness.dark,
brightness: brightness,
useMaterial3: true,
colorSchemeSeed: color,
colorScheme: ColorScheme.fromSeed(
seedColor: color,
brightness: brightness,
contrastLevel: 0.1,
dynamicSchemeVariant: DynamicSchemeVariant.content, // ensure monochrome colors are not modified
),
fontFamily: "LexendDeca",
fontFamilyFallback: fontFallback,
scaffoldBackgroundColor: pitchBlack ?? (light ? Color.alphaBlend(color.withAlpha(60), Colors.white) : null),
Expand Down Expand Up @@ -93,15 +101,18 @@ class AppThemes {
: null),
),
),
dialogBackgroundColor: lighterDialog
? light
? Color.alphaBlend(getMainColorWithAlpha(60), Colors.white)
: Color.alphaBlend(getMainColorWithAlpha(20), pitchBlack ?? const Color.fromARGB(255, 12, 12, 12))
: light
? Color.alphaBlend(getMainColorWithAlpha(35), Colors.white)
: Color.alphaBlend(getMainColorWithAlpha(12), pitchBlack ?? const Color.fromARGB(255, 16, 16, 16)),
focusColor: light ? const Color.fromARGB(200, 190, 190, 190) : const Color.fromARGB(150, 80, 80, 80),
dialogTheme: DialogTheme(surfaceTintColor: Colors.transparent, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24.0.multipliedRadius))),
dialogTheme: DialogTheme(
surfaceTintColor: Colors.transparent,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24.0.multipliedRadius)),
backgroundColor: lighterDialog
? light
? Color.alphaBlend(getMainColorWithAlpha(60), Colors.white)
: Color.alphaBlend(getMainColorWithAlpha(20), pitchBlack ?? const Color.fromARGB(255, 12, 12, 12))
: light
? Color.alphaBlend(getMainColorWithAlpha(35), Colors.white)
: Color.alphaBlend(getMainColorWithAlpha(12), pitchBlack ?? const Color.fromARGB(255, 16, 16, 16)),
),
listTileTheme: ListTileThemeData(
horizontalTitleGap: 16.0,
selectedColor: light
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/dialogs/general_popup_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ Future<void> showGeneralPopupDialog(
return AnimatedThemeOrTheme(
data: theme,
child: Dialog(
backgroundColor: theme.dialogBackgroundColor,
backgroundColor: theme.dialogTheme.backgroundColor,
insetPadding: EdgeInsets.symmetric(horizontal: horizontalMargin, vertical: 24.0),
clipBehavior: Clip.antiAlias,
child: SingleChildScrollView(
Expand Down
5 changes: 3 additions & 2 deletions lib/ui/pages/main_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import 'package:namida/core/enums.dart';
import 'package:namida/core/extensions.dart';
import 'package:namida/core/icon_fonts/broken_icons.dart';
import 'package:namida/core/namida_converter_ext.dart';
import 'package:namida/core/themes.dart';
import 'package:namida/core/translations/language.dart';
import 'package:namida/core/utils.dart';
import 'package:namida/packages/searchbar_animation.dart';
Expand Down Expand Up @@ -324,7 +325,7 @@ class __MainPageFABButtonState extends State<_MainPageFABButton> {
rx: ScrollSearchController.inst.currentSearchType,
builder: (context, currentSearchType) => Icon(
_shouldShowSubmitSearch && currentSearchType == SearchType.youtube ? Broken.search_normal : Broken.shield_slash,
color: Color.fromRGBO(255, 255, 255, 0.8),
color: AppThemes.fabForegroundColor,
),
),
if (runningSearchesCount > 0) searchProgressWidget,
Expand All @@ -336,7 +337,7 @@ class __MainPageFABButtonState extends State<_MainPageFABButton> {
rx: settings.floatingActionButton,
builder: (context, fabButton) => Icon(
fabButton.toIcon(),
color: const Color.fromRGBO(255, 255, 255, 0.8),
color: AppThemes.fabForegroundColor,
),
),
),
Expand Down
6 changes: 5 additions & 1 deletion lib/youtube/widgets/yt_queue_chip.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:namida/core/extensions.dart';
import 'package:namida/core/functions.dart';
import 'package:namida/core/icon_fonts/broken_icons.dart';
import 'package:namida/core/namida_converter_ext.dart';
import 'package:namida/core/themes.dart';
import 'package:namida/core/translations/language.dart';
import 'package:namida/core/utils.dart';
import 'package:namida/packages/scroll_physics_modified.dart';
Expand Down Expand Up @@ -190,7 +191,10 @@ class YTMiniplayerQueueChipState extends State<YTMiniplayerQueueChip> with Ticke
heroTag: 'yt_queue_fab_hero',
backgroundColor: context.theme.colorScheme.secondaryContainer.withValues(alpha: 0.9),
onPressed: () => _animateSmallToBig(),
child: const Icon(Broken.driver),
child: const Icon(
Broken.driver,
color: AppThemes.fabForegroundColor,
),
),
)
: NamidaInkWell(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: namida
description: A Beautiful and Feature-rich Music Player, With YouTube & Video Support Built in Flutter
publish_to: "none"
version: 5.0.09-beta+250218789
version: 5.0.1-beta+250223227

environment:
sdk: ">=3.6.0 <4.0.0"
Expand Down

0 comments on commit 7c3424f

Please sign in to comment.