Skip to content

Commit

Permalink
TW-1781: add deprecated and TODO for background and onBackground color
Browse files Browse the repository at this point in the history
  • Loading branch information
sherlockvn committed May 25, 2024
1 parent 2b11c3b commit cb6cbbb
Show file tree
Hide file tree
Showing 26 changed files with 89 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
flutter clean
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
flutter pub get
flutter pub get # In flutter 3.22, flutter gen-l10n is not working properly, so we need to run flutter pub get again
flutter build web --release --verbose --source-maps --base-href="/${GITHUB_REPOSITORY##*/}/$FOLDER/"
echo "$TWAKE_PREVIEW_CONFIG" | yq '.issue_id = strenv(FOLDER)' > ./build/web/config.json
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
- name: Run widget test
run: |
flutter pub get && flutter pub run build_runner build --delete-conflicting-outputs
flutter pub get
flutter pub get # In flutter 3.22, flutter gen-l10n is not working properly, so we need to run flutter pub get again
flutter test
# integration_test:
Expand Down
1 change: 0 additions & 1 deletion devtools_options.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions docs/adr/0023-upgrade-flutter-3.22.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 21. Listen to presence status
# 23. Upgrade flutter 3.22

Date: 2024-05-24

Expand All @@ -12,7 +12,7 @@ We need to upgrade the flutter to have up-to-date performance and features

## Decision

