Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
UI optimizations #534 (#535)
Browse files Browse the repository at this point in the history
  • Loading branch information
Boehrsi authored Apr 16, 2020
2 parents 9b3858f + 209e673 commit 890da3a
Show file tree
Hide file tree
Showing 20 changed files with 157 additions and 307 deletions.
2 changes: 1 addition & 1 deletion lib/src/chat/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ class _ChatState extends State<Chat> with ChatComposer, ChatCreateMixin, InviteM
showInformationDialog(
context: context,
title: L10n.get(L.contactNoPhoneNumber),
content: L10n.get(L.contactNoPhoneNumberText),
contentText: L10n.get(L.contactNoPhoneNumberText),
navigatable: Navigatable(Type.contactNoNumberDialog),
);
} else {
Expand Down
24 changes: 6 additions & 18 deletions lib/src/chat/chat_profile_group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,26 +116,29 @@ class _ChatProfileGroupState extends State<ChatProfileGroup> {
children: <Widget>[
buildProfileImageAndTitle(chatState),
SettingsItem(
pushesNewScreen: true,
icon: IconSource.flag,
text: L10n.get(L.settingItemFlaggedTitle),
iconBackground: CustomTheme.of(context).flagIcon,
onTap: () => _settingsItemTapped(context, SettingsItemName.flagged),
onTap: () => _navigation.push(context, MaterialPageRoute(builder: (context) => Flagged(chatId: widget.chatId))),
),
ListGroupHeader(
text: L10n.get(L.settingP),
),
SettingsItem(
pushesNewScreen: true,
icon: IconSource.notifications,
text: L10n.get(L.settingItemNotificationsTitle),
iconBackground: CustomTheme.of(context).notificationIcon,
onTap: () => _settingsItemTapped(context, SettingsItemName.notification),
onTap: () => _navigation.pushNamed(context, Navigation.settingsNotifications),
),
ListGroupHeader(
text: L10n.getFormatted(L.participantXP, [state.contactIds.length], count: state.contactIds.length),
),
Visibility(
visible: !chatState.isRemoved,
child: SettingsItem(
pushesNewScreen: true,
icon: IconSource.groupAdd,
text: L10n.get(L.participantAdd),
key: Key(keyChatProfileGroupAddParticipant),
Expand All @@ -146,6 +149,7 @@ class _ChatProfileGroupState extends State<ChatProfileGroup> {
),
_buildGroupMemberList(state, chatState.isRemoved),
SettingsItem(
pushesNewScreen: false,
icon: IconSource.delete,
text: chatState.isRemoved ? L10n.get(L.groupDelete) : L10n.get(L.groupLeave),
iconBackground: CustomTheme.of(context).error,
Expand All @@ -168,22 +172,6 @@ class _ChatProfileGroupState extends State<ChatProfileGroup> {
);
}

_settingsItemTapped(BuildContext context, SettingsItemName settingsItemName) {
switch (settingsItemName) {
case SettingsItemName.flagged:
_navigation.push(
context,
MaterialPageRoute(builder: (context) => Flagged(chatId: widget.chatId)),
);
break;
case SettingsItemName.notification:
_navigation.pushNamed(context, Navigation.settingsNotifications);
break;
default:
break;
}
}

ProfileData buildProfileImageAndTitle(ChatStateSuccess state) {
return ProfileData(
imageBackgroundColor: widget.chatColor,
Expand Down
31 changes: 10 additions & 21 deletions lib/src/chat/chat_profile_single.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,11 @@ import 'package:ox_coi/src/flagged/flagged.dart';
import 'package:ox_coi/src/l10n/l.dart';
import 'package:ox_coi/src/l10n/l10n.dart';
import 'package:ox_coi/src/navigation/navigation.dart';
import 'package:ox_coi/src/utils/keyMapping.dart';
import 'package:ox_coi/src/widgets/list_group_header.dart';
import 'package:ox_coi/src/widgets/profile_body.dart';
import 'package:ox_coi/src/widgets/profile_header.dart';
import 'package:ox_coi/src/widgets/settings_item.dart';
import 'package:ox_coi/src/utils/keyMapping.dart';


class ChatProfileOneToOne extends StatefulWidget {
final int chatId;
Expand Down Expand Up @@ -134,13 +133,18 @@ class _ChatProfileOneToOneState extends State<ChatProfileOneToOne> {
child: ProfileHeader(),
),
SettingsItem(
pushesNewScreen: true,
icon: IconSource.flag,
text: L10n.get(L.settingItemFlaggedTitle),
key: Key(keyChatProfileSingleIconSourceFlaggedTitle),
iconBackground: CustomTheme.of(context).flagIcon,
onTap: () => _settingsItemTapped(context, SettingsItemName.flagged),
onTap: () => _navigation.push(
context,
MaterialPageRoute(builder: (context) => Flagged(chatId: widget.chatId)),
),
),
SettingsItem(
pushesNewScreen: false,
icon: IconSource.block,
text: L10n.get(L.contactBlock),
iconBackground: CustomTheme.of(context).blockIcon,
Expand All @@ -160,45 +164,30 @@ class _ChatProfileOneToOneState extends State<ChatProfileOneToOne> {
),
if (!widget.isSelfTalk)
SettingsItem(
pushesNewScreen: true,
icon: IconSource.notifications,
text: L10n.get(L.settingItemNotificationsTitle),
iconBackground: CustomTheme.of(context).notificationIcon,
onTap: () => _settingsItemTapped(context, SettingsItemName.notification),
onTap: () => _navigation.pushNamed(context, Navigation.settingsNotifications),
),
if (!isInvite())
ListGroupHeader(
text: "",
),
if (!isInvite())
SettingsItem(
pushesNewScreen: false,
icon: IconSource.delete,
text: L10n.get(L.chatDeleteP),
textColor: CustomTheme.of(context).error,
iconBackground: CustomTheme.of(context).blockIcon,
showChevron: false,
onTap: () => showActionDialog(context, ProfileActionType.deleteChat, _deleteChat),
),
],
),
);
}

_settingsItemTapped(BuildContext context, SettingsItemName settingsItemName) {
switch (settingsItemName) {
case SettingsItemName.flagged:
_navigation.push(
context,
MaterialPageRoute(builder: (context) => Flagged(chatId: widget.chatId)),
);
break;
case SettingsItemName.notification:
_navigation.pushNamed(context, Navigation.settingsNotifications);
break;
default:
break;
}
}

_blockContact() {
// Ignoring false positive https://github.com/felangel/bloc/issues/587
// ignore: close_sinks
Expand Down
25 changes: 7 additions & 18 deletions lib/src/contact/contact_change.dart
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class _ContactChangeState extends State<ContactChange> {
showConfirmationDialog(
context: context,
title: L10n.get(L.contactGooglemailDialogTitle),
content: L10n.get(L.contactGooglemailDialogContent),
contentText: L10n.get(L.contactGooglemailDialogContent),
positiveButton: L10n.get(L.contactGooglemailDialogPositiveButton),
positiveAction: () => _goolemailMailAddressAction(state.name, state.email, true),
negativeButton: L10n.get(L.contactGooglemailDialogNegativeButton),
Expand Down Expand Up @@ -280,11 +280,7 @@ class _ContactChangeState extends State<ContactChange> {
),
),
Padding(
padding: const EdgeInsets.only(
top: dimension32dp,
bottom: dimension72dp,
left: formVerticalPadding,
right: formVerticalPadding),
padding: const EdgeInsets.only(top: dimension32dp, bottom: dimension72dp, left: formVerticalPadding, right: formVerticalPadding),
child: Text(
L10n.get(L.contactEditPhoneNumberText),
style: Theme.of(context).textTheme.caption.apply(color: CustomTheme.of(context).onBackground.half()),
Expand All @@ -303,10 +299,14 @@ class _ContactChangeState extends State<ContactChange> {
Visibility(
visible: widget.contactAction == ContactAction.add,
child: SettingsItem(
pushesNewScreen: true,
icon: IconSource.qr,
text: L10n.get(L.qrScan),
iconBackground: CustomTheme.of(context).qrIcon,
onTap: scanQr,
onTap: () => _navigation.push(
context,
MaterialPageRoute(builder: (context) => QrCode(chatId: 0, initialIndex: 1)),
),
),
),
],
Expand All @@ -326,15 +326,4 @@ class _ContactChangeState extends State<ContactChange> {
String _getName() => _nameField.controller.text;

String _getEmail() => widget.contactAction == ContactAction.add ? _emailField.controller.text : widget.email;

scanQr() {
_navigation.push(
context,
MaterialPageRoute(
builder: (context) => QrCode(
chatId: 0,
initialIndex: 1,
)),
);
}
}
30 changes: 5 additions & 25 deletions lib/src/contact/contact_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import 'package:ox_coi/src/contact/contact_item_bloc.dart';
import 'package:ox_coi/src/contact/contact_item_event_state.dart';
import 'package:ox_coi/src/data/contact_repository.dart';
import 'package:ox_coi/src/extensions/string_ui.dart';
import 'package:ox_coi/src/flagged/flagged.dart';
import 'package:ox_coi/src/l10n/l.dart';
import 'package:ox_coi/src/l10n/l10n.dart';
import 'package:ox_coi/src/navigation/navigatable.dart';
Expand Down Expand Up @@ -136,20 +135,15 @@ class _ContactDetailsState extends State<ContactDetails> with ChatCreateMixin {
child: ProfileHeader(),
),
SettingsItem(
pushesNewScreen: true,
key: Key(keyContactDetailOpenChatProfileActionIcon),
icon: IconSource.chat,
text: L10n.get(L.chatOpen),
iconBackground: CustomTheme.of(context).chatIcon,
onTap: () => createChatFromContact(context, widget.contactId),
),
//TODO: This should be discussed (Flagged messages per user)!
// SettingsItem(
// icon: IconSource.flag,
// text: L10n.get(L.settingItemFlaggedTitle),
// iconBackground: CustomTheme.of(context).flagIcon,
// onTap: () => _settingsItemTapped(context, SettingsItemName.flagged),
// ),
SettingsItem(
pushesNewScreen: false,
key: Key(keyUserProfileBlockIconSource),
icon: IconSource.block,
text: L10n.get(L.contactBlock),
Expand All @@ -168,15 +162,17 @@ class _ContactDetailsState extends State<ContactDetails> with ChatCreateMixin {
text: L10n.get(L.settingP),
),
SettingsItem(
pushesNewScreen: true,
icon: IconSource.notifications,
text: L10n.get(L.settingItemNotificationsTitle),
iconBackground: CustomTheme.of(context).notificationIcon,
onTap: () => _settingsItemTapped(context, SettingsItemName.notification),
onTap: () => _navigation.pushNamed(context, Navigation.settingsNotifications),
),
ListGroupHeader(
text: "",
),
SettingsItem(
pushesNewScreen: false,
key: Key(keyContactDetailDeleteContactProfileActionIcon),
icon: IconSource.delete,
text: L10n.get(L.contactDelete),
Expand All @@ -203,22 +199,6 @@ class _ContactDetailsState extends State<ContactDetails> with ChatCreateMixin {
);
}

_settingsItemTapped(BuildContext context, SettingsItemName settingsItemName) {
switch (settingsItemName) {
case SettingsItemName.flagged:
_navigation.push(
context,
MaterialPageRoute(builder: (context) => Flagged()),
);
break;
case SettingsItemName.notification:
_navigation.pushNamed(context, Navigation.settingsNotifications);
break;
default:
break;
}
}

void _editContact(BuildContext context, String name, String email, String phoneNumbers) async {
return await _navigation
.push(
Expand Down
25 changes: 5 additions & 20 deletions lib/src/contact/contact_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,28 +137,13 @@ class _ContactItemState extends State<ContactItem> with ContactItemBuilder, Chat
_buildUnblockContactDialog(String name, String email) {
String contact = name.isNotEmpty ? name : email;
Navigation navigation = Navigation();
return showNavigatableDialog(
return showConfirmationDialog(
context: context,
navigatable: Navigatable(Type.contactUnblockDialog),
dialog: AlertDialog(
title: Text(L10n.get(L.contactUnblock)),
content: Text(L10n.getFormatted(L.contactUnblockTextX, [contact])),
actions: <Widget>[
FlatButton(
child: Text(L10n.get(L.cancel)),
onPressed: () {
navigation.pop(context);
},
),
FlatButton(
child: Text(L10n.get(L.unblock)),
onPressed: () {
unblockContact();
navigation.pop(context);
},
),
],
),
title: L10n.get(L.contactUnblock),
contentText: L10n.getFormatted(L.contactUnblockTextX, [contact]),
positiveButton: L10n.get(L.unblock),
positiveAction: unblockContact,
);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/src/contact/contact_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class _ContactListState extends State<ContactList> with ChatCreateMixin {
showConfirmationDialog(
context: context,
title: L10n.get(L.contactGooglemailDialogTitle),
content: L10n.get(L.contactGooglemailDialogContent),
contentText: L10n.get(L.contactGooglemailDialogContent),
positiveButton: L10n.get(L.contactGooglemailDialogPositiveButton),
positiveAction: () => _googleMailMailAddressAction(true),
negativeButton: L10n.get(L.contactGooglemailDialogNegativeButton),
Expand Down Expand Up @@ -278,7 +278,7 @@ class _ContactListState extends State<ContactList> with ChatCreateMixin {
showConfirmationDialog(
context: context,
title: importTitle,
content: content,
contentText: content,
positiveButton: importPositive,
positiveAction: () {
_progressOverlayEntry = FullscreenOverlay(
Expand Down
1 change: 1 addition & 0 deletions lib/src/l10n/l.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class L {
static final import = _translationKey("Import");
static final inbox = _translationKey("Inbox");
static final invites = _translationKey("Invites");
static final invitation = _translationKey("Invitation");
static final email = _translationKey("Email");
static final location = _translationKey("Location");
static final me = _translationKey("Me");
Expand Down
2 changes: 1 addition & 1 deletion lib/src/login/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class _LoginState extends State<Login> {
showInformationDialog(
context: context,
title: L10n.get(L.loginFailed),
content: state.error,
contentText: state.error,
navigatable: Navigatable(Type.loginErrorDialog),
);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/login/login_manual_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class _LoginManualSettingsState extends State<LoginManualSettings> {
showInformationDialog(
context: context,
title: L10n.get(L.loginFailed),
content: state.error,
contentText: state.error,
navigatable: Navigatable(Type.loginErrorDialog),
);
});
Expand Down
2 changes: 1 addition & 1 deletion lib/src/login/login_provider_signin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class _ProviderSignInState extends State<ProviderSignIn> {
showInformationDialog(
context: context,
title: L10n.get(L.loginFailed),
content: state.error,
contentText: state.error,
navigatable: Navigatable(Type.loginErrorDialog),
);
});
Expand Down
Loading

0 comments on commit 890da3a

Please sign in to comment.