From 531c0cccea22bede670b29b92900bbc1472e172c Mon Sep 17 00:00:00 2001 From: Nikhil Rajput Date: Wed, 4 Jan 2023 02:46:42 +0530 Subject: [PATCH] updated to version 1.0.1+29 --- lib/constants/colors.dart | 6 +- lib/global_widgets/count_widget.dart | 8 +- .../home/controllers/profile_controller.dart | 4 +- .../home/views/widgets/post_widget.dart | 72 +++------------ .../post/views/widgets/comment_widget.dart | 63 ++++++------- .../views/widgets/post_details_widget.dart | 72 +++------------ lib/modules/profile/views/profile_view.dart | 14 ++- .../views/widgets/login_info_widget.dart | 21 ++++- lib/modules/user/user_profile_view.dart | 67 ++++++++------ lib/utils/utility.dart | 88 ++++++++++++++++++- 10 files changed, 223 insertions(+), 192 deletions(-) diff --git a/lib/constants/colors.dart b/lib/constants/colors.dart index a6cdd0a..18d295c 100644 --- a/lib/constants/colors.dart +++ b/lib/constants/colors.dart @@ -50,13 +50,13 @@ abstract class ColorValues { static const Color darkSubtitle2TextColor = Color.fromARGB(255, 124, 124, 124); - static const Color lightBgColor = Color.fromARGB(255, 250, 250, 250); - static const Color lightDialogColor = Color.fromARGB(255, 236, 236, 236); + static const Color lightBgColor = Color.fromARGB(255, 252, 252, 252); + static const Color lightDialogColor = Color.fromARGB(255, 232, 232, 232); static const Color darkBgColor = Color.fromARGB(255, 18, 18, 30); static const Color darkDialogColor = Color.fromARGB(255, 40, 40, 50); static const Color lightShadowColor = Color.fromARGB(255, 0, 0, 0); - static const Color darkShadowColor = Color.fromARGB(255, 200, 200, 200); + static const Color darkShadowColor = Color.fromARGB(255, 150, 150, 150); static const primaryGrad = LinearGradient( colors: [primaryColor, primaryLightColor], diff --git a/lib/global_widgets/count_widget.dart b/lib/global_widgets/count_widget.dart index 2c32b5a..09087f9 100644 --- a/lib/global_widgets/count_widget.dart +++ b/lib/global_widgets/count_widget.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:social_media_app/constants/colors.dart'; import 'package:social_media_app/constants/dimens.dart'; import 'package:social_media_app/constants/styles.dart'; @@ -42,14 +41,17 @@ class NxCountWidget extends StatelessWidget { children: [ Text( value, - style: valueStyle ?? AppStyles.style16Bold, + style: valueStyle ?? + AppStyles.style16Bold.copyWith( + color: Theme.of(context).textTheme.bodyText1!.color, + ), ), Dimens.boxHeight4, Text( title, style: titleStyle ?? AppStyles.style13Normal.copyWith( - color: ColorValues.grayColor, + color: Theme.of(context).textTheme.subtitle2!.color, ), ), ], diff --git a/lib/modules/home/controllers/profile_controller.dart b/lib/modules/home/controllers/profile_controller.dart index 7f7d975..ef71db3 100644 --- a/lib/modules/home/controllers/profile_controller.dart +++ b/lib/modules/home/controllers/profile_controller.dart @@ -248,7 +248,7 @@ class ProfileController extends GetxController { final response = await _apiProvider.getUserPosts( _auth.token, _profileDetails.value.user!.id, - limit: 16, + limit: 12, ); if (response.isSuccessful) { @@ -284,7 +284,7 @@ class ProfileController extends GetxController { _auth.token, _profileDetails.value.user!.id, page: page, - limit: 16, + limit: 12, ); if (response.isSuccessful) { diff --git a/lib/modules/home/views/widgets/post_widget.dart b/lib/modules/home/views/widgets/post_widget.dart index 31ab220..ab81a78 100644 --- a/lib/modules/home/views/widgets/post_widget.dart +++ b/lib/modules/home/views/widgets/post_widget.dart @@ -16,11 +16,13 @@ import 'package:social_media_app/global_widgets/elevated_card.dart'; import 'package:social_media_app/global_widgets/expandable_text_widget.dart'; import 'package:social_media_app/global_widgets/get_time_ago_refresh_widget/get_time_ago_widget.dart'; import 'package:social_media_app/global_widgets/primary_icon_btn.dart'; -import 'package:social_media_app/global_widgets/primary_text_btn.dart'; import 'package:social_media_app/global_widgets/video_player_widget.dart'; import 'package:social_media_app/helpers/get_time_ago_msg.dart'; +import 'package:social_media_app/modules/home/controllers/post_controller.dart'; import 'package:social_media_app/modules/home/controllers/profile_controller.dart'; +import 'package:social_media_app/modules/home/controllers/trending_post_controller.dart'; import 'package:social_media_app/modules/home/views/widgets/post_view_widget.dart'; +import 'package:social_media_app/modules/post/controllers/post_details_controller.dart'; import 'package:social_media_app/modules/post/views/widgets/poll_option_widget.dart'; import 'package:social_media_app/routes/route_management.dart'; import 'package:social_media_app/utils/utility.dart'; @@ -37,6 +39,9 @@ class PostWidget extends StatelessWidget { @override Widget build(BuildContext context) { + assert(controller is PostDetailsController || + controller is PostController || + controller is TrendingPostController); return NxElevatedCard( margin: Dimens.edgeInsets8_0, borderRadius: Dimens.four, @@ -440,7 +445,13 @@ class PostWidget extends StatelessWidget { ListTile( onTap: () { AppUtility.closeBottomSheet(); - _showDeletePostOptions(); + AppUtility.showDeleteDialog( + context, + () async { + AppUtility.closeDialog(); + controller?.deletePost(post.id!); + }, + ); }, leading: Icon( Icons.delete, @@ -484,61 +495,4 @@ class PostWidget extends StatelessWidget { ), ], ); - - Future _showDeletePostOptions() async { - AppUtility.showSimpleDialog( - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Dimens.boxHeight8, - Padding( - padding: Dimens.edgeInsets0_16, - child: Text( - StringValues.delete, - style: AppStyles.style20Bold, - ), - ), - Dimens.boxHeight8, - Padding( - padding: Dimens.edgeInsets0_16, - child: Text( - StringValues.deleteConfirmationText, - style: AppStyles.style14Normal, - ), - ), - Dimens.boxHeight8, - Padding( - padding: Dimens.edgeInsets0_16, - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - NxTextButton( - label: StringValues.no, - labelStyle: AppStyles.style16Bold.copyWith( - color: ColorValues.errorColor, - ), - onTap: AppUtility.closeDialog, - padding: Dimens.edgeInsets8, - ), - Dimens.boxWidth16, - NxTextButton( - label: StringValues.yes, - labelStyle: AppStyles.style16Bold.copyWith( - color: ColorValues.successColor, - ), - onTap: () async { - AppUtility.closeDialog(); - controller?.deletePost(post.id!); - }, - padding: Dimens.edgeInsets8, - ), - ], - ), - ), - Dimens.boxHeight8, - ], - ), - ); - } } diff --git a/lib/modules/post/views/widgets/comment_widget.dart b/lib/modules/post/views/widgets/comment_widget.dart index 4c7ef31..3ae660b 100644 --- a/lib/modules/post/views/widgets/comment_widget.dart +++ b/lib/modules/post/views/widgets/comment_widget.dart @@ -36,7 +36,8 @@ class CommentWidget extends StatelessWidget { children: [ _buildCommentHead(context), _buildCommentBody(context), - _buildCommentFooter(context), + //_buildCommentFooter(context), + Dimens.boxHeight8, ], ), ); @@ -164,36 +165,36 @@ class CommentWidget extends StatelessWidget { ); } - Widget _buildCommentFooter(BuildContext context) => Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - /// Like Button - GestureDetector( - onTap: () => {}, - child: Padding( - padding: Dimens.edgeInsets8, - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - Icon(Icons.favorite_outline, - size: Dimens.twenty, - color: Theme.of(context).textTheme.subtitle1!.color), - Dimens.boxWidth2, - Text( - '${0}'.toCountingFormat(), - style: AppStyles.style13Normal.copyWith( - color: Theme.of(context).textTheme.subtitle1!.color, - ), - ), - ], - ), - ), - ), - ], - ); + // Widget _buildCommentFooter(BuildContext context) => Row( + // crossAxisAlignment: CrossAxisAlignment.center, + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // /// Like Button + // GestureDetector( + // onTap: () => {}, + // child: Padding( + // padding: Dimens.edgeInsets8, + // child: Row( + // mainAxisAlignment: MainAxisAlignment.start, + // crossAxisAlignment: CrossAxisAlignment.center, + // mainAxisSize: MainAxisSize.min, + // children: [ + // Icon(Icons.favorite_outline, + // size: Dimens.twenty, + // color: Theme.of(context).textTheme.subtitle1!.color), + // Dimens.boxWidth2, + // Text( + // '${0}'.toCountingFormat(), + // style: AppStyles.style13Normal.copyWith( + // color: Theme.of(context).textTheme.subtitle1!.color, + // ), + // ), + // ], + // ), + // ), + // ), + // ], + // ); void _showHeaderOptionBottomSheet(BuildContext context) => AppUtility.showBottomSheet( diff --git a/lib/modules/post/views/widgets/post_details_widget.dart b/lib/modules/post/views/widgets/post_details_widget.dart index e5105b9..9ce5aa0 100644 --- a/lib/modules/post/views/widgets/post_details_widget.dart +++ b/lib/modules/post/views/widgets/post_details_widget.dart @@ -15,10 +15,12 @@ import 'package:social_media_app/global_widgets/cached_network_image.dart'; import 'package:social_media_app/global_widgets/elevated_card.dart'; import 'package:social_media_app/global_widgets/expandable_text_widget.dart'; import 'package:social_media_app/global_widgets/primary_icon_btn.dart'; -import 'package:social_media_app/global_widgets/primary_text_btn.dart'; import 'package:social_media_app/global_widgets/video_player_widget.dart'; +import 'package:social_media_app/modules/home/controllers/post_controller.dart'; import 'package:social_media_app/modules/home/controllers/profile_controller.dart'; +import 'package:social_media_app/modules/home/controllers/trending_post_controller.dart'; import 'package:social_media_app/modules/home/views/widgets/post_view_widget.dart'; +import 'package:social_media_app/modules/post/controllers/post_details_controller.dart'; import 'package:social_media_app/modules/post/views/widgets/poll_option_widget.dart'; import 'package:social_media_app/routes/route_management.dart'; import 'package:social_media_app/utils/utility.dart'; @@ -35,6 +37,9 @@ class PostDetailsWidget extends StatelessWidget { @override Widget build(BuildContext context) { + assert(controller is PostDetailsController || + controller is PostController || + controller is TrendingPostController); return NxElevatedCard( margin: Dimens.edgeInsets8_0, borderRadius: Dimens.four, @@ -518,7 +523,13 @@ class PostDetailsWidget extends StatelessWidget { ListTile( onTap: () { AppUtility.closeBottomSheet(); - _showDeletePostOptions(); + AppUtility.showDeleteDialog( + context, + () async { + AppUtility.closeDialog(); + controller?.deletePost(post.id!); + }, + ); }, leading: Icon( Icons.delete, @@ -562,61 +573,4 @@ class PostDetailsWidget extends StatelessWidget { ), ], ); - - Future _showDeletePostOptions() async { - AppUtility.showSimpleDialog( - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Dimens.boxHeight8, - Padding( - padding: Dimens.edgeInsets0_16, - child: Text( - 'Delete', - style: AppStyles.style18Bold, - ), - ), - Dimens.dividerWithHeight, - Padding( - padding: Dimens.edgeInsets0_16, - child: Text( - StringValues.deleteConfirmationText, - style: AppStyles.style14Normal, - ), - ), - Dimens.boxHeight8, - Padding( - padding: Dimens.edgeInsets0_16, - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - NxTextButton( - label: StringValues.no, - labelStyle: AppStyles.style16Bold.copyWith( - color: ColorValues.errorColor, - ), - onTap: AppUtility.closeDialog, - padding: Dimens.edgeInsets8, - ), - Dimens.boxWidth16, - NxTextButton( - label: StringValues.yes, - labelStyle: AppStyles.style16Bold.copyWith( - color: ColorValues.successColor, - ), - onTap: () async { - AppUtility.closeDialog(); - controller?.deletePost(post.id!); - }, - padding: Dimens.edgeInsets8, - ), - ], - ), - ), - Dimens.boxHeight8, - ], - ), - ); - } } diff --git a/lib/modules/profile/views/profile_view.dart b/lib/modules/profile/views/profile_view.dart index e76d99c..e8ca26d 100644 --- a/lib/modules/profile/views/profile_view.dart +++ b/lib/modules/profile/views/profile_view.dart @@ -95,6 +95,7 @@ class ProfileView extends StatelessWidget { children: [ /// Account NxListTile( + bgColor: ColorValues.transparent, padding: Dimens.edgeInsets12, leading: Icon( Icons.account_circle_outlined, @@ -113,6 +114,7 @@ class ProfileView extends StatelessWidget { /// Security NxListTile( + bgColor: ColorValues.transparent, padding: Dimens.edgeInsets12, leading: Icon( Icons.verified_user_outlined, @@ -131,6 +133,7 @@ class ProfileView extends StatelessWidget { /// Privacy NxListTile( + bgColor: ColorValues.transparent, padding: Dimens.edgeInsets12, leading: Icon( Icons.lock_outline, @@ -149,6 +152,7 @@ class ProfileView extends StatelessWidget { /// Help NxListTile( + bgColor: ColorValues.transparent, padding: Dimens.edgeInsets12, leading: Icon( Icons.help_outline_outlined, @@ -167,6 +171,7 @@ class ProfileView extends StatelessWidget { /// Theme NxListTile( + bgColor: ColorValues.transparent, padding: Dimens.edgeInsets12, leading: Icon( Icons.palette_outlined, @@ -185,6 +190,7 @@ class ProfileView extends StatelessWidget { /// About NxListTile( + bgColor: ColorValues.transparent, padding: Dimens.edgeInsets12, leading: Icon( Icons.info_outline, @@ -203,6 +209,7 @@ class ProfileView extends StatelessWidget { /// Check for update NxListTile( + bgColor: ColorValues.transparent, padding: Dimens.edgeInsets12, leading: Icon( Icons.loop_outlined, @@ -221,6 +228,7 @@ class ProfileView extends StatelessWidget { /// Logout NxListTile( + bgColor: ColorValues.transparent, padding: Dimens.edgeInsets12, leading: Icon( Icons.logout_outlined, @@ -402,6 +410,7 @@ class ProfileView extends StatelessWidget { height: Dimens.thirtySix, padding: Dimens.edgeInsets0_8, borderRadius: Dimens.four, + borderWidth: Dimens.one, labelStyle: AppStyles.style14Normal.copyWith( color: Theme.of(context).textTheme.bodyText1!.color, ), @@ -414,8 +423,11 @@ class ProfileView extends StatelessWidget { width: Dimens.screenWidth, padding: Dimens.edgeInsets8_0, decoration: BoxDecoration( - color: Theme.of(context).bottomAppBarColor, borderRadius: BorderRadius.circular(Dimens.four), + border: Border.all( + color: Theme.of(context).bottomAppBarColor, + width: Dimens.one, + ), ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, diff --git a/lib/modules/settings/views/widgets/login_info_widget.dart b/lib/modules/settings/views/widgets/login_info_widget.dart index 4bd31d3..41fac82 100644 --- a/lib/modules/settings/views/widgets/login_info_widget.dart +++ b/lib/modules/settings/views/widgets/login_info_widget.dart @@ -25,7 +25,20 @@ class LoginInfoWidget extends StatelessWidget { @override Widget build(BuildContext context) { return GestureDetector( - onLongPress: () => _showDeleteDialog(item.deviceId!), + onLongPress: () => AppUtility.showDeleteDialog( + context, + () async { + AppUtility.closeDialog(); + if (item.deviceId! == AuthService.find.deviceId.toString()) { + await AuthService.find.logout(); + RouteManagement.goToWelcomeView(); + return; + } else { + await LoginInfoController.find + .deleteLoginDeviceInfo(item.deviceId!); + } + }, + ), child: Padding( padding: margin ?? Dimens.edgeInsets8_0, child: NxListTile( @@ -119,11 +132,11 @@ class LoginInfoWidget extends StatelessWidget { Padding( padding: Dimens.edgeInsets0_16, child: Text( - 'Delete', - style: AppStyles.style18Bold, + StringValues.delete, + style: AppStyles.style20Bold, ), ), - Dimens.dividerWithHeight, + Dimens.boxHeight8, Padding( padding: Dimens.edgeInsets0_16, child: Text( diff --git a/lib/modules/user/user_profile_view.dart b/lib/modules/user/user_profile_view.dart index 02e1a7e..c0205ef 100644 --- a/lib/modules/user/user_profile_view.dart +++ b/lib/modules/user/user_profile_view.dart @@ -16,6 +16,7 @@ import 'package:social_media_app/global_widgets/expandable_text_widget.dart'; import 'package:social_media_app/global_widgets/image_viewer_widget.dart'; import 'package:social_media_app/global_widgets/load_more_widget.dart'; import 'package:social_media_app/global_widgets/post_thumb_widget.dart'; +import 'package:social_media_app/global_widgets/primary_filled_btn.dart'; import 'package:social_media_app/global_widgets/primary_outlined_btn.dart'; import 'package:social_media_app/modules/user/user_details_controller.dart'; import 'package:social_media_app/routes/route_management.dart'; @@ -213,7 +214,7 @@ class UserProfileView extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.center, children: [ Icon( - Icons.link_outlined, + Icons.link, size: Dimens.sixTeen, color: Theme.of(context).textTheme.subtitle1!.color, ), @@ -333,35 +334,40 @@ class UserProfileView extends StatelessWidget { ), ), ), - Dimens.boxWidth16, - Expanded( - child: NxOutlinedButton( - label: StringValues.message.toTitleCase(), - width: Dimens.screenWidth, - height: Dimens.thirtySix, - padding: Dimens.edgeInsets0_8, - borderRadius: Dimens.four, - labelStyle: AppStyles.style14Normal.copyWith( - color: Theme.of(context).textTheme.bodyText1!.color, - ), - onTap: () => RouteManagement.goToChatDetailsView( - User( - id: user.id, - fname: user.fname, - lname: user.lname, - email: user.email, - uname: user.uname, - avatar: user.avatar, - isPrivate: user.isPrivate, - followingStatus: user.followingStatus, - accountStatus: user.accountStatus, - isVerified: user.isVerified, - createdAt: user.createdAt, - updatedAt: user.updatedAt, + if (!user.isPrivate || + (user.isPrivate && user.followingStatus == "following")) + Dimens.boxWidth12, + if (!user.isPrivate || + (user.isPrivate && user.followingStatus == "following")) + Expanded( + child: NxFilledButton( + label: StringValues.message.toTitleCase(), + bgColor: Theme.of(context).bottomAppBarColor, + width: Dimens.screenWidth, + height: Dimens.thirtySix, + padding: Dimens.edgeInsets0_8, + borderRadius: Dimens.four, + labelStyle: AppStyles.style14Normal.copyWith( + color: Theme.of(context).textTheme.bodyText1!.color, + ), + onTap: () => RouteManagement.goToChatDetailsView( + User( + id: user.id, + fname: user.fname, + lname: user.lname, + email: user.email, + uname: user.uname, + avatar: user.avatar, + isPrivate: user.isPrivate, + followingStatus: user.followingStatus, + accountStatus: user.accountStatus, + isVerified: user.isVerified, + createdAt: user.createdAt, + updatedAt: user.updatedAt, + ), ), ), - ), - ) + ) ], ); } @@ -373,8 +379,11 @@ class UserProfileView extends StatelessWidget { width: Dimens.screenWidth, padding: Dimens.edgeInsets8_0, decoration: BoxDecoration( - color: Theme.of(context).bottomAppBarColor, borderRadius: BorderRadius.circular(Dimens.four), + border: Border.all( + color: Theme.of(context).bottomAppBarColor, + width: Dimens.one, + ), ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, diff --git a/lib/utils/utility.dart b/lib/utils/utility.dart index 61da4f9..cb3ce44 100644 --- a/lib/utils/utility.dart +++ b/lib/utils/utility.dart @@ -155,7 +155,7 @@ abstract class AppUtility { maxWidth: Dimens.hundred * 6, ), child: Padding( - padding: Dimens.edgeInsets16, + padding: Dimens.edgeInsets12, child: Align( alignment: Alignment.center, child: Material( @@ -176,6 +176,92 @@ abstract class AppUtility { ); } + /// Show Delete Dialog + + static void showDeleteDialog(BuildContext context, Function onDelete) { + closeDialog(); + Get.dialog( + MediaQuery.removeViewInsets( + context: context, + removeLeft: true, + removeTop: true, + removeRight: true, + removeBottom: true, + child: ConstrainedBox( + constraints: BoxConstraints( + maxHeight: Dimens.screenHeight, + maxWidth: Dimens.hundred * 6, + ), + child: Padding( + padding: Dimens.edgeInsets12, + child: Align( + alignment: Alignment.center, + child: Material( + type: MaterialType.card, + color: Theme.of(Get.context!).dialogBackgroundColor, + borderRadius: BorderRadius.all( + Radius.circular(Dimens.four), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Dimens.boxHeight8, + Padding( + padding: Dimens.edgeInsetsHorizDefault, + child: Text( + StringValues.delete, + style: AppStyles.style20Bold, + ), + ), + Dimens.boxHeight8, + Padding( + padding: Dimens.edgeInsetsHorizDefault, + child: Text( + StringValues.deleteConfirmationText, + style: AppStyles.style14Normal, + ), + ), + Dimens.boxHeight8, + Padding( + padding: Dimens.edgeInsetsHorizDefault, + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + NxTextButton( + label: StringValues.no, + labelStyle: AppStyles.style16Bold.copyWith( + color: ColorValues.errorColor, + ), + onTap: AppUtility.closeDialog, + padding: Dimens.edgeInsets8, + ), + Dimens.boxWidth16, + NxTextButton( + label: StringValues.yes, + labelStyle: AppStyles.style16Bold.copyWith( + color: ColorValues.successColor, + ), + onTap: () => onDelete(), + padding: Dimens.edgeInsets8, + ), + ], + ), + ), + Dimens.boxHeight8, + ], + ), + ), + ), + ), + ), + ), + barrierDismissible: false, + barrierColor: ColorValues.blackColor.withOpacity(0.75), + name: 'delete_dialog', + ); + } + static void showError(String message) { closeSnackBar(); closeBottomSheet();