design: Column mode auto padding

This commit is contained in:
Christian Pauly 2021-04-09 18:26:44 +02:00
parent 0146767e8a
commit 75258271af
13 changed files with 1344 additions and 1239 deletions

View File

@ -10,6 +10,7 @@ import 'package:famedlysdk/famedlysdk.dart';
import 'package:file_picker_cross/file_picker_cross.dart'; import 'package:file_picker_cross/file_picker_cross.dart';
import 'package:fluffychat/views/widgets/chat_settings_popup_menu.dart'; import 'package:fluffychat/views/widgets/chat_settings_popup_menu.dart';
import 'package:fluffychat/views/widgets/content_banner.dart'; import 'package:fluffychat/views/widgets/content_banner.dart';
import 'package:fluffychat/views/widgets/max_width_body.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart'; import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:fluffychat/views/widgets/list_items/participant_list_item.dart'; import 'package:fluffychat/views/widgets/list_items/participant_list_item.dart';
import 'package:fluffychat/utils/matrix_locals.dart'; import 'package:fluffychat/utils/matrix_locals.dart';
@ -234,8 +235,10 @@ class _ChatDetailsState extends State<ChatDetails> {
), ),
), ),
], ],
body: ListView.builder( body: MaxWidthBody(
itemCount: members.length + 1 + (canRequestMoreMembers ? 1 : 0), child: ListView.builder(
itemCount:
members.length + 1 + (canRequestMoreMembers ? 1 : 0),
itemBuilder: (BuildContext context, int i) => i == 0 itemBuilder: (BuildContext context, int i) => i == 0
? Column( ? Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
@ -250,7 +253,8 @@ class _ChatDetailsState extends State<ChatDetails> {
child: Icon(Icons.edit_outlined), child: Icon(Icons.edit_outlined),
) )
: null, : null,
title: Text('${L10n.of(context).groupDescription}:', title: Text(
'${L10n.of(context).groupDescription}:',
style: TextStyle( style: TextStyle(
color: Theme.of(context).accentColor, color: Theme.of(context).accentColor,
fontWeight: FontWeight.bold)), fontWeight: FontWeight.bold)),
@ -261,8 +265,10 @@ class _ChatDetailsState extends State<ChatDetails> {
linkStyle: TextStyle(color: Colors.blueAccent), linkStyle: TextStyle(color: Colors.blueAccent),
textStyle: TextStyle( textStyle: TextStyle(
fontSize: 14, fontSize: 14,
color: color: Theme.of(context)
Theme.of(context).textTheme.bodyText2.color, .textTheme
.bodyText2
.color,
), ),
onLinkTap: (url) => onLinkTap: (url) =>
UrlLauncher(context, url).launchUrl(), UrlLauncher(context, url).launchUrl(),
@ -331,8 +337,8 @@ class _ChatDetailsState extends State<ChatDetails> {
await AdaptivePageLayout.of(context) await AdaptivePageLayout.of(context)
.pushNamed('/rooms/${room.id}/emotes'); .pushNamed('/rooms/${room.id}/emotes');
} else { } else {
await AdaptivePageLayout.of(context).pushNamed( await AdaptivePageLayout.of(context)
'/settings/emotes', .pushNamed('/settings/emotes',
arguments: {'room': room}); arguments: {'room': room});
} }
}, },
@ -362,12 +368,12 @@ class _ChatDetailsState extends State<ChatDetails> {
], ],
child: ListTile( child: ListTile(
leading: CircleAvatar( leading: CircleAvatar(
backgroundColor: backgroundColor: Theme.of(context)
Theme.of(context).scaffoldBackgroundColor, .scaffoldBackgroundColor,
foregroundColor: Colors.grey, foregroundColor: Colors.grey,
child: Icon(Icons.public_outlined)), child: Icon(Icons.public_outlined)),
title: Text( title: Text(L10n.of(context)
L10n.of(context).whoIsAllowedToJoinThisGroup), .whoIsAllowedToJoinThisGroup),
subtitle: Text( subtitle: Text(
room.joinRules.getLocalizedString( room.joinRules.getLocalizedString(
MatrixLocals(L10n.of(context))), MatrixLocals(L10n.of(context))),
@ -375,11 +381,12 @@ class _ChatDetailsState extends State<ChatDetails> {
), ),
), ),
PopupMenuButton( PopupMenuButton(
onSelected: (HistoryVisibility historyVisibility) => onSelected:
(HistoryVisibility historyVisibility) =>
showFutureLoadingDialog( showFutureLoadingDialog(
context: context, context: context,
future: () => future: () => room
room.setHistoryVisibility(historyVisibility), .setHistoryVisibility(historyVisibility),
), ),
itemBuilder: (BuildContext context) => itemBuilder: (BuildContext context) =>
<PopupMenuEntry<HistoryVisibility>>[ <PopupMenuEntry<HistoryVisibility>>[
@ -419,8 +426,8 @@ class _ChatDetailsState extends State<ChatDetails> {
foregroundColor: Colors.grey, foregroundColor: Colors.grey,
child: Icon(Icons.visibility_outlined), child: Icon(Icons.visibility_outlined),
), ),
title: Text( title: Text(L10n.of(context)
L10n.of(context).visibilityOfTheChatHistory), .visibilityOfTheChatHistory),
subtitle: Text( subtitle: Text(
room.historyVisibility.getLocalizedString( room.historyVisibility.getLocalizedString(
MatrixLocals(L10n.of(context))), MatrixLocals(L10n.of(context))),
@ -432,7 +439,8 @@ class _ChatDetailsState extends State<ChatDetails> {
onSelected: (GuestAccess guestAccess) => onSelected: (GuestAccess guestAccess) =>
showFutureLoadingDialog( showFutureLoadingDialog(
context: context, context: context,
future: () => room.setGuestAccess(guestAccess), future: () =>
room.setGuestAccess(guestAccess),
), ),
itemBuilder: (BuildContext context) => itemBuilder: (BuildContext context) =>
<PopupMenuEntry<GuestAccess>>[ <PopupMenuEntry<GuestAccess>>[
@ -448,15 +456,16 @@ class _ChatDetailsState extends State<ChatDetails> {
PopupMenuItem<GuestAccess>( PopupMenuItem<GuestAccess>(
value: GuestAccess.forbidden, value: GuestAccess.forbidden,
child: Text( child: Text(
GuestAccess.forbidden.getLocalizedString( GuestAccess.forbidden
.getLocalizedString(
MatrixLocals(L10n.of(context))), MatrixLocals(L10n.of(context))),
), ),
), ),
], ],
child: ListTile( child: ListTile(
leading: CircleAvatar( leading: CircleAvatar(
backgroundColor: backgroundColor: Theme.of(context)
Theme.of(context).scaffoldBackgroundColor, .scaffoldBackgroundColor,
foregroundColor: Colors.grey, foregroundColor: Colors.grey,
child: Icon(Icons.info_outline), child: Icon(Icons.info_outline),
), ),
@ -470,8 +479,8 @@ class _ChatDetailsState extends State<ChatDetails> {
), ),
ListTile( ListTile(
title: Text(L10n.of(context).editChatPermissions), title: Text(L10n.of(context).editChatPermissions),
subtitle: subtitle: Text(
Text(L10n.of(context).whoCanPerformWhichAction), L10n.of(context).whoCanPerformWhichAction),
leading: CircleAvatar( leading: CircleAvatar(
backgroundColor: backgroundColor:
Theme.of(context).scaffoldBackgroundColor, Theme.of(context).scaffoldBackgroundColor,
@ -529,6 +538,7 @@ class _ChatDetailsState extends State<ChatDetails> {
), ),
), ),
), ),
),
); );
}); });
} }

