Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TW-692: New design for settings screen #707

Merged
merged 20 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
be065bf
TW-692: Update UI when change page
nqhhdev Sep 29, 2023
b3deda1
TW-692: Update folder settings
nqhhdev Sep 29, 2023
c7bff22
TW-692: Fix overflow for display name
nqhhdev Sep 29, 2023
fc552b2
TW-692: Remove Settings screen from go_router
nqhhdev Sep 29, 2023
9d74213
TW-692: Create settings, settings profile enum and settings profile p…
nqhhdev Sep 29, 2023
23d2329
TW-692: Create SettingsDashboardManagerController for manage settings
nqhhdev Sep 29, 2023
b326c79
TW-692: Add new text for intl
nqhhdev Sep 29, 2023
aa964d2
TW-692: Create `SettingsProfileItemBuilder`
nqhhdev Sep 29, 2023
2dc63e8
TW-692: Create `SettingsItemBuilder`
nqhhdev Sep 29, 2023
5a478a6
TW-692: Create `SettingsProfileViewMobile`
nqhhdev Sep 29, 2023
28d5c28
TW-692: Create `SettingsProfileViewWeb`
nqhhdev Sep 29, 2023
fdb4e6f
TW-692: Update settings screen
nqhhdev Sep 29, 2023
2095b04
TW-692: Update settings profile screen
nqhhdev Sep 29, 2023
ed80a28
TW-692: Add SnackBar for copy and update highlight when select option…
nqhhdev Sep 29, 2023
c736d30
TW-692: Create `TwakeEventDispatcher`, `TwakeInappEventTypes` to use …
nqhhdev Oct 3, 2023
5af188e
TW-692: Create `FetchProfileMixin` to handle fetch profile
nqhhdev Oct 3, 2023
4064ca8
TW-692: Handle sync profile for stream
nqhhdev Oct 3, 2023
a90d63a
TW-692: Add ADR for send/listen event
nqhhdev Oct 3, 2023
2633a93
TW-692: Create `UploadProfileInteractor`
nqhhdev Oct 3, 2023
bfe4775
TW-692: Implement `UploadProfile` in presentation layer
nqhhdev Oct 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions assets/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1689,7 +1689,7 @@
"type": "text",
"placeholders": {}
},
"search": "Search for people and channels",
"searchForPeopleAndChannels": "Search for people and channels",
"@search": {
"type": "text",
"placeholders": {}
Expand Down Expand Up @@ -2647,7 +2647,6 @@
"tapToAllowAccessToYourGallery": "Tap to allow access to your Gallery",
"tapToAllowAccessToYourCamera": "You can enable camera access in the Settings app to make video calls in",
"twake": "Twake",
"dismiss": "Dismiss",
"permissionAccess": "Permission access",
"allow": "Allow",
"explainStoragePermission": "Twake need access to your storage to preview file",
Expand All @@ -2669,7 +2668,6 @@
}
},
"keyboard": "Keyboard",
"tapToAllowAccessToYourGallery": "Tap to allow access to your Gallery",
"changeChatAvatar": "Change the Chat avatar",
"roomAvatarMaxFileSize": "The avatar size is too large",
"@roomAvatarMaxFileSize": {},
Expand Down Expand Up @@ -2734,5 +2732,27 @@
"unmuteThisMessage": "Unmute this message",
"read": "Read",
"unread": "Unread",
"unmute": "Unmute"
"unmute": "Unmute",
"privacyAndSecurity" : "Privacy & Security",
"notificationAndSounds": "Notification & Sounds",
"appLanguage": "App Language",
"chatFolders": "Chat Folders",
"settingsChatSubtitle" : "Appearance, themes, wallpaper, chat history.",
"settingsPrivacyAndSecuritySubtitle": "Block contacts, disappearing messages.",
"settingsNotificationAndSoundsSubtitle": "Custom how you get notifications from Twake such as previewing messages, sounds, time,...",
"settingsChatFoldersSubtitle": "Create and manage folders for different groups of chats and quickly switch between them.",
"settingsAppLanguageSubtitle": "English (phone’s language).",
"settingsDevicesSubtitle": "Control your sign in and sign out on any device.",
"settingsHelpSubtitle": "Help center, contact us, privacy policy.",
"displayName": "Display Name",
"bio": "Bio (optional)",
"matrixId": "Matrix ID",
"email": "Email",
"company": "Company",
"basicInfo": "BASIC INFO",
"editProfileDescriptions": "Update your profile with a new name, picture and a short introduction.",
"workIdentitiesInfo": "WORK IDENTITIES INFO",
"editWorkIdentitiesDescriptions": "Edit your work identity settings such as Matrix ID, email or company name.",
"copiedMatrixIdToClipboard": "Copied Matrix ID to clipboard.",
"changeProfilePhoto": "Change profile photo"
}
73 changes: 73 additions & 0 deletions docs/adr/0009-Instructions-for-naming-twake-events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# 7. Instructions for naming twake events

