Skip to content

Commit

Permalink
Merge pull request #23 from AmityCo/dev
Browse files Browse the repository at this point in the history
fix #31 #48  #33
  • Loading branch information
ThanakornThanom authored May 15, 2024
2 parents 3279528 + dc39e26 commit 71da5e3
Show file tree
Hide file tree
Showing 19 changed files with 1,602 additions and 887 deletions.
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:amity_uikit_beta_service/view/UIKit/social/my_community_feed.dar
import 'package:amity_uikit_beta_service/view/UIKit/social/post_target_page.dart';
import 'package:amity_uikit_beta_service/view/chat/UIKit/chat_room_page.dart';
import 'package:amity_uikit_beta_service/view/social/global_feed.dart';
import 'package:amity_uikit_beta_service/view/user/user_profile.dart';
import 'package:amity_uikit_beta_service/view/user/user_profile_v2.dart';
import 'package:amity_uikit_beta_service/viewmodel/configuration_viewmodel.dart';
import 'package:flutter/material.dart';
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/components/post_profile.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:amity_uikit_beta_service/components/custom_user_avatar.dart';
import 'package:amity_uikit_beta_service/view/UIKit/social/general_component.dart';
import 'package:amity_uikit_beta_service/view/user/user_profile.dart';
import 'package:amity_uikit_beta_service/view/user/user_profile_v2.dart';
import 'package:amity_uikit_beta_service/viewmodel/user_feed_viewmodel.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'dart:developer';
import 'package:amity_sdk/amity_sdk.dart';
import 'package:amity_uikit_beta_service/components/alert_dialog.dart';
import 'package:amity_uikit_beta_service/view/social/select_user_page.dart';
import 'package:amity_uikit_beta_service/view/user/user_profile.dart';
import 'package:amity_uikit_beta_service/view/user/user_profile_v2.dart';
import 'package:amity_uikit_beta_service/viewmodel/community_member_viewmodel.dart';
import 'package:amity_uikit_beta_service/viewmodel/community_viewmodel.dart';
import 'package:amity_uikit_beta_service/viewmodel/configuration_viewmodel.dart';
Expand Down
16 changes: 11 additions & 5 deletions lib/view/UIKit/social/community_setting/posts/post_cpmponent.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class PostMedia extends StatelessWidget {
@override
Widget build(BuildContext context) {
Widget buildMediaGrid(List<UIKitFileSystem> files) {
print("XXXXXXXX: buildMediaGrid");
if (files.isEmpty) return Container();

Widget backgroundImage(UIKitFileSystem file, int index) {
Expand Down Expand Up @@ -169,9 +170,11 @@ class PostMedia extends StatelessWidget {

String getFileImage(String filePath) {
String extension = filePath.split('.').last;

print("getFileImage: $extension");
switch (extension) {
case 'audio':
return 'assets/images/fileType/audio_small.png';
return 'assets/images/fileType/audio_large.png';
case 'avi':
return 'assets/images/fileType/avi_large.png';
case 'csv':
Expand Down Expand Up @@ -208,12 +211,15 @@ class PostMedia extends StatelessWidget {
}

Widget listMediaGrid(List<UIKitFileSystem> files) {
print("XXXXXXXX: listMediaGrid");
return ListView.builder(
physics: const NeverScrollableScrollPhysics(),
itemCount: files.length,
shrinkWrap: true,
itemBuilder: (context, index) {
var file = files[index];
print("file: ${file.fileInfo.toString()}");
print("path to render: ${file.file.path}");
int rawprogress = isEditPost
? Provider.of<EditPostVM>(context).editPostMedie[index].progress
: Provider.of<CreatePostVMV2>(context).files[index].progress;
Expand Down Expand Up @@ -307,16 +313,15 @@ class PostMedia extends StatelessWidget {
);
}

bool isNotImageVideoOrAudio(UIKitFileSystem file) {
bool isNotImageOrVideo(UIKitFileSystem file) {
if (!isEditPost) {
final mimeType = lookupMimeType(file.file.path);

if (mimeType != null) {
final isImage = mimeType.startsWith('image/');
final isVideo = mimeType.startsWith('video/');
final isAudio = mimeType.startsWith('audio/');

return !(isImage || isVideo || isAudio);
return !(isImage || isVideo);
} else {
// If the MIME type is unknown, consider it as not an image, video, or audio.
return true;
Expand All @@ -336,7 +341,8 @@ class PostMedia extends StatelessWidget {
if (files.isEmpty) {
return Container(); // No non-image, non-video, non-audio files to display.
}
return isNotImageVideoOrAudio(files[0])
print("XXXXXXXX ${isNotImageOrVideo(files[0])}");
return isNotImageOrVideo(files[0])
? listMediaGrid(files)
: buildMediaGrid(files);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/view/UIKit/social/explore_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class _CommunityPageState extends State<CommunityPage> {
backgroundColor: Provider.of<AmityUIConfiguration>(context)
.appColors
.baseBackground,
iconTheme: const IconThemeData(color: Colors.blue),

leading: IconButton(
icon: Icon(
Icons.close,
Expand Down Expand Up @@ -101,7 +101,7 @@ class _CommunityPageState extends State<CommunityPage> {
),
tabs: const [
Tab(
text: "Newfeed",
text: "Newsfeed",
),
Tab(text: "Explore"),
],
Expand Down
1 change: 1 addition & 0 deletions lib/view/UIKit/social/my_community_feed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class _MyCommunityPageState extends State<MyCommunityPage> {
backgroundColor:
Provider.of<AmityUIConfiguration>(context).appColors.baseBackground,
appBar: AppBar(
scrolledUnderElevation: 0,
elevation: 0.0,
backgroundColor: Provider.of<AmityUIConfiguration>(context)
.appColors
Expand Down
1 change: 1 addition & 0 deletions lib/view/UIKit/social/post_target_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class _PostToPageState extends State<PostToPage> {
backgroundColor:
Provider.of<AmityUIConfiguration>(context).appColors.baseBackground,
appBar: AppBar(
scrolledUnderElevation: 0,
elevation: 0.0, // Add this line to remove the shadow
leading: IconButton(
icon: Icon(
Expand Down
2 changes: 1 addition & 1 deletion lib/view/UIKit/social/search_communities.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:amity_sdk/amity_sdk.dart';
import 'package:amity_uikit_beta_service/view/UIKit/social/my_community_feed.dart';
import 'package:amity_uikit_beta_service/view/social/community_feed.dart';
import 'package:amity_uikit_beta_service/view/user/user_profile.dart';
import 'package:amity_uikit_beta_service/view/user/user_profile_v2.dart';
import 'package:amity_uikit_beta_service/viewmodel/community_feed_viewmodel.dart';
import 'package:amity_uikit_beta_service/viewmodel/configuration_viewmodel.dart';
import 'package:amity_uikit_beta_service/viewmodel/my_community_viewmodel.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/view/notification/notification_all_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'dart:developer';
import 'package:amity_sdk/amity_sdk.dart';
import 'package:amity_uikit_beta_service/components/custom_user_avatar.dart';
import 'package:amity_uikit_beta_service/view/social/user_pending_request_component.dart';
import 'package:amity_uikit_beta_service/view/user/user_profile.dart';
import 'package:amity_uikit_beta_service/view/user/user_profile_v2.dart';
import 'package:amity_uikit_beta_service/viewmodel/notification_viewmodel.dart';
import 'package:amity_uikit_beta_service/viewmodel/pending_request_viewmodel.dart';
import 'package:animation_wrappers/animation_wrappers.dart';
Expand Down
74 changes: 34 additions & 40 deletions lib/view/social/global_feed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:amity_uikit_beta_service/components/post_profile.dart';
import 'package:amity_uikit_beta_service/view/UIKit/social/community_setting/posts/edit_post_page.dart';
import 'package:amity_uikit_beta_service/view/UIKit/social/general_component.dart';
import 'package:amity_uikit_beta_service/view/UIKit/social/my_community_feed.dart';
import 'package:amity_uikit_beta_service/view/user/user_profile_v2.dart';
import 'package:amity_uikit_beta_service/viewmodel/amity_viewmodel.dart';
import 'package:amity_uikit_beta_service/viewmodel/my_community_viewmodel.dart';
import 'package:amity_uikit_beta_service/viewmodel/user_viewmodel.dart';
Expand All @@ -21,7 +22,6 @@ import '../../viewmodel/edit_post_viewmodel.dart';
import '../../viewmodel/feed_viewmodel.dart';
import '../../viewmodel/post_viewmodel.dart';
import '../../viewmodel/user_feed_viewmodel.dart';
import '../user/user_profile.dart';
import 'comments.dart';
import 'community_feed.dart';
import 'post_content_widget.dart';
Expand Down Expand Up @@ -109,45 +109,39 @@ class GlobalFeedScreenState extends State<GlobalFeedScreen> {
physics: const AlwaysScrollableScrollPhysics(),
itemCount: vm.getAmityPosts.length,
itemBuilder: (context, index) {
return StreamBuilder<AmityPost>(
key: Key(vm.getAmityPosts[index].postId!),
stream: vm.getAmityPosts[index].listen.stream,
initialData: vm.getAmityPosts[index],
builder: (context, snapshot) {
var latestComments =
snapshot.data!.latestComments;
var post = snapshot.data!;
print(
"STREAM: ${(post.data as TextData).text}+++${post.myReactions}");
return Column(
children: [
index != 0
? const SizedBox()
: widget.isShowMyCommunity
? CommunityIconList(
amityCommunites:
Provider.of<MyCommunityVM>(
context)
.amityCommunities,
canCreateCommunity:
widget.canCreateCommunity,
)
: const SizedBox(),
PostWidget(
isPostDetail: false,
// customPostRanking:
// widget.isCustomPostRanking,
feedType: FeedType.global,
showCommunity: true,
showlatestComment: true,
post: snapshot.data!,
theme: theme,
postIndex: index,
isFromFeed: true,
),
],
);
},
return Column(
children: [
index != 0
? const SizedBox()
: widget.isShowMyCommunity
? CommunityIconList(
amityCommunites:
Provider.of<MyCommunityVM>(
context)
.amityCommunities,
canCreateCommunity:
widget.canCreateCommunity,
)
: const SizedBox(),
StreamBuilder<AmityPost>(
stream:
vm.getAmityPosts[index].listen.stream,
initialData: vm.getAmityPosts[index],
builder: (context, snapshot) {
return PostWidget(
isPostDetail: false,
// customPostRanking:
// widget.isCustomPostRanking,
feedType: FeedType.global,
showCommunity: true,
showlatestComment: true,
post: snapshot.data!,
theme: theme,
postIndex: index,
isFromFeed: true,
);
}),
],
);
},
),
Expand Down
21 changes: 13 additions & 8 deletions lib/view/social/post_content_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ class AmityPostWidget extends StatefulWidget {
final bool shouldShowTextPost;
final FeedType feedType;
const AmityPostWidget(
this.posts, this.isChildrenPost, this.isCornerRadiusEnabled, this.feedType,
{super.key,
this.haveChildrenPost = false,
this.shouldShowTextPost = true,});
this.posts,
this.isChildrenPost,
this.isCornerRadiusEnabled,
this.feedType, {
super.key,
this.haveChildrenPost = false,
this.shouldShowTextPost = true,
});
@override
AmityPostWidgetState createState() => AmityPostWidgetState();
}
Expand Down Expand Up @@ -186,7 +190,7 @@ class AmityPostWidgetState extends State<AmityPostWidget> {
Widget build(BuildContext context) {
if (!widget.isChildrenPost) {
if (widget.haveChildrenPost || !urlValidation(widget.posts[0])) {
return TextPost(post: widget.posts[0],feedType: widget.feedType);
return TextPost(post: widget.posts[0], feedType: widget.feedType);
} else {
String url =
extractLink(widget.posts[0]); //urlExtraction(widget.posts[0]);
Expand All @@ -195,7 +199,7 @@ class AmityPostWidgetState extends State<AmityPostWidget> {
children: [
// Text(url),
widget.shouldShowTextPost
? TextPost(post: widget.posts[0],feedType: widget.feedType)
? TextPost(post: widget.posts[0], feedType: widget.feedType)
: Container(),
generateURLWidget(url.toLowerCase())
// AnyLinkPreview(
Expand Down Expand Up @@ -1046,7 +1050,7 @@ String _getFileImage(String filePath) {
String extension = filePath.split('.').last;
switch (extension) {
case 'audio':
return 'assets/images/fileType/audio_small.png';
return 'assets/images/fileType/audio_large.png';
case 'avi':
return 'assets/images/fileType/avi_large.png';
case 'csv':
Expand Down Expand Up @@ -1154,7 +1158,8 @@ Widget _listMediaGrid(List<AmityPost> files) {
class TextPost extends StatelessWidget {
final AmityPost post;
final FeedType feedType;
const TextPost({Key? key, required this.post,required this.feedType}) : super(key: key);
const TextPost({Key? key, required this.post, required this.feedType})
: super(key: key);

Widget buildURLWidget(String text) {
return Builder(builder: (context) {
Expand Down
2 changes: 1 addition & 1 deletion lib/view/social/user_follower_component.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:amity_sdk/amity_sdk.dart';
import 'package:amity_uikit_beta_service/components/bottom_sheet.dart';
import 'package:amity_uikit_beta_service/view/user/user_profile.dart';
import 'package:amity_uikit_beta_service/view/user/user_profile_v2.dart';
import 'package:amity_uikit_beta_service/viewmodel/user_feed_viewmodel.dart';
import 'package:animation_wrappers/animations/faded_slide_animation.dart';
import 'package:flutter/material.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/view/social/user_following_component.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:amity_sdk/amity_sdk.dart';
import 'package:amity_uikit_beta_service/components/bottom_sheet.dart';
import 'package:amity_uikit_beta_service/view/user/user_profile.dart';
import 'package:amity_uikit_beta_service/view/user/user_profile_v2.dart';
import 'package:amity_uikit_beta_service/viewmodel/user_feed_viewmodel.dart';
import 'package:animation_wrappers/animations/faded_slide_animation.dart';
import 'package:flutter/material.dart';
Expand Down
Loading

0 comments on commit 71da5e3

Please sign in to comment.