View File

@ -2,6 +2,7 @@ import 'package:famedlysdk/encryption.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/views/widgets/avatar.dart'; import 'package:fluffychat/views/widgets/avatar.dart';
import 'package:fluffychat/views/widgets/matrix.dart'; import 'package:fluffychat/views/widgets/matrix.dart';
import 'package:fluffychat/views/widgets/max_width_body.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
import '../views/widgets/dialogs/key_verification_dialog.dart'; import '../views/widgets/dialogs/key_verification_dialog.dart';
@ -81,7 +82,9 @@ class _ChatEncryptionSettingsState extends State<ChatEncryptionSettings> {
), ),
), ),
), ),
body: StreamBuilder( body: MaxWidthBody(
withScrolling: true,
child: StreamBuilder(
stream: room.onUpdate.stream, stream: room.onUpdate.stream,
builder: (context, snapshot) { builder: (context, snapshot) {
return FutureBuilder<List<DeviceKeys>>( return FutureBuilder<List<DeviceKeys>>(
@ -99,19 +102,24 @@ class _ChatEncryptionSettingsState extends State<ChatEncryptionSettings> {
} }
final deviceKeys = snapshot.data; final deviceKeys = snapshot.data;
return ListView.builder( return ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: deviceKeys.length, itemCount: deviceKeys.length,
itemBuilder: (BuildContext context, int i) => Column( itemBuilder: (BuildContext context, int i) => Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
if (i == 0 || if (i == 0 ||
deviceKeys[i].userId != deviceKeys[i - 1].userId) ...{ deviceKeys[i].userId !=
deviceKeys[i - 1].userId) ...{
Divider(height: 1, thickness: 1), Divider(height: 1, thickness: 1),
PopupMenuButton( PopupMenuButton(
onSelected: (action) => onSelected: (action) =>
onSelected(context, action, deviceKeys[i]), onSelected(context, action, deviceKeys[i]),
itemBuilder: (c) { itemBuilder: (c) {
var items = <PopupMenuEntry<String>>[]; var items = <PopupMenuEntry<String>>[];
if (room.client.userDeviceKeys[deviceKeys[i].userId] if (room
.client
.userDeviceKeys[deviceKeys[i].userId]
.verified == .verified ==
UserVerifiedStatus.unknown) { UserVerifiedStatus.unknown) {
items.add(PopupMenuItem( items.add(PopupMenuItem(
@ -162,7 +170,8 @@ class _ChatEncryptionSettingsState extends State<ChatEncryptionSettings> {
if (deviceKeys[i].blocked || if (deviceKeys[i].blocked ||
!deviceKeys[i].verified) { !deviceKeys[i].verified) {
items.add(PopupMenuItem( items.add(PopupMenuItem(
value: deviceKeys[i].userId == room.client.userID value:
deviceKeys[i].userId == room.client.userID
? 'verify' ? 'verify'
: 'verify_user', : 'verify_user',
child: Text(L10n.of(context).verifyStart), child: Text(L10n.of(context).verifyStart),
@ -234,6 +243,7 @@ class _ChatEncryptionSettingsState extends State<ChatEncryptionSettings> {
}, },
); );
}), }),
),
); );
} }
} }

View File

@ -3,6 +3,7 @@ import 'dart:developer';
import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:adaptive_page_layout/adaptive_page_layout.dart'; import 'package:adaptive_page_layout/adaptive_page_layout.dart';
import 'package:fluffychat/views/widgets/dialogs/permission_slider_dialog.dart'; import 'package:fluffychat/views/widgets/dialogs/permission_slider_dialog.dart';
import 'package:fluffychat/views/widgets/max_width_body.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart'; import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:fluffychat/views/widgets/matrix.dart'; import 'package:fluffychat/views/widgets/matrix.dart';
@ -52,12 +53,14 @@ class ChatPermissionsSettings extends StatelessWidget {
leading: BackButton(), leading: BackButton(),
title: Text(L10n.of(context).editChatPermissions), title: Text(L10n.of(context).editChatPermissions),
), ),
body: StreamBuilder( body: MaxWidthBody(
withScrolling: true,
child: StreamBuilder(
stream: Matrix.of(context).client.onSync.stream.where( stream: Matrix.of(context).client.onSync.stream.where(
(e) => (e) =>
(e?.rooms?.join?.containsKey(roomId) ?? false) && (e?.rooms?.join?.containsKey(roomId) ?? false) &&
(e.rooms.join[roomId]?.timeline?.events (e.rooms.join[roomId]?.timeline?.events?.any(
?.any((s) => s.type == EventTypes.RoomPowerLevels) ?? (s) => s.type == EventTypes.RoomPowerLevels) ??
false), false),
), ),
builder: (context, _) { builder: (context, _) {
@ -70,7 +73,7 @@ class ChatPermissionsSettings extends StatelessWidget {
Map<String, dynamic>.from(powerLevelsContent['events']) Map<String, dynamic>.from(powerLevelsContent['events'])
..removeWhere((k, v) => !(v is int)); ..removeWhere((k, v) => !(v is int));
return ListView( return Column(
children: [ children: [
Column( Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
@ -94,8 +97,8 @@ class ChatPermissionsSettings extends StatelessWidget {
), ),
Builder(builder: (context) { Builder(builder: (context) {
final key = 'rooms'; final key = 'rooms';
final int value = final int value = powerLevelsContent
powerLevelsContent.containsKey('notifications') .containsKey('notifications')
? powerLevelsContent['notifications']['rooms'] ?? 0 ? powerLevelsContent['notifications']['rooms'] ?? 0
: 0; : 0;
return PermissionsListTile( return PermissionsListTile(
@ -168,7 +171,8 @@ class ChatPermissionsSettings extends StatelessWidget {
context: context, context: context,
future: () => future: () =>
room.client.upgradeRoom(roomId, newVersion), room.client.upgradeRoom(roomId, newVersion),
).then((_) => AdaptivePageLayout.of(context).pop()); ).then(
(_) => AdaptivePageLayout.of(context).pop());
}, },
); );
}, },
@ -180,6 +184,7 @@ class ChatPermissionsSettings extends StatelessWidget {
); );
}, },
), ),
),
); );
} }
} }

View File

@ -5,6 +5,7 @@ import 'package:fluffychat/views/widgets/default_app_bar_search_field.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/views/widgets/avatar.dart'; import 'package:fluffychat/views/widgets/avatar.dart';
import 'package:fluffychat/views/widgets/max_width_body.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart'; import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:fluffychat/views/widgets/matrix.dart'; import 'package:fluffychat/views/widgets/matrix.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -128,8 +129,12 @@ class _InvitationSelectionState extends State<InvitationSelection> {
onChanged: (String text) => searchUserWithCoolDown(context, text), onChanged: (String text) => searchUserWithCoolDown(context, text),
), ),
), ),
body: foundProfiles.isNotEmpty body: MaxWidthBody(
withScrolling: true,
child: foundProfiles.isNotEmpty
? ListView.builder( ? ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: foundProfiles.length, itemCount: foundProfiles.length,
itemBuilder: (BuildContext context, int i) => ListTile( itemBuilder: (BuildContext context, int i) => ListTile(
leading: Avatar( leading: Avatar(
@ -154,6 +159,8 @@ class _InvitationSelectionState extends State<InvitationSelection> {
} }
var contacts = snapshot.data; var contacts = snapshot.data;
return ListView.builder( return ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: contacts.length, itemCount: contacts.length,
itemBuilder: (BuildContext context, int i) => ListTile( itemBuilder: (BuildContext context, int i) => ListTile(
leading: Avatar( leading: Avatar(
@ -167,6 +174,7 @@ class _InvitationSelectionState extends State<InvitationSelection> {
); );
}, },
), ),
),
); );
} }
} }

View File

@ -1,5 +1,6 @@
import 'package:adaptive_page_layout/adaptive_page_layout.dart'; import 'package:adaptive_page_layout/adaptive_page_layout.dart';
import 'package:famedlysdk/famedlysdk.dart' as sdk; import 'package:famedlysdk/famedlysdk.dart' as sdk;
import 'package:fluffychat/views/widgets/max_width_body.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart'; import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:fluffychat/views/widgets/matrix.dart'; import 'package:fluffychat/views/widgets/matrix.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -45,7 +46,8 @@ class _NewGroupState extends State<NewGroup> {
title: Text(L10n.of(context).createNewGroup), title: Text(L10n.of(context).createNewGroup),
elevation: 0, elevation: 0,
), ),
body: Column( body: MaxWidthBody(
child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
Padding( Padding(
@ -72,6 +74,7 @@ class _NewGroupState extends State<NewGroup> {
), ),
], ],
), ),
),
floatingActionButton: FloatingActionButton( floatingActionButton: FloatingActionButton(
onPressed: () => submitAction(context), onPressed: () => submitAction(context),
child: Icon(Icons.arrow_forward_outlined), child: Icon(Icons.arrow_forward_outlined),

View File

@ -4,6 +4,7 @@ import 'package:adaptive_page_layout/adaptive_page_layout.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/views/widgets/avatar.dart'; import 'package:fluffychat/views/widgets/avatar.dart';
import 'package:fluffychat/views/widgets/contacts_list.dart'; import 'package:fluffychat/views/widgets/contacts_list.dart';
import 'package:fluffychat/views/widgets/max_width_body.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart'; import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:fluffychat/views/widgets/matrix.dart'; import 'package:fluffychat/views/widgets/matrix.dart';
import 'package:fluffychat/utils/fluffy_share.dart'; import 'package:fluffychat/utils/fluffy_share.dart';
@ -101,7 +102,8 @@ class _NewPrivateChatState extends State<NewPrivateChat> {
) )
], ],
), ),
body: Column( body: MaxWidthBody(
child: Column(
children: <Widget>[ children: <Widget>[
Padding( Padding(
padding: const EdgeInsets.all(12.0), padding: const EdgeInsets.all(12.0),
@ -145,7 +147,8 @@ class _NewPrivateChatState extends State<NewPrivateChat> {
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Avatar( child: Avatar(
foundProfile.avatarUrl, foundProfile.avatarUrl,
foundProfile.displayname ?? foundProfile.userId, foundProfile.displayname ??
foundProfile.userId,
size: 12, size: 12,
), ),
) )
@ -198,7 +201,8 @@ class _NewPrivateChatState extends State<NewPrivateChat> {
//size: 24, //size: 24,
), ),
title: Text( title: Text(
foundProfile.displayname ?? foundProfile.userId.localpart, foundProfile.displayname ??
foundProfile.userId.localpart,
style: TextStyle(), style: TextStyle(),
maxLines: 1, maxLines: 1,
), ),
@ -219,6 +223,7 @@ class _NewPrivateChatState extends State<NewPrivateChat> {
), ),
], ],
), ),
),
); );
} }
} }

