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

feat: remove encryption and public/private #306

Merged
merged 3 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions assets/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -2608,9 +2608,6 @@
"max": {}
}
},
"makeThisGroupPublic": "Make this group public",
"groupPrivateDescription": "This group will only be visible to those who are invited. From the group settings, you can change this at any time.",
"enableE2EEncryption": "Enable end-to-end encryption",
"owner": "Owner",
"participantsCount": "Participants ({count})",
"@participantsCount": {
Expand Down
28 changes: 2 additions & 26 deletions lib/pages/new_group/new_group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:fluffychat/app_state/failure.dart';
import 'package:fluffychat/config/routes.dart';
import 'package:fluffychat/domain/app_state/contact/get_contacts_success.dart';
import 'package:fluffychat/pages/new_group/selected_contacts_map_change_notiifer.dart';
import 'package:fluffychat/presentation/mixin/load_more_contacts_mixin.dart';
import 'package:fluffychat/presentation/model/presentation_contact.dart';
import 'package:fluffychat/mixin/comparable_presentation_contact_mixin.dart';
import 'package:fluffychat/pages/new_group/new_group_chat_info.dart';
Expand All @@ -25,22 +24,19 @@ class NewGroup extends StatefulWidget {
NewGroupController createState() => NewGroupController();
}

class NewGroupController extends State<NewGroup>
class NewGroupController extends State<NewGroup>
with ComparablePresentationContactMixin {
final searchContactsController = SearchContactsController();
final fetchContactsController = FetchContactsController();
final contactStreamController = StreamController<Either<Failure, GetContactsSuccess>>();
final groupNameTextEditingController = TextEditingController();
final groupchatInfoScrollController = ScrollController();

final selectedContactsMapNotifier = SelectedContactsMapChangeNotifier();
final haveGroupNameNotifier = ValueNotifier(false);
final isEnableEEEncryptionNotifier = ValueNotifier(true);

final groupNameFocusNode = FocusNode();

String groupName = "";
bool isGroupPublic = false;

static const maxScrollOffsetAllowedInPixel = 380.0;

Expand All @@ -53,7 +49,6 @@ class NewGroupController extends State<NewGroup>
listenSearchContacts();
listenGroupNameChanged();
fetchContactsController.fetchCurrentTomContacts();
listenForGroupchatInfoScrollController();
fetchContactsController.listenForScrollChanged(fetchContactsController: fetchContactsController);
searchContactsController.onSearchKeywordChanged = (searchKey) {
disableLoadMoreInSearch();
Expand All @@ -73,20 +68,9 @@ class NewGroupController extends State<NewGroup>
groupNameTextEditingController.dispose();

selectedContactsMapNotifier.dispose();
isEnableEEEncryptionNotifier.dispose();
haveGroupNameNotifier.dispose();
}

void listenForGroupchatInfoScrollController() {
groupchatInfoScrollController.addListener(() {
if (groupchatInfoScrollController.offset > maxScrollOffsetAllowedInPixel) {
groupchatInfoScrollController.jumpTo(
maxScrollOffsetAllowedInPixel,
);
}
});
}

void listenContactsStartList() {
fetchContactsController.streamController.stream.listen((event) {
Logs().d('NewGroupController::fetchContacts() - event: $event');
Expand Down Expand Up @@ -131,7 +115,7 @@ class NewGroupController extends State<NewGroup>
pageBuilder: (context, animation, secondaryAnimation) {
return const SizedBox.shrink();
},
context: context,
context: context,
useRootNavigator: false,
barrierColor: Colors.white,
transitionBuilder: (context, animation1, animation2, widget) {
Expand All @@ -147,14 +131,6 @@ class NewGroupController extends State<NewGroup>
);
}

void autoScrollWhenExpandParticipants() {
groupchatInfoScrollController.animateTo(
MediaQuery.of(context).size.height,
duration: const Duration(milliseconds: 800),
curve: Curves.easeIn,
);
}

@override
Widget build(BuildContext context) => NewGroupView(this);
}
106 changes: 34 additions & 72 deletions lib/pages/new_group/new_group_chat_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:fluffychat/presentation/model/presentation_contact.dart';
import 'package:fluffychat/pages/new_group/new_group.dart';
import 'package:fluffychat/pages/new_group/new_group_info_controller.dart';
import 'package:fluffychat/pages/new_group/widget/expansion_participants_list.dart';
import 'package:fluffychat/widgets/setting_tile.dart';
import 'package:fluffychat/widgets/twake_components/twake_fab.dart';
import 'package:fluffychat/widgets/twake_components/twake_icon_button.dart';
import 'package:flutter/material.dart';
Expand All @@ -30,48 +29,43 @@ class NewGroupChatInfo extends StatelessWidget {
appBar: _buildAppBar(context),
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: SingleChildScrollView(
physics: const ClampingScrollPhysics(),
controller: newGroupController.groupchatInfoScrollController,
child: LayoutBuilder(
builder: (context, constraint) {
return ConstrainedBox(
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height - MediaQuery.of(context).viewInsets.bottom
),
child: IntrinsicHeight(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: _buildChangeProfileWidget(context)),
const SizedBox(height: 16.0),
Text(L10n.of(context)!.addAPhoto,
style: Theme.of(context).textTheme.labelLarge?.copyWith(
color: Theme.of(context).colorScheme.onSurface,
),
child: LayoutBuilder(
builder: (context, constraint) {
return ConstrainedBox(
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height - MediaQuery.of(context).viewInsets.bottom
),
child: IntrinsicHeight(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: _buildChangeProfileWidget(context)),
const SizedBox(height: 16.0),
Text(L10n.of(context)!.addAPhoto,
style: Theme.of(context).textTheme.labelLarge?.copyWith(
color: Theme.of(context).colorScheme.onSurface,
),
Text(L10n.of(context)!.maxImageSize(5),
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: LinagoraRefColors.material().neutral[40],
)),
const SizedBox(height: 32),
_buildGroupNameTextFieid(context),
const SizedBox(height: 16),
_buildSettings(context),
Expanded(
child: ExpansionParticipantsList(
newGroupController: newGroupController,
contactsList: contactsList,
),
),
Text(L10n.of(context)!.maxImageSize(5),
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: LinagoraRefColors.material().neutral[40],
)),
const SizedBox(height: 32),
_buildGroupNameTextFieid(context),
const SizedBox(height: 16),
Expanded(
child: ExpansionParticipantsList(
newGroupController: newGroupController,
contactsList: contactsList,
),
],
),
),
],
),
);
}
),
),
);
}
),
),
floatingActionButton: ValueListenableBuilder<bool>(
Expand Down Expand Up @@ -180,36 +174,4 @@ class NewGroupChatInfo extends StatelessWidget {
),
);
}

