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

Um/feat/subchannel #240

Merged
merged 9 commits into from
Oct 29, 2024
2 changes: 1 addition & 1 deletion ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '12.0'
platform :ios, '13.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
18 changes: 18 additions & 0 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
87240C3E9927238D49A20AD9 /* [CP] Embed Pods Frameworks */,
47EF1AD016902339FB844E27 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -219,6 +220,23 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
};
47EF1AD016902339FB844E27 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
showEnvVarsInLog = 0;
};
87240C3E9927238D49A20AD9 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down
5 changes: 4 additions & 1 deletion lib/core/route/app_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,14 @@ class AppRoute {
static const createCustomPostRoute = 'createCustomPost';

static const chat = 'chat';
static const chatRoute = 'chatRoute/:channelId';
static const chatRoute = 'chatRoute/:channelId/:channelName';

static const channelProfile = 'channelProfile';
static const channelProfileRoute = '/channelProfile/:channelId';

static const subChannelProfile = 'subChannelProfile';
static const subChannelProfileRoute = '/subChannelProfile/:subChannelId';

static const channelList = 'channelList';
static const channelListRoute = '/channelList';

Expand Down
17 changes: 15 additions & 2 deletions lib/core/route/app_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import 'package:flutter_social_sample_app/presentation/screen/stories_by_targets
import 'package:flutter_social_sample_app/presentation/screen/story_details/story_details_screens.dart';
import 'package:flutter_social_sample_app/presentation/screen/story_targets_by_targets%20/targets_by_targets_screens.dart';
import 'package:flutter_social_sample_app/presentation/screen/stream_list/stream_list_screen.dart';
import 'package:flutter_social_sample_app/presentation/screen/sub_channel/get_sub_channel.dart';
import 'package:flutter_social_sample_app/presentation/screen/token_exchange/token_exchange_screen.dart';
import 'package:flutter_social_sample_app/presentation/screen/user_blocked_list/user_blocked_list_screen.dart';
import 'package:flutter_social_sample_app/presentation/screen/user_feed/user_feed_screen.dart';
Expand Down Expand Up @@ -329,8 +330,11 @@ class AppRouter {
GoRoute(
name: AppRoute.chat,
path: AppRoute.chatRoute,
builder: (context, state) =>
ChatScreen(channelId: state.params['channelId']!),
builder: (context, state) {
print("ChannelId: ${state.params['channelId']} - ChannelName: ${state.params['channelName']}");
return ChatScreen(channelId: state.params['channelId']! , channelName: state.params['channelName']!,);
}
,
),
],
),
Expand All @@ -351,6 +355,15 @@ class AppRouter {
channelId: state.params['channelId']!,
),
),


