Skip to content

Commit

Permalink
Fix theme
Browse files Browse the repository at this point in the history
  • Loading branch information
YeungKC committed Jul 13, 2023
1 parent 151ba17 commit e49ffbf
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
8 changes: 7 additions & 1 deletion lib/app.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart' hide AnimatedTheme;
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
Expand Down Expand Up @@ -226,12 +225,19 @@ class _App extends StatelessWidget {
],
theme: ThemeData(
colorScheme: const ColorScheme.light(primary: Colors.black),
textSelectionTheme: TextSelectionThemeData(
cursorColor: lightBrightnessThemeData.accent,
),
useMaterial3: true,
).withFallbackFonts(),
darkTheme: ThemeData(
colorScheme: const ColorScheme.dark(primary: Colors.white),
textSelectionTheme: TextSelectionThemeData(
cursorColor: darkBrightnessThemeData.accent,
),
useMaterial3: true,
).withFallbackFonts(),
themeMode: context.watch<SettingCubit>().themeMode,
builder: (context, child) {
try {
context.accountServer.language =
Expand Down
14 changes: 12 additions & 2 deletions lib/bloc/setting_cubit.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:ui';

import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import 'package:hydrated_bloc/hydrated_bloc.dart';

import '../utils/logger.dart';
Expand Down Expand Up @@ -148,6 +147,17 @@ class SettingCubit extends HydratedCubit<SettingState> {
}
}

ThemeMode get themeMode {
switch(brightness) {
case Brightness.dark:
return ThemeMode.dark;
case Brightness.light:
return ThemeMode.light;
case null:
return ThemeMode.system;
}
}

set messageShowAvatar(bool? value) =>
emit(state.copyWith(messageShowAvatar: value));

Expand Down
5 changes: 4 additions & 1 deletion lib/ui/home/chat/files_preview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ class _FilesPreviewDialog extends HookWidget {
left: 32, top: 18, bottom: 18, right: 32),
backgroundColor: context.theme.accent,
),
child: Text(context.l10n.send.toUpperCase()),
child: Text(
context.l10n.send.toUpperCase(),
style: const TextStyle(color: Colors.white),
),
),
),
const SizedBox(height: 24),
Expand Down

0 comments on commit e49ffbf

Please sign in to comment.