- remove `background` and `onBackground` color, now use only `surface` and `onSurface`
- Add `ignore_deprecated` and `TODO` for `background` and `onBackground` color, when `surface` and `background` merge to one, we will change
- change name from `surfaceVariant` => `surfaceContainerHighest`, `MaterialStateProperty` => `WidgetStateProperty`, `MaterialState` => `WidgetState`, use `super.key` for shorter form (new lint rule)
- Migration from `RawKeyEvent` to `KeyEvent`. [Read more](https://docs.flutter.dev/release/breaking-changes/key-event-migration#deprecated-apis-that-have-an-equivalent) (in conclusion, add ignore_deprecated, because that when i test it again, the up/down not work)
- Upgrade flutter_local_notification from `requestPermission` => `requestNotificationsPermission` [Changelog](https://pub.dev/packages/flutter_local_notifications/changelog#16001), [Readmore](https://developer.android.com/develop/ui/views/notifications/notification-permission?hl=vi)
Expand Down
10 changes: 10 additions & 0 deletions lib/config/themes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,16 @@ abstract class TwakeThemes {
onSecondaryContainer: brightness == Brightness.light
? LinagoraSysColors.material().onSecondaryContainer
: LinagoraSysColors.material().onSecondaryContainerDark,
// TODO: remove when the color scheme is updated
// ignore: deprecated_member_use
background: brightness == Brightness.light
? LinagoraSysColors.material().background
: LinagoraSysColors.material().backgroundDark,
// TODO: remove when the color scheme is updated
// ignore: deprecated_member_use
onBackground: brightness == Brightness.light
? LinagoraSysColors.material().onBackground
: LinagoraSysColors.material().onBackgroundDark,
error: brightness == Brightness.light
? LinagoraSysColors.material().error
: LinagoraSysColors.material().errorDark,
Expand Down
6 changes: 3 additions & 3 deletions lib/pages/chat/chat_input_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ChatInputRow extends StatelessWidget {
Container(
height: ChatInputRowStyle.chatInputRowHeight,
alignment: Alignment.center,
child: _ChatAccountPicker(controller),
child: ChatAccountPicker(controller),
),
Expanded(
child:
Expand Down Expand Up @@ -206,10 +206,10 @@ class ActionSelectModeWidget extends StatelessWidget {
}
}

class _ChatAccountPicker extends StatelessWidget {
class ChatAccountPicker extends StatelessWidget {
final ChatController controller;

const _ChatAccountPicker(this.controller);
const ChatAccountPicker(this.controller, {super.key});

void _popupMenuButtonSelected(String mxid) {
final client = controller.matrix!.currentBundle!
Expand Down
4 changes: 3 additions & 1 deletion lib/pages/chat/chat_invitation_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ class ChatInvitationBody extends StatelessWidget with MessageContentMixin {
child: Container(
width: ChatInvitationBodyStyle.dialogWidth,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
// TODO: change to colorSurface when its approved
// ignore: deprecated_member_use
color: Theme.of(context).colorScheme.background,
borderRadius: BorderRadius.circular(
ChatInvitationBodyStyle.dialogBorderRadius,
),
Expand Down
4 changes: 3 additions & 1 deletion lib/pages/chat/chat_view_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ class ChatViewStyle {
}) =>
active
? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.onSurface;
// TODO: change to colorSurface when its approved
// ignore: deprecated_member_use
: Theme.of(context).colorScheme.onBackground;

static const paddingBottomContextMenu = 16.0;
}
12 changes: 6 additions & 6 deletions lib/pages/chat/events/cute_events.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ class _CuteEventOverlayState extends State<CuteEventOverlay>
animation: controller!,
builder: (context, _) => LayoutBuilder(
builder: (context, constraints) {
final width = constraints.maxWidth - _CuteOverlayContent.size;
final height = constraints.maxHeight + _CuteOverlayContent.size;
final width = constraints.maxWidth - CuteOverlayContent.size;
final height = constraints.maxHeight + CuteOverlayContent.size;
return SizedBox(
height: constraints.maxHeight,
width: constraints.maxWidth,
Expand All @@ -157,8 +157,8 @@ class _CuteEventOverlayState extends State<CuteEventOverlay>
.25 *
position.height *
(controller?.value ?? 0)) -
_CuteOverlayContent.size,
child: _CuteOverlayContent(
CuteOverlayContent.size,
child: CuteOverlayContent(
emoji: widget.emoji,
),
),
Expand All @@ -178,11 +178,11 @@ class _CuteEventOverlayState extends State<CuteEventOverlay>
}
}

class _CuteOverlayContent extends StatelessWidget {
class CuteOverlayContent extends StatelessWidget {
static const double size = 64.0;
final String emoji;

const _CuteOverlayContent({required this.emoji});
const CuteOverlayContent({super.key, required this.emoji});

@override
Widget build(BuildContext context) {
Expand Down
4 changes: 3 additions & 1 deletion lib/pages/chat/events/message/message_content_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ class MessageContentBuilder extends StatelessWidget

@override
Widget build(BuildContext context) {
final textColor = Theme.of(context).colorScheme.onSurface;
// TODO: change to colorSurface when its approved
// ignore: deprecated_member_use
final textColor = Theme.of(context).colorScheme.onBackground;
final displayEvent = event.getDisplayEvent(timeline);
final noPadding = {
MessageTypes.File,
Expand Down
4 changes: 3 additions & 1 deletion lib/pages/chat/events/verification_request_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ class VerificationRequestContent extends StatelessWidget {
color: Theme.of(context).dividerColor,
),
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
color: Theme.of(context).colorScheme.surface,
// TODO: change to colorSurface when its approved
// ignore: deprecated_member_use
color: Theme.of(context).colorScheme.background,
),
child: Row(
mainAxisSize: MainAxisSize.min,
Expand Down
4 changes: 3 additions & 1 deletion lib/pages/chat/send_file_dialog/hover_actions_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ class SendFileDialogActionsWidget extends StatelessWidget {
child: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Theme.of(context).colorScheme.surface,
// TODO: change to colorSurface when its approved
// ignore: deprecated_member_use
color: Theme.of(context).colorScheme.background,
),
margin: SendFileDialogStyle.paddingRemoveButton,
child: Row(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ class ChatDetailsMediaStyle {

static Decoration durationBoxDecoration(BuildContext context) =>
ShapeDecoration(
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.5),
// TODO: change to colorSurface when its approved
// ignore: deprecated_member_use
color: Theme.of(context).colorScheme.onBackground.withOpacity(0.5),
shape: const StadiumBorder(),
);

Expand Down
4 changes: 3 additions & 1 deletion lib/pages/chat_list/navi_rail_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ class NaviRailItem extends StatelessWidget {
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
color: isSelected
? Theme.of(context).colorScheme.primaryContainer
: Theme.of(context).colorScheme.surface,
// TODO: change to colorSurface when its approved
// ignore: deprecated_member_use
: Theme.of(context).colorScheme.background,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 8.0,
Expand Down
4 changes: 3 additions & 1 deletion lib/pages/chat_list/space_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ class _SpaceViewState extends State<SpaceView> {
MatrixLocals(L10n.of(context)!),
);
return Material(
color: Theme.of(context).colorScheme.surface,
// TODO: change to colorSurface when its approved
// ignore: deprecated_member_use
color: Theme.of(context).colorScheme.background,
child: ListTile(
leading: Avatar(
mxContent: rootSpace.avatar,
Expand Down
4 changes: 3 additions & 1 deletion lib/pages/contacts_tab/empty_contacts_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ class EmptyContactBody extends StatelessWidget {
Text(
L10n.of(context)!.soonThereHaveContacts,
style: Theme.of(context).textTheme.titleLarge?.copyWith(
color: Theme.of(context).colorScheme.onSurface,
// TODO: change to colorSurface when its approved
// ignore: deprecated_member_use
color: Theme.of(context).colorScheme.onBackground,
),
textAlign: TextAlign.center,
),
Expand Down
16 changes: 11 additions & 5 deletions lib/pages/new_group/widget/contacts_selection_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import 'package:fluffychat/pages/new_private_chat/widget/no_contacts_found.dart'

class ContactsSelectionList extends StatelessWidget {
final SelectedContactsMapChangeNotifier selectedContactsMapNotifier;
final ValueNotifier<List<PresentationSearch>> presentationRecentContactNotifier;
final ValueNotifier<List<PresentationSearch>>
presentationRecentContactNotifier;
final ValueNotifier<Either<Failure, Success>> presentationContactNotifier;
final Function() onSelectedContact;
final List<String> disabledContactIds;
Expand All @@ -32,7 +33,7 @@ class ContactsSelectionList extends StatelessWidget {
required this.textEditingController,
required this.presentationRecentContactNotifier,
});

@override
Widget build(BuildContext context) {
return ValueListenableBuilder(
Expand All @@ -42,7 +43,8 @@ class ContactsSelectionList extends StatelessWidget {

return state.fold(
(failure) {
final recentContact = presentationRecentContactNotifier.value.isEmpty;
final recentContact =
presentationRecentContactNotifier.value.isEmpty;
final textControllerIsEmpty = textEditingController.text.isEmpty;
if (failure is GetPresentationContactsEmpty ||
failure is GetPresentationContactsFailure) {
Expand All @@ -51,7 +53,9 @@ class ContactsSelectionList extends StatelessWidget {
child: Padding(
padding: ContactsSelectionListStyle.notFoundPadding,
child: NoContactsFound(
keyword: textControllerIsEmpty ? null : textEditingController.text,
keyword: textControllerIsEmpty
? null
: textEditingController.text,
),
),
);
Expand Down Expand Up @@ -103,7 +107,9 @@ class ContactsSelectionList extends StatelessWidget {
onSelectedContact: onSelectedContact,
highlightKeyword: textEditingController.text,
disabled: disabled,
paddingTop: index == 0 ? ContactsSelectionListStyle.listPaddingTop : 0,
paddingTop: index == 0
? ContactsSelectionListStyle.listPaddingTop
: 0,
);
},
);
Expand Down
4 changes: 3 additions & 1 deletion lib/pages/settings_dashboard/settings/settings_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ class SettingsView extends StatelessWidget {
),
bottomNavigationBar: bottomNavigationBar,
body: ListTileTheme(
iconColor: Theme.of(context).colorScheme.onSurface,
// TODO: change to colorSurface when its approved
// ignore: deprecated_member_use
iconColor: Theme.of(context).colorScheme.onBackground,
child: ListView(
key: const Key('SettingsListViewContent'),
children: <Widget>[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ class SettingsSecurityView extends StatelessWidget {
context: context,
),
body: ListTileTheme(
iconColor: Theme.of(context).colorScheme.onSurface,
// TODO: remove when the color scheme is updated
// ignore: deprecated_member_use
iconColor: Theme.of(context).colorScheme.onBackground,
child: MaxWidthBody(
withScrolling: true,
child: Column(
Expand Down
4 changes: 3 additions & 1 deletion lib/pages/story/story_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,9 @@ class StoryView extends StatelessWidget {
onPressed: controller.replyAction,
icon: const Icon(Icons.send_outlined),
),
fillColor: Theme.of(context).colorScheme.surface,
// TODO: change to colorSurface when its approved
// ignore: deprecated_member_use
fillColor: Theme.of(context).colorScheme.background,
),
),
),
Expand Down
4 changes: 3 additions & 1 deletion lib/utils/twake_snackbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ class TwakeSnackBar {
content: Text(
message,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Theme.of(context).colorScheme.surface,
// TODO: change to colorSurface when its approved
// ignore: deprecated_member_use
color: Theme.of(context).colorScheme.background,
),
),
),
Expand Down
4 changes: 3 additions & 1 deletion lib/widgets/app_bars/searchable_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ class SearchableAppBar extends StatelessWidget {
prefixIcon: !isFullScreen
? Icon(
Icons.search_outlined,
color: Theme.of(context).colorScheme.onSurface,
// TODO: change to colorSurface when its approved
// ignore: deprecated_member_use
color: Theme.of(context).colorScheme.onBackground,
)
: null,
suffixIcon: const SizedBox.shrink(),
Expand Down
4 changes: 3 additions & 1 deletion lib/widgets/file_widget/file_tile_widget_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ class FileTileWidgetStyle {

TextStyle highlightTextStyle(BuildContext context) {
return TextStyle(
color: Theme.of(context).colorScheme.onSurface,
// TODO: change to colorSurface when its approved
// ignore: deprecated_member_use
color: Theme.of(context).colorScheme.onBackground,
fontWeight: FontWeight.bold,
backgroundColor: CssColor.fromCss('gold'),
);
Expand Down
4 changes: 3 additions & 1 deletion lib/widgets/layouts/login_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ class LoginScaffold extends StatelessWidget {
if (isMobileMode) return scaffold;
return Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.onSurface,
// TODO: change to colorSurface when its approved
// ignore: deprecated_member_use
color: Theme.of(context).colorScheme.onBackground,
),
child: Center(
child: Padding(
Expand Down
8 changes: 6 additions & 2 deletions lib/widgets/lock_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ class LockScreenState extends State<LockScreen> {
),
body: Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
// TODO: change to colorSurface when its approved
// ignore: deprecated_member_use
color: Theme.of(context).colorScheme.background,
gradient: LinearGradient(
begin: Alignment.topRight,
end: Alignment.bottomLeft,
Expand All @@ -55,7 +57,9 @@ class LockScreenState extends State<LockScreen> {
Theme.of(context).secondaryHeaderColor.withAlpha(16),
Theme.of(context).primaryColor.withAlpha(16),
Theme.of(context).colorScheme.secondary.withAlpha(16),
Theme.of(context).colorScheme.surface.withAlpha(16),
// TODO: change to colorSurface when its approved
// ignore: deprecated_member_use
Theme.of(context).colorScheme.background.withAlpha(16),
],
),
),
Expand Down
2 changes: 1 addition & 1 deletion scripts/code_analyze.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh -ve
flutter pub get && flutter pub run build_runner build --delete-conflicting-outputs
dart format --set-exit-if-changed lib/ test/
flutter pub get
flutter pub get # In flutter 3.22, flutter gen-l10n is not working properly, so we need to run flutter pub get again
flutter analyze

0 comments on commit cb6cbbb

Please sign in to comment.