GoRoute(
name: AppRoute.subChannelProfile,
path: AppRoute.subChannelProfileRoute,
builder: (context, state) => GetSubChannelScreen(
subChannelId: state.params['subChannelId']!,
),
),
GoRoute(
name: AppRoute.channelList,
path: AppRoute.channelListRoute,
Expand Down
696 changes: 324 additions & 372 deletions lib/core/widget/message_widget.dart

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions lib/core/widget/story_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ class FeedReactionActionWidget extends StatelessWidget {
Widget build(BuildContext context) {
final themeData = Theme.of(context);
bool isFlagedByMe = amityStory.myReactions.isNotEmpty;
print("Reaction Event: isFallgedByMe $isFlagedByMe");
return Container(
margin: const EdgeInsets.only(top: 8, bottom: 8),
child: Row(
Expand All @@ -578,7 +579,6 @@ class FeedReactionActionWidget extends StatelessWidget {
referenceId: amityStory.storyId!),
'like')
.then((value) {
print(value.myReactions);
});
} else {
AmitySocialClient.newReactionRepository()
Expand All @@ -587,7 +587,6 @@ class FeedReactionActionWidget extends StatelessWidget {
referenceId: amityStory.storyId!),
'like')
.then((value) {
print(value.myReactions);
});
}
},
Expand Down
223 changes: 223 additions & 0 deletions lib/core/widget/subchannel_item_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
import 'package:amity_sdk/amity_sdk.dart';
import 'package:flutter/material.dart';
import 'package:flutter_social_sample_app/core/route/app_route.dart';
import 'package:flutter_social_sample_app/core/widget/common_snackbar.dart';
import 'package:flutter_social_sample_app/core/widget/dialog/edit_text_dialog.dart';
import 'package:flutter_social_sample_app/core/widget/dialog/error_dialog.dart';
import 'package:go_router/go_router.dart';

class SubChannelItemWidget extends StatelessWidget {
final AmitySubChannel subChannel;
const SubChannelItemWidget({super.key, required this.subChannel});
@override
Widget build(BuildContext context) {
final themeData = Theme.of(context);
return Container(
margin: const EdgeInsets.symmetric(horizontal: 8),
child: GestureDetector(
onTap: () {
GoRouter.of(context).pushNamed(AppRoute.chat, params: {
'channelId': subChannel.subChannelId!,
'channelName': subChannel.displayName!,
});
},
child: Card(
child: Container(
padding: const EdgeInsets.all(8),
child: Stack(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
subChannel.displayName ?? '<< No display name >>',
style: themeData.textTheme.titleLarge,
),
PopupMenuButton(
child: const Icon(Icons.arrow_drop_down_circle_outlined),
itemBuilder: (BuildContext context) {
return [
const PopupMenuItem(
value: 0,
child: Text('Soft Delete'),
),
const PopupMenuItem(
value: 1,
child: Text('Hard Delete'),
),
const PopupMenuItem(
value: 2,
child: Text('Edit SubChannel'),
),
const PopupMenuItem(
value: 3,
child: Text('Subscribe to RTE'),
),
const PopupMenuItem(
value: 4,
child: Text('UnSubscribe to RTE'),
),
];
},
onSelected: (value) {
switch (value) {
case 0:
AmitySocialClient.newSubChannelRepository()
.softDeleteSubChannel(subChannelId: subChannel.subChannelId!)
.then(
(value) => (context.mounted)
? CommonSnackbar.showPositiveSnackbar(
context,
'Success',
'SubChannel Soft Deleted',
)
: null,
)
.onError(
(error, stackTrace) => (context.mounted)
? CommonSnackbar.showNagativeSnackbar(
context,
'Error',
error.toString(),
)
: null,
);
break;
case 1:
AmitySocialClient.newSubChannelRepository()
.hardDeleteSubChannel(subChannelId: subChannel.subChannelId!)
.then(
(value) => (context.mounted)
? CommonSnackbar.showPositiveSnackbar(
context,
'Success',
'SubChannel Hard Deleted',
)
: null,
)
.onError(
(error, stackTrace) => (context.mounted)
? CommonSnackbar.showNagativeSnackbar(
context,
'Error',
error.toString(),
)
: null,
);
break;
case 2:
EditTextDialog.show(
context,
hintText: 'Enter new Display Name',
onPress: (value) {
if (value.trim().isEmpty) {
ErrorDialog.show(context, title: 'Error', message: 'Channel Name cannot be empty');
return;
}
AmitySocialClient.newSubChannelRepository()
.updateeditSubChannelSubChannel(
subChannelId: subChannel.subChannelId!,
displayName: value,
)
.then((value) => (context.mounted) ? CommonSnackbar.showPositiveSnackbar(context, 'Success', 'SubChannel Updated') : null)
.onError((error, stackTrace) => (context.mounted) ? CommonSnackbar.showNagativeSnackbar(context, 'Error', error.toString()) : null);
},
);
break;

case 3:
subChannel
.subscription()
.subscribeTopic()
.then(
(value) => (context.mounted)
? CommonSnackbar.showPositiveSnackbar(
context,
'Success',
'SubChannel Subscribed',
)
: null,
)
.onError(
(error, stackTrace) => (context.mounted)
? CommonSnackbar.showNagativeSnackbar(
context,
'Error',
error.toString(),
)
: null,
);
break;
case 4:
subChannel
.subscription()
.unsubscribeTopic()
.then(
(value) => (context.mounted)
? CommonSnackbar.showPositiveSnackbar(
context,
'Success',
'SubChannel Unsubscribed',
)
: null,
)
.onError(
(error, stackTrace) => (context.mounted)
? CommonSnackbar.showNagativeSnackbar(
context,
'Error',
error.toString(),
)
: null,
);
break;
}
}),
],
),
Text(
'Message Count: ${subChannel.messageCount ?? 'NaN'}',
style: themeData.textTheme.bodySmall,
),
Text(
'isDeleted: ${subChannel.isDeleted ?? 'NaN'}',
style: themeData.textTheme.bodySmall,
),
Text(
'last Activity: ${subChannel.lastActivity?.toIso8601String() ?? 'NaN'}',
style: themeData.textTheme.bodySmall,
),
Text(
'isDeleted: ${subChannel.isDeleted ?? 'NaN'}',
style: themeData.textTheme.bodySmall,
),
SelectableText(
'SubChannel ID : ${subChannel.subChannelId ?? 'NaN'}',
style: themeData.textTheme.bodySmall,
),
],
),
subChannel.isDeleted ?? false
? Positioned.fill(
child: Container(
color: Colors.grey.withOpacity(0.5),
child: Center(
child: Text(
'Deleted',
style: themeData.textTheme.titleLarge?.copyWith(color: Colors.red),
),
),
),
)
: const SizedBox.shrink(),
],
),
),
),
),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class _ChannelCreateScreenState extends State<ChannelCreateScreen> {
} else {
builder = AmityChatClient.newChannelRepository().createChannel().communityType().withDisplayName(name);

if (channeld.isEmpty) channeld = const Uuid().v4();
// if (channeld.isEmpty) channeld = const Uuid().v4();
builder.channelId(channeld);
}
break;
Expand Down
Loading
Loading