Merge branch 'krille/apl' into 'main'

fix: Minor apl bugs

See merge request famedly/fluffychat!339
This commit is contained in:
Krille Fear 2021-01-16 13:24:52 +00:00
commit e09782f0a4
22 changed files with 170 additions and 135 deletions

View File

@ -114,8 +114,10 @@ class _ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
startCallAction(context); startCallAction(context);
break; break;
case 'details': case 'details':
await AdaptivePageLayout.of(context).pushNamedAndRemoveAllOthers( if (AdaptivePageLayout.of(context).viewDataStack.length < 3) {
'/rooms/${widget.room.id}/details'); await AdaptivePageLayout.of(context)
.pushNamed('/rooms/${widget.room.id}/details');
}
break; break;
} }

View File

@ -82,7 +82,7 @@ class FluffyRoutes {
case 'rooms': case 'rooms':
if (parts.length == 3) { if (parts.length == 3) {
return ViewData( return ViewData(
leftView: (_) => ChatList(), leftView: (_) => ChatList(activeChat: parts[2]),
mainView: (_) => Chat(parts[2]), mainView: (_) => Chat(parts[2]),
); );
} else if (parts.length == 4) { } else if (parts.length == 4) {
@ -91,31 +91,31 @@ class FluffyRoutes {
switch (action) { switch (action) {
case 'details': case 'details':
return ViewData( return ViewData(
leftView: (_) => ChatList(), leftView: (_) => ChatList(activeChat: parts[2]),
mainView: (_) => Chat(parts[2]), mainView: (_) => Chat(parts[2]),
rightView: (_) => ChatDetails(roomId), rightView: (_) => ChatDetails(roomId),
); );
case 'encryption': case 'encryption':
return ViewData( return ViewData(
leftView: (_) => ChatList(), leftView: (_) => ChatList(activeChat: parts[2]),
mainView: (_) => Chat(parts[2]), mainView: (_) => Chat(parts[2]),
rightView: (_) => ChatEncryptionSettings(roomId), rightView: (_) => ChatEncryptionSettings(roomId),
); );
case 'permissions': case 'permissions':
return ViewData( return ViewData(
leftView: (_) => ChatList(), leftView: (_) => ChatList(activeChat: parts[2]),
mainView: (_) => Chat(parts[2]), mainView: (_) => Chat(parts[2]),
rightView: (_) => ChatPermissionsSettings(roomId), rightView: (_) => ChatPermissionsSettings(roomId),
); );
case 'invite': case 'invite':
return ViewData( return ViewData(
leftView: (_) => ChatList(), leftView: (_) => ChatList(activeChat: parts[2]),
mainView: (_) => Chat(parts[2]), mainView: (_) => Chat(parts[2]),
rightView: (_) => InvitationSelection(roomId), rightView: (_) => InvitationSelection(roomId),
); );
case 'emotes': case 'emotes':
return ViewData( return ViewData(
leftView: (_) => ChatList(), leftView: (_) => ChatList(activeChat: parts[2]),
mainView: (_) => Chat(parts[2]), mainView: (_) => Chat(parts[2]),
rightView: (_) => MultipleEmotesSettings(roomId), rightView: (_) => MultipleEmotesSettings(roomId),
); );

View File

@ -36,6 +36,7 @@ class _ArchiveState extends State<Archive> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
leading: BackButton(),
title: Text(L10n.of(context).archive), title: Text(L10n.of(context).archive),
elevation: _scrolledToTop ? 0 : null, elevation: _scrolledToTop ? 0 : null,
), ),

View File

@ -472,7 +472,8 @@ class _ChatState extends State<Chat> {
onPressed: () => setState(() => selectedEvents.clear()), onPressed: () => setState(() => selectedEvents.clear()),
) )
: null, : null,
titleSpacing: 0, titleSpacing:
AdaptivePageLayout.of(context).columnMode(context) ? null : 0,
title: selectedEvents.isEmpty title: selectedEvents.isEmpty
? StreamBuilder<Object>( ? StreamBuilder<Object>(
stream: room.onUpdate.stream, stream: room.onUpdate.stream,
@ -490,7 +491,12 @@ class _ChatState extends State<Chat> {
), ),
) )
: () => AdaptivePageLayout.of(context) : () => AdaptivePageLayout.of(context)
.pushNamed('/rooms/${room.id}/details'), .viewDataStack
.length <
3
? AdaptivePageLayout.of(context)
.pushNamed('/rooms/${room.id}/details')
: null,
title: Text( title: Text(
room.getLocalizedDisplayname( room.getLocalizedDisplayname(
MatrixLocals(L10n.of(context))), MatrixLocals(L10n.of(context))),

View File

@ -172,6 +172,7 @@ class _ChatDetailsState extends State<ChatDetails> {
if (room == null) { if (room == null) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
leading: BackButton(),
title: Text(L10n.of(context).oopsSomethingWentWrong), title: Text(L10n.of(context).oopsSomethingWentWrong),
), ),
body: Center( body: Center(
@ -192,6 +193,7 @@ class _ChatDetailsState extends State<ChatDetails> {
headerSliverBuilder: headerSliverBuilder:
(BuildContext context, bool innerBoxIsScrolled) => <Widget>[ (BuildContext context, bool innerBoxIsScrolled) => <Widget>[
SliverAppBar( SliverAppBar(
leading: BackButton(),
expandedHeight: 300.0, expandedHeight: 300.0,
floating: true, floating: true,
pinned: true, pinned: true,

View File

@ -91,6 +91,7 @@ class _ChatEncryptionSettingsState extends State<ChatEncryptionSettings> {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
leading: BackButton(),
title: Text(L10n.of(context).participatingUserDevices), title: Text(L10n.of(context).participatingUserDevices),
), ),
body: StreamBuilder( body: StreamBuilder(

View File

@ -45,7 +45,10 @@ class ChatPermissionsSettings extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar(title: Text(L10n.of(context).editChatPermissions)), appBar: AppBar(
leading: BackButton(),
title: Text(L10n.of(context).editChatPermissions),
),
body: StreamBuilder( body: StreamBuilder(
stream: Matrix.of(context).client.onSync.stream.where( stream: Matrix.of(context).client.onSync.stream.where(
(e) => (e) =>

View File

@ -122,6 +122,7 @@ class _DiscoverPageState extends State<DiscoverPage> {
); );
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
leading: BackButton(),
titleSpacing: 0, titleSpacing: 0,
elevation: _scrolledToTop ? 0 : null, elevation: _scrolledToTop ? 0 : null,
title: DefaultAppBarSearchField( title: DefaultAppBarSearchField(

View File

@ -123,6 +123,7 @@ class _InvitationSelectionState extends State<InvitationSelection> {
room.name?.isEmpty ?? false ? L10n.of(context).group : room.name; room.name?.isEmpty ?? false ? L10n.of(context).group : room.name;
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
leading: BackButton(),
titleSpacing: 0, titleSpacing: 0,
title: DefaultAppBarSearchField( title: DefaultAppBarSearchField(
autofocus: true, autofocus: true,

View File

@ -156,7 +156,7 @@ class _LoginState extends State<Login> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
leading: loading ? Container() : null, leading: loading ? Container() : BackButton(),
elevation: 0, elevation: 0,
title: Text( title: Text(
L10n.of(context).logInTo(Matrix.of(context) L10n.of(context).logInTo(Matrix.of(context)

View File

@ -40,6 +40,7 @@ class _NewGroupState extends State<NewGroup> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
leading: BackButton(),
title: Text(L10n.of(context).createNewGroup), title: Text(L10n.of(context).createNewGroup),
elevation: 0, elevation: 0,
), ),

View File

@ -85,6 +85,7 @@ class _NewPrivateChatState extends State<NewPrivateChat> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
leading: BackButton(),
title: Text(L10n.of(context).newPrivateChat), title: Text(L10n.of(context).newPrivateChat),
elevation: 0, elevation: 0,
), ),

View File

@ -260,21 +260,24 @@ class _SettingsState extends State<Settings> {
if (mounted) setState(() => profile = p); if (mounted) setState(() => profile = p);
return p; return p;
}); });
crossSigningCachedFuture ??= if (client.encryption != null) {
client.encryption.crossSigning.isCached().then((c) { crossSigningCachedFuture ??=
if (mounted) setState(() => crossSigningCached = c); client.encryption.crossSigning.isCached().then((c) {
return c; if (mounted) setState(() => crossSigningCached = c);
}); return c;
megolmBackupCachedFuture ??= });
client.encryption.keyManager.isCached().then((c) { megolmBackupCachedFuture ??=
if (mounted) setState(() => megolmBackupCached = c); client.encryption.keyManager.isCached().then((c) {
return c; if (mounted) setState(() => megolmBackupCached = c);
}); return c;
});
}
return Scaffold( return Scaffold(
body: NestedScrollView( body: NestedScrollView(
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) => headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) =>
<Widget>[ <Widget>[
SliverAppBar( SliverAppBar(
leading: BackButton(),
expandedHeight: 300.0, expandedHeight: 300.0,
floating: true, floating: true,
pinned: true, pinned: true,
@ -434,126 +437,128 @@ class _SettingsState extends State<Settings> {
), ),
onTap: () => _deleteAccountAction(context), onTap: () => _deleteAccountAction(context),
), ),
Divider(thickness: 1), if (client.encryption != null) ...{
ListTile( Divider(thickness: 1),
title: Text( ListTile(
L10n.of(context).encryption, title: Text(
style: TextStyle( L10n.of(context).encryption,
color: Theme.of(context).primaryColor, style: TextStyle(
fontWeight: FontWeight.bold, color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold,
),
), ),
), ),
), ListTile(
ListTile( trailing: Icon(Icons.compare_arrows_outlined),
trailing: Icon(Icons.compare_arrows_outlined), title: Text(client.encryption.crossSigning.enabled
title: Text(client.encryption.crossSigning.enabled ? L10n.of(context).crossSigningEnabled
? L10n.of(context).crossSigningEnabled : L10n.of(context).crossSigningDisabled),
: L10n.of(context).crossSigningDisabled), subtitle: client.encryption.crossSigning.enabled
subtitle: client.encryption.crossSigning.enabled ? Text(client.isUnknownSession
? Text(client.isUnknownSession ? L10n.of(context).unknownSessionVerify
? L10n.of(context).unknownSessionVerify : L10n.of(context).sessionVerified +
: L10n.of(context).sessionVerified + ', ' +
', ' + (crossSigningCached == null
(crossSigningCached == null ? ''
? '' : (crossSigningCached
: (crossSigningCached ? L10n.of(context).keysCached
? L10n.of(context).keysCached : L10n.of(context).keysMissing)))
: L10n.of(context).keysMissing))) : null,
: null, onTap: () async {
onTap: () async { if (!client.encryption.crossSigning.enabled) {
if (!client.encryption.crossSigning.enabled) { return BootstrapDialog().show(context);
return BootstrapDialog().show(context); }
} if (client.isUnknownSession) {
if (client.isUnknownSession) { final input = await showTextInputDialog(
final input = await showTextInputDialog( context: context,
context: context, title: L10n.of(context).askSSSSVerify,
title: L10n.of(context).askSSSSVerify, textFields: [
textFields: [ DialogTextField(
DialogTextField( hintText: L10n.of(context).passphraseOrKey,
hintText: L10n.of(context).passphraseOrKey, obscureText: true,
obscureText: true, minLines: 1,
minLines: 1, maxLines: 1,
maxLines: 1, )
) ],
], );
); if (input != null) {
if (input != null) { final valid = await showFutureLoadingDialog(
final valid = await showFutureLoadingDialog( context: context,
context: context, future: () async {
future: () async { // make sure the loading spinner shows before we test the keys
// make sure the loading spinner shows before we test the keys await Future.delayed(Duration(milliseconds: 100));
await Future.delayed(Duration(milliseconds: 100)); var valid = false;
var valid = false;
try {
await client.encryption.crossSigning
.selfSign(recoveryKey: input.single);
valid = true;
} catch (_) {
try { try {
await client.encryption.crossSigning await client.encryption.crossSigning
.selfSign(passphrase: input.single); .selfSign(recoveryKey: input.single);
valid = true; valid = true;
} catch (_) { } catch (_) {
valid = false; try {
await client.encryption.crossSigning
.selfSign(passphrase: input.single);
valid = true;
} catch (_) {
valid = false;
}
} }
} return valid;
return valid; });
});
if (valid.result == true) { if (valid.result == true) {
await showOkAlertDialog( await showOkAlertDialog(
context: context, context: context,
message: L10n.of(context).verifiedSession, message: L10n.of(context).verifiedSession,
); );
setState(() { setState(() {
crossSigningCachedFuture = null; crossSigningCachedFuture = null;
crossSigningCached = null; crossSigningCached = null;
megolmBackupCachedFuture = null; megolmBackupCachedFuture = null;
megolmBackupCached = null; megolmBackupCached = null;
}); });
} else { } else {
await showOkAlertDialog( await showOkAlertDialog(
context: context, context: context,
message: L10n.of(context).incorrectPassphraseOrKey, message: L10n.of(context).incorrectPassphraseOrKey,
); );
}
} }
} }
} if (!(await client.encryption.crossSigning.isCached())) {
if (!(await client.encryption.crossSigning.isCached())) { await requestSSSSCache(context);
await requestSSSSCache(context); }
} },
},
),
ListTile(
trailing: Icon(Icons.wb_cloudy_outlined),
title: Text(client.encryption.keyManager.enabled
? L10n.of(context).onlineKeyBackupEnabled
: L10n.of(context).onlineKeyBackupDisabled),
subtitle: client.encryption.keyManager.enabled
? Text(megolmBackupCached == null
? ''
: (megolmBackupCached
? L10n.of(context).keysCached
: L10n.of(context).keysMissing))
: null,
onTap: () async {
if (!client.encryption.keyManager.enabled) {
return BootstrapDialog().show(context);
}
if (!(await client.encryption.keyManager.isCached())) {
await requestSSSSCache(context);
}
},
),
ListTile(
title: Text(L10n.of(context).yourPublicKey),
onTap: () => showOkAlertDialog(
context: context,
title: L10n.of(context).yourPublicKey,
message: client.fingerprintKey.beautified,
), ),
trailing: Icon(Icons.vpn_key_outlined), ListTile(
), trailing: Icon(Icons.wb_cloudy_outlined),
title: Text(client.encryption.keyManager.enabled
? L10n.of(context).onlineKeyBackupEnabled
: L10n.of(context).onlineKeyBackupDisabled),
subtitle: client.encryption.keyManager.enabled
? Text(megolmBackupCached == null
? ''
: (megolmBackupCached
? L10n.of(context).keysCached
: L10n.of(context).keysMissing))
: null,
onTap: () async {
if (!client.encryption.keyManager.enabled) {
return BootstrapDialog().show(context);
}
if (!(await client.encryption.keyManager.isCached())) {
await requestSSSSCache(context);
}
},
),
ListTile(
title: Text(L10n.of(context).yourPublicKey),
onTap: () => showOkAlertDialog(
context: context,
title: L10n.of(context).yourPublicKey,
message: client.fingerprintKey.beautified,
),
trailing: Icon(Icons.vpn_key_outlined),
),
},
Divider(thickness: 1), Divider(thickness: 1),
ListTile( ListTile(
title: Text( title: Text(

View File

@ -95,6 +95,7 @@ class _Settings3PidState extends State<Settings3Pid> {
_request ??= Matrix.of(context).client.requestThirdPartyIdentifiers(); _request ??= Matrix.of(context).client.requestThirdPartyIdentifiers();
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
leading: BackButton(),
title: Text(L10n.of(context).passwordRecovery), title: Text(L10n.of(context).passwordRecovery),
actions: [ actions: [
IconButton( IconButton(

View File

@ -88,7 +88,10 @@ class DevicesSettingsState extends State<DevicesSettings> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar(title: Text(L10n.of(context).devices)), appBar: AppBar(
leading: BackButton(),
title: Text(L10n.of(context).devices),
),
body: FutureBuilder<bool>( body: FutureBuilder<bool>(
future: _loadUserDevices(context), future: _loadUserDevices(context),
builder: (BuildContext context, snapshot) { builder: (BuildContext context, snapshot) {

View File

@ -169,6 +169,7 @@ class _EmotesSettingsState extends State<EmotesSettings> {
} }
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
leading: BackButton(),
title: Text(L10n.of(context).emoteSettings), title: Text(L10n.of(context).emoteSettings),
), ),
floatingActionButton: showSave floatingActionButton: showSave

View File

@ -22,7 +22,10 @@ class SettingsIgnoreList extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final client = Matrix.of(context).client; final client = Matrix.of(context).client;
return Scaffold( return Scaffold(
appBar: AppBar(title: Text(L10n.of(context).ignoredUsers)), appBar: AppBar(
leading: BackButton(),
title: Text(L10n.of(context).ignoredUsers),
),
body: Column( body: Column(
children: [ children: [
Padding( Padding(

View File

@ -14,6 +14,7 @@ class MultipleEmotesSettings extends StatelessWidget {
final room = Matrix.of(context).client.getRoomById(roomId); final room = Matrix.of(context).client.getRoomById(roomId);
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
leading: BackButton(),
title: Text(L10n.of(context).emotePacks), title: Text(L10n.of(context).emotePacks),
), ),
body: StreamBuilder( body: StreamBuilder(

View File

@ -109,6 +109,7 @@ class SettingsNotifications extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
leading: BackButton(),
title: Text(L10n.of(context).notifications), title: Text(L10n.of(context).notifications),
), ),
body: StreamBuilder( body: StreamBuilder(

View File

@ -51,6 +51,7 @@ class _SettingsStyleState extends State<SettingsStyle> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
leading: BackButton(),
title: Text(L10n.of(context).changeTheme), title: Text(L10n.of(context).changeTheme),
), ),
body: ListView( body: ListView(

View File

@ -70,7 +70,7 @@ class _SignUpState extends State<SignUp> {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
elevation: 0, elevation: 0,
leading: loading ? Container() : null, leading: loading ? Container() : BackButton(),
title: Text( title: Text(
Matrix.of(context) Matrix.of(context)
.client .client

View File

@ -110,7 +110,7 @@ class _SignUpPasswordState extends State<SignUpPassword> {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
elevation: 0, elevation: 0,
leading: loading ? Container() : null, leading: loading ? Container() : BackButton(),
title: Text( title: Text(
L10n.of(context).chooseAStrongPassword, L10n.of(context).chooseAStrongPassword,
), ),