Date: 2023-10-03

## Status

Accepted

## Docs

- [Spec](https://spec.matrix.org/v1.6/#events)

## Context

- All data exchanged through Matrix is represented as an “event”. In addition, we have local support events.
- We can use local events to handle logic and behavior by injecting events into a defined stream.

## Decision

How to name events
- Below are the naming rules for events.
- App.twake is the name of the application.
- Inapp is event use for local support.
- Profile is the name of the feature.
- Avatar is the name of the event.
ex: 'app.twake.inapp.profile.avatar'

How to use events.
- Send event

```
class TwakeEventDispatcher {
static final TwakeEventDispatcher _twakeEventDispatcher =
TwakeEventDispatcher._instance();

factory TwakeEventDispatcher() {
return _twakeEventDispatcher;
}

TwakeEventDispatcher._instance();

void sendAccountDataEvent({
required Client client,
required BasicEvent basicEvent,
}) {
client.onAccountData.add(basicEvent);
}
}

twakeEventDispatcher.sendAccountDataEvent(
client: client,
basicEvent: BasicEvent(
type: TwakeInappEventTypes.uploadAvatarEvent,
content: profile.toJson(),
),
);
```
- Listen event and handle it

```
client.onAccountData.stream.listen((event) {
Logs().d(
'FetchProfileMixin::onAccountData() - EventType: ${event.type} - EventContent: ${event.content}',
);
if (event.type == TwakeInappEventTypes.uploadAvatarEvent) {
profileNotifier.value = Profile.fromJson(event.content);
}
});
```

## Consequences

- If we do not specifically define the event, it will be duplicated with the homeserver event
1 change: 1 addition & 0 deletions lib/config/app_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ abstract class AppConfig {
static const String defaultVideoBlurHash = 'L5H2EC=PM+yV0g-mq.wG9c010J}I';
static const int thumbnailQuality = 70;
static const int blurHashSize = 32;
static const int imageQuality = 50;
nqhhdev marked this conversation as resolved.
Show resolved Hide resolved

static String? issueId;

Expand Down
26 changes: 17 additions & 9 deletions lib/config/go_routes/go_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:fluffychat/pages/chat_draft/draft_chat.dart';
import 'package:fluffychat/pages/chat_encryption_settings/chat_encryption_settings.dart';
import 'package:fluffychat/pages/error_page/error_page.dart';
import 'package:fluffychat/pages/homeserver_picker/homeserver_picker.dart';
import 'package:fluffychat/pages/settings_dashboard/settings_profile/settings_profile.dart';
import 'package:fluffychat/pages/share/share.dart';
import 'package:fluffychat/pages/story/story_page.dart';
import 'package:fluffychat/presentation/model/chat/chat_router_input_argument.dart';
Expand All @@ -25,15 +26,15 @@ import 'package:fluffychat/pages/invitation_selection/invitation_selection.dart'
import 'package:fluffychat/pages/login/login.dart';
import 'package:fluffychat/pages/new_group/new_group.dart';
import 'package:fluffychat/pages/new_private_chat/new_private_chat.dart';
import 'package:fluffychat/pages/settings_3pid/settings_3pid.dart';
import 'package:fluffychat/pages/settings_chat/settings_chat.dart';
import 'package:fluffychat/pages/settings_emotes/settings_emotes.dart';
import 'package:fluffychat/pages/settings_ignore_list/settings_ignore_list.dart';
import 'package:fluffychat/pages/settings_multiple_emotes/settings_multiple_emotes.dart';
import 'package:fluffychat/pages/settings_notifications/settings_notifications.dart';
import 'package:fluffychat/pages/settings_security/settings_security.dart';
import 'package:fluffychat/pages/settings_stories/settings_stories.dart';
import 'package:fluffychat/pages/settings_style/settings_style.dart';
import 'package:fluffychat/pages/settings_dashboard/settings_3pid/settings_3pid.dart';
import 'package:fluffychat/pages/settings_dashboard/settings_chat/settings_chat.dart';
import 'package:fluffychat/pages/settings_dashboard/settings_emotes/settings_emotes.dart';
import 'package:fluffychat/pages/settings_dashboard/settings_ignore_list/settings_ignore_list.dart';
import 'package:fluffychat/pages/settings_dashboard/settings_multiple_emotes/settings_multiple_emotes.dart';
import 'package:fluffychat/pages/settings_dashboard/settings_notifications/settings_notifications.dart';
import 'package:fluffychat/pages/settings_dashboard/settings_security/settings_security.dart';
import 'package:fluffychat/pages/settings_dashboard/settings_stories/settings_stories.dart';
import 'package:fluffychat/pages/settings_dashboard/settings_style/settings_style.dart';
import 'package:fluffychat/pages/sign_up/signup.dart';
import 'package:fluffychat/widgets/log_view.dart';
import 'package:fluffychat/widgets/matrix.dart';
Expand Down Expand Up @@ -243,6 +244,13 @@ abstract class AppRoutes {
);
},
),
GoRoute(
path: 'profile',
pageBuilder: (context, state) => defaultPageBuilder(
context,
const SettingsProfile(),
),
),
GoRoute(
path: 'notifications',
pageBuilder: (context, state) => defaultPageBuilder(
Expand Down
6 changes: 6 additions & 0 deletions lib/di/global/get_it_initializer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import 'package:fluffychat/domain/usecase/send_file_interactor.dart';
import 'package:fluffychat/domain/usecase/send_file_on_web_interactor.dart';
import 'package:fluffychat/domain/usecase/send_image_interactor.dart';
import 'package:fluffychat/domain/usecase/send_images_interactor.dart';
import 'package:fluffychat/domain/usecase/settings/update_profile_interactor.dart';
import 'package:fluffychat/event/twake_event_dispatcher.dart';
import 'package:fluffychat/utils/responsive/responsive_utils.dart';
import 'package:get_it/get_it.dart';

Expand Down Expand Up @@ -71,6 +73,7 @@ class GetItInitializer {
HiveDI().bind();
NetworkConnectivityDI().bind();
getIt.registerSingleton(ResponsiveUtils());
getIt.registerSingleton(TwakeEventDispatcher());
}

void bindingQueue() {
Expand Down Expand Up @@ -175,5 +178,8 @@ class GetItInitializer {
getIt.registerSingleton<TimelineSearchEventInteractor>(
TimelineSearchEventInteractor(),
);
getIt.registerSingleton<UpdateProfileInteractor>(
UpdateProfileInteractor(),
);
}
}
10 changes: 10 additions & 0 deletions lib/domain/app_state/settings/update_profile_failure.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:fluffychat/app_state/failure.dart';

class UpdateProfileFailure extends Failure {
final dynamic exception;

const UpdateProfileFailure(this.exception) : super();

@override
List<Object?> get props => [exception];
}
8 changes: 8 additions & 0 deletions lib/domain/app_state/settings/update_profile_loading.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import 'package:fluffychat/app_state/success.dart';

class UpdateProfileLoading extends Success {
const UpdateProfileLoading();

@override
List<Object?> get props => [];
}
21 changes: 21 additions & 0 deletions lib/domain/app_state/settings/update_profile_success.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:fluffychat/app_state/success.dart';

class UpdateProfileInitial extends Success {
@override
List<Object?> get props => [];
}

class UpdateProfileSuccess extends Success {
final Uri? avatar;
final String? displayName;
final bool isDeleteAvatar;
sherlockvn marked this conversation as resolved.
Show resolved Hide resolved

const UpdateProfileSuccess({
this.avatar,
this.displayName,
this.isDeleteAvatar = false,
});

@override
List<Object?> get props => [avatar, displayName, isDeleteAvatar];
}
47 changes: 47 additions & 0 deletions lib/domain/usecase/settings/update_profile_interactor.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import 'package:dartz/dartz.dart';
import 'package:fluffychat/app_state/failure.dart';
import 'package:fluffychat/app_state/success.dart';
import 'package:fluffychat/domain/app_state/settings/update_profile_failure.dart';
import 'package:fluffychat/domain/app_state/settings/update_profile_loading.dart';
import 'package:fluffychat/domain/app_state/settings/update_profile_success.dart';
import 'package:matrix/matrix.dart';

class UpdateProfileInteractor {
Stream<Either<Failure, Success>> execute({
required Client client,
Uri? avatarUrl,
bool isDeleteAvatar = false,
String? displayName,
}) async* {
yield const Right(UpdateProfileLoading());
try {
Logs().d(
'UploadProfileInteractor::execute(): Uri - $avatarUrl - displayName - $displayName',
);
if (avatarUrl != null || isDeleteAvatar) {
await client.setAvatarUrl(
client.userID!,
avatarUrl ?? Uri.parse(''),
);
}
if (displayName != null) {
await client.setDisplayName(
client.userID!,
displayName,
);
}
yield Right(
UpdateProfileSuccess(
displayName: displayName,
avatar: avatarUrl,
isDeleteAvatar: isDeleteAvatar,
),
);
} catch (e) {
Logs().d(
'UploadAvatarInteractor::execute(): Exception - $e}',
);
yield Left(UpdateProfileFailure(e));
}
}
}
19 changes: 19 additions & 0 deletions lib/event/twake_event_dispatcher.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:matrix/matrix.dart';

class TwakeEventDispatcher {
static final TwakeEventDispatcher _twakeEventDispatcher =
TwakeEventDispatcher._instance();

factory TwakeEventDispatcher() {
return _twakeEventDispatcher;
}

TwakeEventDispatcher._instance();

void sendAccountDataEvent({
required Client client,
required BasicEvent basicEvent,
}) {
client.onAccountData.add(basicEvent);
}
}
3 changes: 3 additions & 0 deletions lib/event/twake_inapp_event_types.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class TwakeInappEventTypes {
static const String uploadAvatarEvent = 'app.twake.inapp.profile.avatar';
sherlockvn marked this conversation as resolved.
Show resolved Hide resolved
}
2 changes: 1 addition & 1 deletion lib/pages/chat_details/chat_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:fluffychat/pages/chat_details/chat_details_page_view/links/chat_
import 'package:fluffychat/pages/chat_details/chat_details_page_view/media/chat_details_media_page.dart';
import 'package:fluffychat/pages/invitation_selection/invitation_selection.dart';
import 'package:fluffychat/pages/invitation_selection/invitation_selection_web.dart';
import 'package:fluffychat/presentation/enum/settings/settings_profile_enum.dart';
import 'package:fluffychat/presentation/extensions/room_summary_extension.dart';
import 'package:fluffychat/presentation/mixins/handle_video_download_mixin.dart';
import 'package:fluffychat/presentation/mixins/play_video_action_mixin.dart';
Expand All @@ -28,7 +29,6 @@ import 'package:image_picker/image_picker.dart';
import 'package:matrix/matrix.dart';

import 'package:fluffychat/pages/chat_details/chat_details_view.dart';
import 'package:fluffychat/pages/settings/settings.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/widgets/matrix.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/chat_list/chat_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'package:fluffychat/pages/bootstrap/bootstrap_dialog.dart';
import 'package:fluffychat/pages/bootstrap/tom_bootstrap_dialog.dart';
import 'package:fluffychat/pages/chat_list/chat_list_view.dart';
import 'package:fluffychat/pages/chat_list/receive_sharing_intent_mixin.dart';
import 'package:fluffychat/pages/settings_security/settings_security.dart';
import 'package:fluffychat/pages/settings_dashboard/settings_security/settings_security.dart';
import 'package:fluffychat/presentation/enum/chat_list/chat_list_enum.dart';
import 'package:fluffychat/presentation/extensions/client_extension.dart';
import 'package:fluffychat/presentation/model/chat_list/chat_selection_actions.dart';
Expand Down
38 changes: 20 additions & 18 deletions lib/pages/chat_list/chat_list_item_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,25 +75,27 @@ mixin ChatListItemMixin {
return isGroup
? Row(
children: [
FutureBuilder<User?>(
future: room.lastEvent?.fetchSenderUser(),
builder: (context, snapshot) {
if (snapshot.data == null) return const SizedBox.shrink();
return Text(
snapshot.data!.calcDisplayname(),
overflow: TextOverflow.ellipsis,
maxLines: 1,
softWrap: false,
style: Theme.of(context).textTheme.labelLarge?.merge(
TextStyle(
overflow: TextOverflow.ellipsis,
color: unread
? Theme.of(context).colorScheme.onSurface
: ChatListItemStyle.readMessageColor,
Expanded(
child: FutureBuilder<User?>(
future: room.lastEvent?.fetchSenderUser(),
builder: (context, snapshot) {
if (snapshot.data == null) return const SizedBox.shrink();
return Text(
snapshot.data!.calcDisplayname(),
overflow: TextOverflow.ellipsis,
maxLines: 1,
softWrap: false,
style: Theme.of(context).textTheme.labelLarge?.merge(
TextStyle(
overflow: TextOverflow.ellipsis,
color: unread
? Theme.of(context).colorScheme.onSurface
: ChatListItemStyle.readMessageColor,
),
),
),
);
},
);
},
),
),
const Spacer()
],
Expand Down
Loading