fix(ui): Allow opening non-redesigned pages again

This commit is contained in:
PapaTutuWawa 2024-03-30 20:11:36 +01:00
parent de84d5924b
commit 8928d3a34c
7 changed files with 50 additions and 27 deletions

View File

@ -77,6 +77,7 @@ import 'package:moxxyv2/ui/service/data.dart';
import 'package:moxxyv2/ui/service/progress.dart';
import 'package:moxxyv2/ui/service/read.dart';
import 'package:moxxyv2/ui/service/sharing.dart';
import 'package:moxxyv2/ui/theme.dart';
import 'package:page_transition/page_transition.dart';
void setupLogging() {
@ -293,9 +294,15 @@ class MyAppState extends State<MyApp> with WidgetsBindingObserver {
title: 'Moxxy',
theme: ThemeData(
colorScheme: light,
extensions: [
getMoxxyThemeData(Brightness.light),
],
),
darkTheme: ThemeData(
colorScheme: dark,
extensions: [
getMoxxyThemeData(Brightness.dark),
],
),
navigatorKey: widget.navigationKey,
onGenerateRoute: (settings) {

View File

@ -367,7 +367,10 @@ class ConversationPageState extends State<ConversationPage>
Widget build(BuildContext context) {
final maxWidth = MediaQuery.of(context).size.width * 0.6;
return PopScope(
canPop: !_keyboardController.currentData.visible && !_keyboardController.currentData.showWidget && !_conversationController.messagingController.isRecordingNotifier.value,
canPop: !_keyboardController.currentData.visible &&
!_keyboardController.currentData.showWidget &&
!_conversationController
.messagingController.isRecordingNotifier.value,
onPopInvoked: (didPop) {
if (_keyboardController.currentData.visible) {
// If the keyboard is open, dismiss it.

View File

@ -82,7 +82,7 @@ class CropPage extends StatelessWidget {
return PopScope(
onPopInvoked: (_) {
context.read<CropBloc>().add(ResetImageEvent());
},
},
child: SafeArea(
child: state.image != null
? _buildImageBody(context, state)

View File

@ -123,7 +123,9 @@ class AccountsBottomModal extends StatelessWidget {
final cubit = context.read<AccountCubit>();
final accounts = cubit.state.accounts;
final extent = clampDouble(
((accounts.length + 1) * AccountListTile.height + mq.textScaler.scale(20)) / mq.size.height,
((accounts.length + 1) * AccountListTile.height +
mq.textScaler.scale(20)) /
mq.size.height,
0,
0.9,
);

View File

@ -93,7 +93,9 @@ class CropBackgroundPageState extends State<CropBackgroundPage> {
canPop: !state.isWorking,
onPopInvoked: (didPop) {
if (didPop) {
context.read<CropBackgroundBloc>().add(CropBackgroundResetEvent());
context
.read<CropBackgroundBloc>()
.add(CropBackgroundResetEvent());
}
},
child: SafeArea(

View File

@ -89,6 +89,34 @@ MaterialStateProperty<Color> _makeEnabledDisabledProperty(
});
}
/// Helper function to construct the ThemeData extension for Moxxy-specific theming.
// TODO(Unknown): Remove once we have an actual design for everything
MoxxyThemeData getMoxxyThemeData(Brightness brightness) {
if (brightness == Brightness.dark) {
return const MoxxyThemeData(
conversationTextFieldColor: conversationTextFieldColorDark,
profileFallbackBackgroundColor: profileFallbackBackgroundColorDark,
profileFallbackTextColor: profileFallbackTextColorDark,
bubbleQuoteInTextFieldColor: bubbleQuoteInTextFieldColorDark,
bubbleQuoteInTextFieldTextColor: bubbleQuoteInTextFieldTextColorDark,
conversationTextFieldHintTextColor: textFieldHintTextColorDark,
conversationTextFieldTextColor: textFieldTextColorDark,
conversationOverlayTextColor: conversationOverlayButtonTextColor,
);
} else {
return const MoxxyThemeData(
conversationTextFieldColor: conversationTextFieldColorLight,
profileFallbackBackgroundColor: profileFallbackBackgroundColorLight,
profileFallbackTextColor: profileFallbackTextColorLight,
bubbleQuoteInTextFieldColor: bubbleQuoteInTextFieldColorLight,
bubbleQuoteInTextFieldTextColor: bubbleQuoteInTextFieldTextColorLight,
conversationTextFieldHintTextColor: textFieldHintTextColorLight,
conversationTextFieldTextColor: textFieldTextColorLight,
conversationOverlayTextColor: conversationOverlayButtonTextColor,
);
}
}
// NOTE: Inspired by syphon's code: https://github.com/syphon-org/syphon/blob/dev/lib/global/themes.dart
ThemeData getThemeData(BuildContext context, Brightness brightness) {
return ThemeData(
@ -143,28 +171,7 @@ ThemeData getThemeData(BuildContext context, Brightness brightness) {
),
extensions: [
if (brightness == Brightness.dark)
const MoxxyThemeData(
conversationTextFieldColor: conversationTextFieldColorDark,
profileFallbackBackgroundColor: profileFallbackBackgroundColorDark,
profileFallbackTextColor: profileFallbackTextColorDark,
bubbleQuoteInTextFieldColor: bubbleQuoteInTextFieldColorDark,
bubbleQuoteInTextFieldTextColor: bubbleQuoteInTextFieldTextColorDark,
conversationTextFieldHintTextColor: textFieldHintTextColorDark,
conversationTextFieldTextColor: textFieldTextColorDark,
conversationOverlayTextColor: conversationOverlayButtonTextColor,
)
else
const MoxxyThemeData(
conversationTextFieldColor: conversationTextFieldColorLight,
profileFallbackBackgroundColor: profileFallbackBackgroundColorLight,
profileFallbackTextColor: profileFallbackTextColorLight,
bubbleQuoteInTextFieldColor: bubbleQuoteInTextFieldColorLight,
bubbleQuoteInTextFieldTextColor: bubbleQuoteInTextFieldTextColorLight,
conversationTextFieldHintTextColor: textFieldHintTextColorLight,
conversationTextFieldTextColor: textFieldTextColorLight,
conversationOverlayTextColor: conversationOverlayButtonTextColor,
),
getMoxxyThemeData(brightness),
],
);
}

View File

@ -64,7 +64,9 @@ class ContextMenu extends StatelessWidget {
/// Computes the height of the context menu, given the number of items.
static double computeHeight(BuildContext context, int numberItems) {
return 2 * pxToLp(24) + numberItems * (pxToLp(48) + MediaQuery.of(context).textScaler.scale(32));
return 2 * pxToLp(24) +
numberItems *
(pxToLp(48) + MediaQuery.of(context).textScaler.scale(32));
}
@override