View File

@ -1,5 +1,6 @@
import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/views/widgets/max_width_body.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart'; import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:fluffychat/views/widgets/matrix.dart'; import 'package:fluffychat/views/widgets/matrix.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -99,7 +100,8 @@ class _Settings3PidState extends State<Settings3Pid> {
) )
], ],
), ),
body: FutureBuilder<List<ThirdPartyIdentifier>>( body: MaxWidthBody(
child: FutureBuilder<List<ThirdPartyIdentifier>>(
future: _request, future: _request,
builder: (BuildContext context, builder: (BuildContext context,
AsyncSnapshot<List<ThirdPartyIdentifier>> snapshot) { AsyncSnapshot<List<ThirdPartyIdentifier>> snapshot) {
@ -131,7 +133,8 @@ class _Settings3PidState extends State<Settings3Pid> {
title: Text( title: Text(
identifier.isEmpty identifier.isEmpty
? L10n.of(context).noPasswordRecoveryDescription ? L10n.of(context).noPasswordRecoveryDescription
: L10n.of(context).withTheseAddressesRecoveryDescription, : L10n.of(context)
.withTheseAddressesRecoveryDescription,
), ),
), ),
Divider(height: 1), Divider(height: 1),
@ -158,6 +161,7 @@ class _Settings3PidState extends State<Settings3Pid> {
); );
}, },
), ),
),
); );
} }
} }

