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

create chat flow implementation #1060

Merged
merged 20 commits into from
Oct 26, 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
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: 3 additions & 0 deletions .changes/1060-create-chat-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Chat Feature:
- Chat Creation flow is now more simplified and accessible, allows you to create DM/Group DM's by selecting user(s) from the new intuitive interface and discard previous side sheet in favor of it.
- The create chat interface is now more adaptive, meaning it'll adapt to the screen sizes and show bottom sheet (mobile) and dialog (larger screens), when you tap on plus icon in `Chat`.
2 changes: 1 addition & 1 deletion app/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -889,4 +889,4 @@
/* End XCConfigurationList section */
};
rootObject = 97C146E61CF9000F007C117D /* Project object */;
}
}
3 changes: 2 additions & 1 deletion app/lib/common/providers/space_providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ final maybeSpaceInfoProvider =
});

/// gives current context space id
final selectedSpaceIdProvider = StateProvider<String?>((ref) => null);
final selectedSpaceIdProvider =
StateProvider.autoDispose<String?>((ref) => null);

/// gives current context space details based on id, will throw null if id is null
final selectedSpaceDetailsProvider =
Expand Down
1 change: 1 addition & 0 deletions app/lib/common/utils/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ enum Routes {

// --- chat
chat('/chat'),
gnunicorn marked this conversation as resolved.
Show resolved Hide resolved
// show as dialog
createChat('/chat/create'),
chatroom('/chat/:roomId([!#][^/]+)'), // !roomId, #roomName
chatProfile('/chat/:roomId([!#][^/]+)/profile'),
Expand Down
8 changes: 6 additions & 2 deletions app/lib/common/utils/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ extension Context on BuildContext {
// with consumer and then call your provider

T read<T>(ProviderBase<T> provider) {
return ProviderScope.containerOf(this, listen: false).read(provider);
return ProviderScope.containerOf(this, listen: false).read(provider);
}
}


/// An extension on [Ref] with helpful methods to add a debounce.
extension RefDebounceExtension on Ref {
/// Delays an execution by a bit such that if a dependency changes multiple
Expand All @@ -47,6 +46,11 @@ extension RefDebounceExtension on Ref {
}
}

const largeScreenBreakPoint = 770;
bool isLargeScreen(BuildContext context) {
return MediaQuery.of(context).size.width >= largeScreenBreakPoint;
}

DateTime kFirstDay = DateTime.utc(2010, 10, 16);
DateTime kLastDay = DateTime.utc(2050, 12, 31);

Expand Down
3 changes: 3 additions & 0 deletions app/lib/common/widgets/default_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class DefaultDialog extends ConsumerWidget {
final Widget? subtitle;
final Widget? description;
final double? height;
final double? minHeight;
final double? width;
final bool isLoader;
final List<Widget>? actions;
Expand All @@ -17,6 +18,7 @@ class DefaultDialog extends ConsumerWidget {
this.subtitle,
this.description,
this.height,
this.minHeight,
this.width,
this.isLoader = false,
this.actions = const <Widget>[],
Expand All @@ -31,6 +33,7 @@ class DefaultDialog extends ConsumerWidget {
constraints: BoxConstraints(
maxWidth: width ?? MediaQuery.of(context).size.width * 0.5,
maxHeight: height ?? double.infinity,
minHeight: minHeight ?? 0.0,
),
child: SingleChildScrollView(
child: Column(
Expand Down
38 changes: 7 additions & 31 deletions app/lib/features/chat/pages/room_profile_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:acter/features/room/widgets/notifications_settings_tile.dart';
import 'package:atlas_icons/atlas_icons.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:settings_ui/settings_ui.dart';
Expand Down Expand Up @@ -260,43 +261,18 @@ class RoomProfilePage extends ConsumerWidget {
onPressed: () async {
Navigator.of(context, rootNavigator: true)
.pop();
showAdaptiveDialog(
context: context,
builder: (context) => const DefaultDialog(
title: Text('Leaving room'),
isLoader: true,
),
);
EasyLoading.show(status: 'Leaving Room');
var res = await _handleLeaveRoom(ref, roomId);
if (res) {
if (context.mounted) {
context.pop();
EasyLoading.dismiss();
context.goNamed(Routes.chat.name);
}
} else {
if (context.mounted) {
showAdaptiveDialog(
context: ctx,
builder: (ctx) => DefaultDialog(
title: Text(
'Some error occured',
style: Theme.of(context)
.textTheme
.titleSmall,
),
isLoader: true,
actions: [
DefaultButton(
onPressed: () => Navigator.of(
context,
rootNavigator: true,
).pop(),
title: 'Close',
),
],
),
);
}
EasyLoading.dismiss();
EasyLoading.showError(
'Some error occured leaving room',
);
}
},
title: 'Yes',
Expand Down
238 changes: 0 additions & 238 deletions app/lib/features/chat/sheets/create_chat_sheet.dart

This file was deleted.

Loading
Loading