Widget _buildSettings(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: Column(
children: [
SettingTile(
key: UniqueKey(),
leadingIcon: Icons.back_hand_outlined,
settingTitle: L10n.of(context)!.makeThisGroupPublic,
settingDescription: L10n.of(context)!.groupPrivateDescription,
onSwitchButtonChanged: (valueChanged)
=> newGroupController.onGroupPrivacyChanged(valueChanged),
defaultSwitchValue: newGroupController.isGroupPublic,
),
ValueListenableBuilder<bool>(
valueListenable: newGroupController.isEnableEEEncryptionNotifier,
builder: (context, value, child) {
return SettingTile(
key: UniqueKey(),
leadingIcon: Icons.lock_outline,
settingTitle: L10n.of(context)!.enableE2EEncryption,
onSwitchButtonChanged: ((valueChanged) => {}),
isEditable: false,
defaultSwitchValue: value,
);
},
)
],
),
);
}
}
11 changes: 2 additions & 9 deletions lib/pages/new_group/new_group_info_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ extension NewGroupInfoController on NewGroupController {
invite: getSelectedValidContacts(contactsList)
.map<String>((contact) => contact.matrixId!)
.toList(),
enableEncryption: isEnableEEEncryptionNotifier.value,
preset: isGroupPublic
? CreateRoomPreset.publicChat
: CreateRoomPreset.privateChat,
enableEncryption: true,
preset: CreateRoomPreset.privateChat
);
}
);
Expand All @@ -36,11 +34,6 @@ extension NewGroupInfoController on NewGroupController {
}
}

void onGroupPrivacyChanged(bool switchValue) {
isGroupPublic = switchValue;
isEnableEEEncryptionNotifier.value = !switchValue;
}

Set<PresentationContact> getSelectedValidContacts(
Iterable<PresentationContact> contactsList,
) {
Expand Down
15 changes: 6 additions & 9 deletions lib/pages/new_group/widget/expansion_participants_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ExpansionParticipantsList extends StatefulWidget {
}

class _ExpansionParticipantsListState extends State<ExpansionParticipantsList> {
bool isExpanded = false;
bool isExpanded = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you change it, i set it default to be false because, when have a long list, it will auto scroll down a little bit, so user can't see group image, so i set default to false. Please check the case when have a lot of contacts also

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we should found another way to solve that, we need to expand it by default

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it because imo it was better UI now we removed settings tiles

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not working atm with many contacts

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wjhat is not working ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sherlockvn it looks like it was a build error, it's working now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expandablelist


@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -55,11 +55,11 @@ class _ExpansionParticipantsListState extends State<ExpansionParticipantsList> {
shape: BoxShape.circle,
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.12),
),
icon: isExpanded
? Icons.expand_less
: Icons.expand_more,
tooltip: isExpanded
? L10n.of(context)!.shrink
icon: isExpanded
? Icons.expand_less
: Icons.expand_more,
tooltip: isExpanded
? L10n.of(context)!.shrink
: L10n.of(context)!.expand,
),
],
Expand Down Expand Up @@ -89,9 +89,6 @@ class _ExpansionParticipantsListState extends State<ExpansionParticipantsList> {
void toggleExpansionList() {
setState(() {
isExpanded = !isExpanded;
if (isExpanded) {
widget.newGroupController.autoScrollWhenExpandParticipants();
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class LoadingContactWidget extends StatelessWidget {
const SizedBox(height: 16.0,),
const CircularProgressIndicator(),
const SizedBox(height: 16.0,),
Text(L10n.of(context)!.loadingContacts,
Text(L10n.of(context)!.loadingContacts,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Theme.of(context).colorScheme.secondary,
),),
Expand Down
Loading