View File

@ -2,6 +2,7 @@ import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:famedlysdk/encryption/utils/key_verification.dart'; import 'package:famedlysdk/encryption/utils/key_verification.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/views/widgets/dialogs/key_verification_dialog.dart'; import 'package:fluffychat/views/widgets/dialogs/key_verification_dialog.dart';
import 'package:fluffychat/views/widgets/max_width_body.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart'; import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
@ -131,7 +132,8 @@ class DevicesSettingsState extends State<DevicesSettings> {
leading: BackButton(), leading: BackButton(),
title: Text(L10n.of(context).devices), title: Text(L10n.of(context).devices),
), ),
body: FutureBuilder<bool>( body: MaxWidthBody(
child: FutureBuilder<bool>(
future: _loadUserDevices(context), future: _loadUserDevices(context),
builder: (BuildContext context, snapshot) { builder: (BuildContext context, snapshot) {
if (snapshot.hasError) { if (snapshot.hasError) {
@ -151,7 +153,8 @@ class DevicesSettingsState extends State<DevicesSettings> {
Function isOwnDevice = (Device userDevice) => Function isOwnDevice = (Device userDevice) =>
userDevice.deviceId == Matrix.of(context).client.deviceID; userDevice.deviceId == Matrix.of(context).client.deviceID;
final devices = List<Device>.from(this.devices); final devices = List<Device>.from(this.devices);
var thisDevice = devices.firstWhere(isOwnDevice, orElse: () => null); var thisDevice =
devices.firstWhere(isOwnDevice, orElse: () => null);
devices.removeWhere(isOwnDevice); devices.removeWhere(isOwnDevice);
devices.sort((a, b) => b.lastSeenTs.compareTo(a.lastSeenTs)); devices.sort((a, b) => b.lastSeenTs.compareTo(a.lastSeenTs));
return Column( return Column(
@ -209,6 +212,7 @@ class DevicesSettingsState extends State<DevicesSettings> {
); );
}, },
), ),
),
); );
} }
} }

