Skip to content

Commit

Permalink
TW-1308: remove back button in setting in web
Browse files Browse the repository at this point in the history
  • Loading branch information
sherlockvn authored and hoangdat committed Jan 12, 2024
1 parent 26c42da commit 10cd42a
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 17 deletions.
9 changes: 6 additions & 3 deletions lib/pages/device_settings/device_settings_view.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:fluffychat/pages/settings_dashboard/settings/settings_app_bar.dart';
import 'package:flutter/material.dart';

import 'package:flutter_gen/gen_l10n/l10n.dart';
Expand All @@ -14,9 +15,11 @@ class DevicesSettingsView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: const BackButton(),
title: Text(L10n.of(context)!.devices),
appBar: SettingsAppBar(
context: context,
title: Text(
L10n.of(context)!.deviceKeys,
),
),
body: MaxWidthBody(
child: FutureBuilder<bool>(
Expand Down
34 changes: 34 additions & 0 deletions lib/pages/settings_dashboard/settings/settings_app_bar.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/di/global/get_it_initializer.dart';
import 'package:fluffychat/utils/responsive/responsive_utils.dart';
import 'package:flutter/material.dart';

class SettingsAppBar extends StatelessWidget implements PreferredSizeWidget {
final Widget? title;

final BuildContext context;

final List<Widget>? actions;

const SettingsAppBar({
super.key,
required this.title,
required this.context,
this.actions,
});

@override
Widget build(BuildContext context) {
final responsiveUtils = getIt.get<ResponsiveUtils>();
return AppBar(
title: title,
leading: responsiveUtils.isMobile(context)
? const BackButton()
: const SizedBox.shrink(),
actions: actions,
);
}

@override
Size get preferredSize => Size.fromHeight(AppConfig.toolbarHeight(context));
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:fluffychat/pages/settings_dashboard/settings/settings_app_bar.dart';
import 'package:fluffychat/pages/settings_dashboard/settings_3pid/settings_3pid.dart';
import 'package:flutter/material.dart';

Expand All @@ -16,8 +17,7 @@ class Settings3PidView extends StatelessWidget {
Widget build(BuildContext context) {
controller.request ??= Matrix.of(context).client.getAccount3PIDs();
return Scaffold(
appBar: AppBar(
leading: const BackButton(),
appBar: SettingsAppBar(
title: Text(L10n.of(context)!.passwordRecovery),
actions: [
IconButton(
Expand All @@ -26,6 +26,7 @@ class Settings3PidView extends StatelessWidget {
tooltip: L10n.of(context)!.addEmail,
),
],
context: context,
),
body: MaxWidthBody(
child: FutureBuilder<List<ThirdPartyIdentifier>?>(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:fluffychat/pages/settings_dashboard/settings/settings_app_bar.dart';
import 'package:fluffychat/pages/settings_dashboard/settings_app_language/settings_app_language.dart';
import 'package:fluffychat/pages/settings_dashboard/settings_app_language/settings_app_language_view_style.dart';
import 'package:fluffychat/presentation/extensions/localizations/locale_extension.dart';
Expand All @@ -16,12 +17,12 @@ class SettingsAppLanguageView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: const BackButton(),
appBar: SettingsAppBar(
title: Text(
L10n.of(context)!.appLanguage,
style: Theme.of(context).textTheme.titleLarge,
),
context: context,
),
body: SingleChildScrollView(
padding: SettingsAppLanguageViewStyle.paddingBody,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/config/setting_keys.dart';
import 'package:fluffychat/pages/settings_dashboard/settings/settings_app_bar.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/utils/voip/callkeep_manager.dart';
import 'package:fluffychat/widgets/layouts/max_width_body.dart';
Expand All @@ -19,7 +20,10 @@ class SettingsChatView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(L10n.of(context)!.chat)),
appBar: SettingsAppBar(
title: Text(L10n.of(context)!.chat),
context: context,
),
body: ListTileTheme(
iconColor: Theme.of(context).textTheme.bodyLarge!.color,
child: MaxWidthBody(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:fluffychat/pages/settings_dashboard/settings/settings_app_bar.dart';
import 'package:fluffychat/widgets/matrix.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand All @@ -20,9 +21,9 @@ class EmotesSettingsView extends StatelessWidget {
final client = Matrix.of(context).client;
final imageKeys = controller.pack!.images.keys.toList();
return Scaffold(
appBar: AppBar(
leading: const BackButton(),
appBar: SettingsAppBar(
title: Text(L10n.of(context)!.emoteSettings),
context: context,
),
floatingActionButton: controller.showSave
? FloatingActionButton(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:fluffychat/pages/settings_dashboard/settings/settings_app_bar.dart';
import 'package:fluffychat/utils/dialog/twake_dialog.dart';
import 'package:fluffychat/widgets/matrix.dart';
import 'package:flutter/material.dart';
Expand All @@ -19,9 +20,9 @@ class SettingsIgnoreListView extends StatelessWidget {
Widget build(BuildContext context) {
final client = Matrix.of(context).client;
return Scaffold(
appBar: AppBar(
leading: const BackButton(),
appBar: SettingsAppBar(
title: Text(L10n.of(context)!.ignoredUsers),
context: context,
),
body: MaxWidthBody(
child: Column(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:fluffychat/pages/settings_dashboard/settings/settings_app_bar.dart';
import 'package:flutter/material.dart';

import 'package:flutter_gen/gen_l10n/l10n.dart';
Expand All @@ -17,9 +18,9 @@ class MultipleEmotesSettingsView extends StatelessWidget {
Widget build(BuildContext context) {
final room = Matrix.of(context).client.getRoomById(controller.roomId!)!;
return Scaffold(
appBar: AppBar(
leading: const BackButton(),
appBar: SettingsAppBar(
title: Text(L10n.of(context)!.emotePacks),
context: context,
),
body: StreamBuilder(
stream: room.onUpdate.stream,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:fluffychat/pages/settings_dashboard/settings/settings_app_bar.dart';
import 'package:fluffychat/utils/dialog/twake_dialog.dart';
import 'package:fluffychat/utils/localized_exception_extension.dart';
import 'package:fluffychat/widgets/matrix.dart';
Expand All @@ -19,9 +20,9 @@ class SettingsNotificationsView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: const BackButton(),
appBar: SettingsAppBar(
title: Text(L10n.of(context)!.notifications),
context: context,
),
body: MaxWidthBody(
withScrolling: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:fluffychat/pages/settings_dashboard/settings/settings_app_bar.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:fluffychat/utils/beautify_string_extension.dart';
Expand All @@ -13,7 +14,10 @@ class SettingsSecurityView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(L10n.of(context)!.security)),
appBar: SettingsAppBar(
title: Text(L10n.of(context)!.security),
context: context,
),
body: ListTileTheme(
iconColor: Theme.of(context).colorScheme.onBackground,
child: MaxWidthBody(
Expand Down

0 comments on commit 10cd42a

Please sign in to comment.