Skip to content

Commit

Permalink
chore: Follow up design textfields
Browse files Browse the repository at this point in the history
  • Loading branch information
krille-chan committed Aug 27, 2024
1 parent a3d15ec commit aa3de28
Show file tree
Hide file tree
Showing 13 changed files with 105 additions and 52 deletions.
3 changes: 2 additions & 1 deletion assets/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -2760,5 +2760,6 @@
"loginWithMatrixId": "Login with Matrix-ID",
"discoverHomeservers": "Discover homeservers",
"whatIsAHomeserver": "What is a homeserver?",
"homeserverDescription": "All your data is stored on the homeserver, just like an email provider. You can choose which homeserver you want to use, while you can still communicate with everyone. Learn more at at https://matrix.org."
"homeserverDescription": "All your data is stored on the homeserver, just like an email provider. You can choose which homeserver you want to use, while you can still communicate with everyone. Learn more at at https://matrix.org.",
"doesNotSeemToBeAValidHomeserver": "Doesn't seem to be a compatible homeserver. Wrong URL?"
}
11 changes: 11 additions & 0 deletions lib/pages/chat_members/chat_members_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class ChatMembersView extends StatelessWidget {
(room.summary.mInvitedMemberCount ?? 0);

final error = controller.error;
final theme = Theme.of(context);

return Scaffold(
appBar: AppBar(
Expand Down Expand Up @@ -90,6 +91,16 @@ class ChatMembersView extends StatelessWidget {
controller: controller.filterController,
onChanged: controller.setFilter,
decoration: InputDecoration(
filled: true,
fillColor: theme.colorScheme.secondaryContainer,
border: OutlineInputBorder(
borderSide: BorderSide.none,
borderRadius: BorderRadius.circular(99),
),
hintStyle: TextStyle(
color: theme.colorScheme.onPrimaryContainer,
fontWeight: FontWeight.normal,
),
prefixIcon: const Icon(Icons.search_outlined),
hintText: L10n.of(context)!.search,
),
Expand Down
12 changes: 12 additions & 0 deletions lib/pages/chat_search/chat_search_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class ChatSearchView extends StatelessWidget {
);
}

final theme = Theme.of(context);

return Scaffold(
appBar: AppBar(
leading: const Center(child: BackButton()),
Expand Down Expand Up @@ -59,6 +61,16 @@ class ChatSearchView extends StatelessWidget {
decoration: InputDecoration(
hintText: L10n.of(context)!.search,
suffixIcon: const Icon(Icons.search_outlined),
filled: true,
fillColor: theme.colorScheme.secondaryContainer,
border: OutlineInputBorder(
borderSide: BorderSide.none,
borderRadius: BorderRadius.circular(99),
),
hintStyle: TextStyle(
color: theme.colorScheme.onPrimaryContainer,
fontWeight: FontWeight.normal,
),
),
),
),
Expand Down
19 changes: 17 additions & 2 deletions lib/pages/homeserver_picker/homeserver_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,17 @@ class HomeserverPickerController extends State<HomeserverPicker> {
Future<void> checkHomeserverAction([_]) async {
homeserverController.text =
homeserverController.text.trim().toLowerCase().replaceAll(' ', '-');
if (homeserverController.text == _lastCheckedUrl) return;

if (homeserverController.text.isEmpty) {
setState(() {
error = loginFlows = null;
isLoading = false;
Matrix.of(context).getLoginClient().homeserver = null;
});
return;
}
if (_lastCheckedUrl == homeserverController.text) return;

_lastCheckedUrl = homeserverController.text;
setState(() {
error = loginFlows = null;
Expand All @@ -102,7 +112,12 @@ class HomeserverPickerController extends State<HomeserverPicker> {
final (_, _, loginFlows) = await client.checkHomeserver(homeserver);
this.loginFlows = loginFlows;
} catch (e) {
setState(() => error = (e).toLocalizedString(context));
setState(
() => error = (e).toLocalizedString(
context,
ExceptionContext.checkHomeserver,
),
);
} finally {
if (mounted) {
setState(() => isLoading = false);
Expand Down
2 changes: 2 additions & 0 deletions lib/pages/homeserver_picker/homeserver_picker_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class HomeserverPickerView extends StatelessWidget {
controller.tryCheckHomeserverActionWithoutCooldown,
onTap: controller.tryCheckHomeserverActionWithCooldown,
controller: controller.homeserverController,
autocorrect: false,
keyboardType: TextInputType.url,
decoration: InputDecoration(
prefixIcon: controller.isLoading
? Container(
Expand Down
11 changes: 11 additions & 0 deletions lib/pages/invitation_selection/invitation_selection_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class InvitationSelectionView extends StatelessWidget {
}

final groupName = room.name.isEmpty ? L10n.of(context)!.group : room.name;
final theme = Theme.of(context);
return Scaffold(
appBar: AppBar(
leading: const Center(child: BackButton()),
Expand All @@ -44,6 +45,16 @@ class InvitationSelectionView extends StatelessWidget {
child: TextField(
textInputAction: TextInputAction.search,
decoration: InputDecoration(
filled: true,
fillColor: theme.colorScheme.secondaryContainer,
border: OutlineInputBorder(
borderSide: BorderSide.none,
borderRadius: BorderRadius.circular(99),
),
hintStyle: TextStyle(
color: theme.colorScheme.onPrimaryContainer,
fontWeight: FontWeight.normal,
),
hintText: L10n.of(context)!.inviteContactToGroup(groupName),
prefixIcon: controller.loading
? const Padding(
Expand Down
17 changes: 6 additions & 11 deletions lib/pages/new_group/new_group_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ class NewGroupView extends StatelessWidget {
readOnly: controller.loading,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.people_outlined),
hintText: L10n.of(context)!.groupName,
labelText: L10n.of(context)!.groupName,
),
),
),
const SizedBox(height: 16),
SwitchListTile.adaptive(
contentPadding: const EdgeInsets.symmetric(horizontal: 32),
secondary: const Icon(Icons.public_outlined),
title: Text(L10n.of(context)!.groupIsPublic),
value: controller.publicGroup,
Expand All @@ -76,6 +77,8 @@ class NewGroupView extends StatelessWidget {
duration: FluffyThemes.animationDuration,
child: controller.publicGroup
? SwitchListTile.adaptive(
contentPadding:
const EdgeInsets.symmetric(horizontal: 32),
secondary: const Icon(Icons.search_outlined),
title: Text(L10n.of(context)!.groupCanBeFoundViaSearch),
value: controller.groupCanBeFound,
Expand All @@ -86,6 +89,7 @@ class NewGroupView extends StatelessWidget {
: const SizedBox.shrink(),
),
SwitchListTile.adaptive(
contentPadding: const EdgeInsets.symmetric(horizontal: 32),
secondary: Icon(
Icons.lock_outlined,
color: theme.colorScheme.onSurface,
Expand All @@ -108,16 +112,7 @@ class NewGroupView extends StatelessWidget {
controller.loading ? null : controller.submitAction,
child: controller.loading
? const LinearProgressIndicator()
: Row(
children: [
Expanded(
child: Text(
L10n.of(context)!.createGroupAndInviteUsers,
),
),
Icon(Icons.adaptive.arrow_forward_outlined),
],
),
: Text(L10n.of(context)!.createGroupAndInviteUsers),
),
),
),
Expand Down
10 changes: 10 additions & 0 deletions lib/pages/new_private_chat/new_private_chat_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ class NewPrivateChatView extends StatelessWidget {
onChanged: controller.searchUsers,
decoration: InputDecoration(
hintText: L10n.of(context)!.searchForUsers,
filled: true,
fillColor: theme.colorScheme.secondaryContainer,
border: OutlineInputBorder(
borderSide: BorderSide.none,
borderRadius: BorderRadius.circular(99),
),
hintStyle: TextStyle(
color: theme.colorScheme.onPrimaryContainer,
fontWeight: FontWeight.normal,
),
prefixIcon: searchResponse == null
? const Icon(Icons.search_outlined)
: FutureBuilder(
Expand Down
15 changes: 4 additions & 11 deletions lib/pages/new_space/new_space_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,20 @@ class NewSpaceView extends StatelessWidget {
readOnly: controller.loading,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.people_outlined),
hintText: L10n.of(context)!.spaceName,
labelText: L10n.of(context)!.spaceName,
errorText: controller.nameError,
),
),
),
const SizedBox(height: 16),
SwitchListTile.adaptive(
contentPadding: const EdgeInsets.symmetric(horizontal: 32),
title: Text(L10n.of(context)!.spaceIsPublic),
value: controller.publicGroup,
onChanged: controller.setPublicGroup,
),
ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 32),
trailing: const Padding(
padding: EdgeInsets.symmetric(horizontal: 16.0),
child: Icon(Icons.info_outlined),
Expand All @@ -78,16 +80,7 @@ class NewSpaceView extends StatelessWidget {
controller.loading ? null : controller.submitAction,
child: controller.loading
? const LinearProgressIndicator()
: Row(
children: [
Expanded(
child: Text(
L10n.of(context)!.createNewSpace,
),
),
Icon(Icons.adaptive.arrow_forward_outlined),
],
),
: Text(L10n.of(context)!.createNewSpace),
),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SettingsIgnoreListView extends StatelessWidget {
labelText: L10n.of(context)!.blockUsername,
suffixIcon: IconButton(
tooltip: L10n.of(context)!.block,
icon: const Icon(Icons.send_outlined),
icon: const Icon(Icons.add),
onPressed: () => controller.ignoreUser(context),
),
),
Expand Down
39 changes: 18 additions & 21 deletions lib/pages/settings_password/settings_password_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ class SettingsPasswordView extends StatelessWidget {
return Scaffold(
appBar: AppBar(
title: Text(L10n.of(context)!.changePassword),
actions: [
TextButton(
child: Text(L10n.of(context)!.passwordRecoverySettings),
onPressed: () => context.go('/rooms/settings/security/3pid'),
),
],
),
body: ListTileTheme(
iconColor: theme.colorScheme.onSurface,
Expand All @@ -31,13 +25,6 @@ class SettingsPasswordView extends StatelessWidget {
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
Center(
child: Icon(
Icons.key_outlined,
color: theme.dividerColor,
size: 80,
),
),
const SizedBox(height: 16),
TextField(
controller: controller.oldPasswordController,
Expand All @@ -46,18 +33,22 @@ class SettingsPasswordView extends StatelessWidget {
autofocus: true,
readOnly: controller.loading,
decoration: InputDecoration(
hintText: L10n.of(context)!.pleaseEnterYourCurrentPassword,
prefixIcon: const Icon(Icons.lock_outlined),
hintText: '********',
labelText: L10n.of(context)!.pleaseEnterYourCurrentPassword,
errorText: controller.oldPasswordError,
),
),
const Divider(height: 32),
const Divider(height: 64),
TextField(
controller: controller.newPassword1Controller,
obscureText: true,
autocorrect: false,
readOnly: controller.loading,
decoration: InputDecoration(
hintText: L10n.of(context)!.newPassword,
prefixIcon: const Icon(Icons.lock_reset_outlined),
hintText: '********',
labelText: L10n.of(context)!.newPassword,
errorText: controller.newPassword1Error,
),
),
Expand All @@ -68,22 +59,28 @@ class SettingsPasswordView extends StatelessWidget {
autocorrect: false,
readOnly: controller.loading,
decoration: InputDecoration(
hintText: L10n.of(context)!.repeatPassword,
prefixIcon: const Icon(Icons.repeat_outlined),
hintText: '********',
labelText: L10n.of(context)!.repeatPassword,
errorText: controller.newPassword2Error,
),
),
const SizedBox(height: 16),
const SizedBox(height: 32),
SizedBox(
width: double.infinity,
child: ElevatedButton.icon(
child: ElevatedButton(
onPressed:
controller.loading ? null : controller.changePassword,
icon: const Icon(Icons.send_outlined),
label: controller.loading
child: controller.loading
? const LinearProgressIndicator()
: Text(L10n.of(context)!.changePassword),
),
),
const SizedBox(height: 16),
TextButton(
child: Text(L10n.of(context)!.passwordRecoverySettings),
onPressed: () => context.go('/rooms/settings/security/3pid'),
),
],
),
),
Expand Down
7 changes: 3 additions & 4 deletions lib/pages/settings_security/settings_security_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ class SettingsSecurityView extends StatelessWidget {
onTap: controller.setAppLockAction,
),
},
Divider(
color: theme.dividerColor,
),
Divider(color: theme.dividerColor),
ListTile(
title: Text(
L10n.of(context)!.account,
Expand Down Expand Up @@ -118,13 +116,14 @@ class SettingsSecurityView extends StatelessWidget {
),
ListTile(
iconColor: Colors.orange,
leading: const Icon(Icons.tap_and_play),
leading: const Icon(Icons.delete_sweep_outlined),
title: Text(
L10n.of(context)!.dehydrate,
style: const TextStyle(color: Colors.orange),
),
onTap: controller.dehydrateAction,
),
Divider(color: theme.dividerColor),
ListTile(
iconColor: Colors.red,
leading: const Icon(Icons.delete_outlined),
Expand Down
9 changes: 8 additions & 1 deletion lib/utils/localized_exception_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:io';
import 'package:flutter/material.dart';

import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:http/http.dart';
import 'package:matrix/encryption.dart';
import 'package:matrix/matrix.dart';

Expand Down Expand Up @@ -69,9 +70,14 @@ extension LocalizedExceptionExtension on Object {
}
if (this is IOException ||
this is SocketException ||
this is SyncConnectionException) {
this is SyncConnectionException ||
this is ClientException) {
return L10n.of(context)!.noConnectionToTheServer;
}
if (this is FormatException &&
exceptionContext == ExceptionContext.checkHomeserver) {
return L10n.of(context)!.doesNotSeemToBeAValidHomeserver;
}
if (this is String) return toString();
if (this is UiaException) return toString();
Logs().w('Something went wrong: ', this);
Expand All @@ -81,4 +87,5 @@ extension LocalizedExceptionExtension on Object {

enum ExceptionContext {
changePassword,
checkHomeserver,
}

0 comments on commit aa3de28

Please sign in to comment.