View File

@ -6,6 +6,7 @@ import 'package:famedlysdk/famedlysdk.dart';
import 'package:file_picker_cross/file_picker_cross.dart'; import 'package:file_picker_cross/file_picker_cross.dart';
import 'package:fluffychat/utils/platform_infos.dart'; import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/views/widgets/max_width_body.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
@ -184,7 +185,8 @@ class _EmotesSettingsState extends State<EmotesSettings> {
child: Icon(Icons.save_outlined, color: Colors.white), child: Icon(Icons.save_outlined, color: Colors.white),
) )
: null, : null,
body: StreamBuilder( body: MaxWidthBody(
child: StreamBuilder(
stream: widget.room?.onUpdate?.stream, stream: widget.room?.onUpdate?.stream,
builder: (context, snapshot) { builder: (context, snapshot) {
return Column( return Column(
@ -324,7 +326,8 @@ class _EmotesSettingsState extends State<EmotesSettings> {
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: borderRadius:
BorderRadius.all(Radius.circular(10)), BorderRadius.all(Radius.circular(10)),
color: Theme.of(context).secondaryHeaderColor, color:
Theme.of(context).secondaryHeaderColor,
), ),
child: TextField( child: TextField(
readOnly: readonly, readOnly: readonly,
@ -366,7 +369,8 @@ class _EmotesSettingsState extends State<EmotesSettings> {
controller.text = emote.emoteClean; controller.text = emote.emoteClean;
showOkAlertDialog( showOkAlertDialog(
context: context, context: context,
message: L10n.of(context).emoteInvalid, message:
L10n.of(context).emoteInvalid,
okLabel: L10n.of(context).ok, okLabel: L10n.of(context).ok,
useRootNavigator: false, useRootNavigator: false,
); );
@ -401,6 +405,7 @@ class _EmotesSettingsState extends State<EmotesSettings> {
], ],
); );
}), }),
),
); );
} }
} }

