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);
break;
case 'details':
await AdaptivePageLayout.of(context).pushNamedAndRemoveAllOthers(
'/rooms/${widget.room.id}/details');
if (AdaptivePageLayout.of(context).viewDataStack.length < 3) {
await AdaptivePageLayout.of(context)
.pushNamed('/rooms/${widget.room.id}/details');
}
break;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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