View File

@ -1,5 +1,6 @@
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/views/widgets/avatar.dart'; import 'package:fluffychat/views/widgets/avatar.dart';
import 'package:fluffychat/views/widgets/max_width_body.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart'; import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
@ -45,7 +46,8 @@ class _SettingsIgnoreListState extends State<SettingsIgnoreList> {
leading: BackButton(), leading: BackButton(),
title: Text(L10n.of(context).ignoredUsers), title: Text(L10n.of(context).ignoredUsers),
), ),
body: Column( body: MaxWidthBody(
child: Column(
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
@ -93,8 +95,8 @@ class _SettingsIgnoreListState extends State<SettingsIgnoreList> {
s.data?.avatarUrl ?? Uri.parse(''), s.data?.avatarUrl ?? Uri.parse(''),
s.data?.displayname ?? client.ignoredUsers[i], s.data?.displayname ?? client.ignoredUsers[i],
), ),
title: title: Text(
Text(s.data?.displayname ?? client.ignoredUsers[i]), s.data?.displayname ?? client.ignoredUsers[i]),
trailing: IconButton( trailing: IconButton(
tooltip: L10n.of(context).delete, tooltip: L10n.of(context).delete,
icon: Icon(Icons.delete_forever_outlined), icon: Icon(Icons.delete_forever_outlined),
@ -111,6 +113,7 @@ class _SettingsIgnoreListState extends State<SettingsIgnoreList> {
), ),
], ],
), ),
),
); );
} }
} }

View File

@ -1,6 +1,7 @@
import 'dart:io'; import 'dart:io';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/views/widgets/max_width_body.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart'; import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:fluffychat/config/app_config.dart'; import 'package:fluffychat/config/app_config.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
@ -113,25 +114,28 @@ class SettingsNotifications extends StatelessWidget {
leading: BackButton(), leading: BackButton(),
title: Text(L10n.of(context).notifications), title: Text(L10n.of(context).notifications),
), ),
body: StreamBuilder( body: MaxWidthBody(
withScrolling: true,
child: StreamBuilder(
stream: Matrix.of(context) stream: Matrix.of(context)
.client .client
.onAccountData .onAccountData
.stream .stream
.where((event) => event.type == 'm.push_rules'), .where((event) => event.type == 'm.push_rules'),
builder: (BuildContext context, _) { builder: (BuildContext context, _) {
return ListView( return Column(
children: [ children: [
SwitchListTile( SwitchListTile(
value: !Matrix.of(context).client.allPushNotificationsMuted, value: !Matrix.of(context).client.allPushNotificationsMuted,
title: title: Text(
Text(L10n.of(context).notificationsEnabledForThisAccount), L10n.of(context).notificationsEnabledForThisAccount),
onChanged: (_) => showFutureLoadingDialog( onChanged: (_) => showFutureLoadingDialog(
context: context, context: context,
future: () => Matrix.of(context) future: () =>
Matrix.of(context).client.setMuteAllPushNotifications(
!Matrix.of(context)
.client .client
.setMuteAllPushNotifications( .allPushNotificationsMuted,
!Matrix.of(context).client.allPushNotificationsMuted,
), ),
), ),
), ),
@ -204,6 +208,7 @@ class SettingsNotifications extends StatelessWidget {
], ],
); );
}), }),
),
); );
} }
} }

View File

@ -2,6 +2,7 @@ import 'dart:io';
import 'package:adaptive_theme/adaptive_theme.dart'; import 'package:adaptive_theme/adaptive_theme.dart';
import 'package:fluffychat/config/setting_keys.dart'; import 'package:fluffychat/config/setting_keys.dart';
import 'package:fluffychat/views/widgets/max_width_body.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:image_picker/image_picker.dart'; import 'package:image_picker/image_picker.dart';
@ -56,7 +57,9 @@ class _SettingsStyleState extends State<SettingsStyle> {
leading: BackButton(), leading: BackButton(),
title: Text(L10n.of(context).changeTheme), title: Text(L10n.of(context).changeTheme),
), ),
body: ListView( body: MaxWidthBody(
withScrolling: true,
child: Column(
children: [ children: [
RadioListTile<AdaptiveThemeMode>( RadioListTile<AdaptiveThemeMode>(
groupValue: _currentTheme, groupValue: _currentTheme,
@ -121,7 +124,8 @@ class _SettingsStyleState extends State<SettingsStyle> {
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: Container( child: Container(
margin: const EdgeInsets.symmetric(horizontal: 16), margin: const EdgeInsets.symmetric(horizontal: 16),
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 10), padding:
const EdgeInsets.symmetric(vertical: 6, horizontal: 10),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Theme.of(context).secondaryHeaderColor, color: Theme.of(context).secondaryHeaderColor,
borderRadius: BorderRadius.circular(16), borderRadius: BorderRadius.circular(16),
@ -151,6 +155,7 @@ class _SettingsStyleState extends State<SettingsStyle> {
), ),
], ],
), ),
),
); );
} }
} }

View File

@ -0,0 +1,38 @@
import 'dart:math';
import 'package:flutter/material.dart';
class MaxWidthBody extends StatelessWidget {
final Widget child;
final double maxWidth;
final bool withScrolling;
const MaxWidthBody({
this.child,
this.maxWidth = 600,
this.withScrolling = false,
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) {
final padding = EdgeInsets.symmetric(
horizontal: max(0, (constraints.maxWidth - maxWidth) / 2),
);
return withScrolling
? SingleChildScrollView(
physics: ScrollPhysics(),
child: Padding(
padding: padding,
child: child,
),
)
: Padding(
padding: padding,
child: child,
);
},
);
}
}