diff --git a/lib/sidemenu/Community/MyCommunity/AddGroups.dart b/lib/sidemenu/Community/MyCommunity/AddGroups.dart index 4d018d0..a4f139f 100644 --- a/lib/sidemenu/Community/MyCommunity/AddGroups.dart +++ b/lib/sidemenu/Community/MyCommunity/AddGroups.dart @@ -143,7 +143,9 @@ class _AddGroupState extends State { print("community created"); // Get.toNamed(RouteName.mycommunity); Get.back(); - Get.back(); + Get.back( + result: true + ); return utils.showToast(data.message); } else { Get.back(); diff --git a/lib/sidemenu/Community/MyCommunity/NewCommunity.dart b/lib/sidemenu/Community/MyCommunity/NewCommunity.dart index 80aa8e6..736297d 100644 --- a/lib/sidemenu/Community/MyCommunity/NewCommunity.dart +++ b/lib/sidemenu/Community/MyCommunity/NewCommunity.dart @@ -151,319 +151,326 @@ class _NewCommunityState extends State { @override Widget build(BuildContext context) { - return GestureDetector( - onTap: () => FocusManager.instance.primaryFocus?.unfocus(), - child: Scaffold( - // key: _scaffoldKey1, - backgroundColor: Color(0xFF222935), - extendBody: true, - resizeToAvoidBottomInset: true, - appBar: CommonAppbar( - titleTxt: "New community", - ), - body: Stack(children: [ - Container( - decoration: const BoxDecoration( - image: DecorationImage( - image: AssetImage("assets/images/png/Ellipse 1496.png"), - fit: BoxFit.fill)), + return WillPopScope( + onWillPop: () async{ + Get.back(result: true); + return true; + }, + child: GestureDetector( + onTap: () => FocusManager.instance.primaryFocus?.unfocus(), + child: Scaffold( + // key: _scaffoldKey1, + backgroundColor: Color(0xFF222935), + extendBody: true, + resizeToAvoidBottomInset: true, + appBar: CommonAppbar( + titleTxt: "New community", + customBack: true, ), - SingleChildScrollView( - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - sizedBoxHeight(20.h), - Center( - child: InkWell( + body: Stack(children: [ + Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/png/Ellipse 1496.png"), + fit: BoxFit.fill)), + ), + SingleChildScrollView( + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + sizedBoxHeight(20.h), + Center( + child: InkWell( + onTap: () { + ImageUploadBottomSheet().showModal( + context, + false, + (result) { + if (result != null && result.isNotEmpty) { + var file = File(result); + filePath.cast(); + filePath.add(file); + isImageAdded = true; + setState(() {}); + if (Platform.isAndroid) { + Get.back(); + } + } else { + // Handle case where no image is selected + filePath.clear(); + isImageAdded = false; + setState(() {}); + } + }, + ); + }, + child: commonGlassUI( + width: 95.w, + height: 95.h, + borderRadius: BorderRadius.circular(100), + opacity1: 0.24, + opacity2: 0.24, + customWidget: filePath.isNotEmpty && isImageAdded + ? ClipOval( + child: SizedBox.fromSize( + size: Size.fromRadius(47.5.r), + child: Image.file( + filePath[0]!, + fit: BoxFit.cover, + width: double.infinity, + ), + ), + ) + : Center( + child: Image.asset( + "assets/images/png/cameraicon2.png", + height: 30.h, + width: 30.w, + ), + ), + borderwidth: 0.5), + ), + ), + sizedBoxHeight(20.h), + Center( + child: + text16w400_white("Add community profile picture")), + sizedBoxHeight(30.h), + text16w400_FCFCFC("Banner image"), + sizedBoxHeight(15.h), + InkWell( onTap: () { ImageUploadBottomSheet().showModal( context, false, (result) { + // var file = File(result); + + // bannerPath.add(file); + // isbannerAdded = true; + // setState(() {}); if (result != null && result.isNotEmpty) { var file = File(result); - filePath.cast(); - filePath.add(file); - isImageAdded = true; - setState(() {}); - if (Platform.isAndroid) { - Get.back(); + + // Check if the file size exceeds 10 MB + int fileSizeInBytes = file.lengthSync(); + double fileSizeInMB = + fileSizeInBytes / (1024 * 1024); + + if (fileSizeInMB > 10) { + // Show toast message if the file size exceeds 10 MB + + utils.showToast( + "The selected file is too large. Max file size is 10 MB."); + } else { + // Clear the existing image and add the new one + bannerPath.clear(); + bannerPath.add(file); + isbannerAdded = true; + setState(() {}); } } else { // Handle case where no image is selected - filePath.clear(); - isImageAdded = false; + bannerPath.clear(); + isbannerAdded = false; setState(() {}); } + if (Platform.isAndroid) { + Get.back(); + } }, ); }, - child: commonGlassUI( - width: 95.w, - height: 95.h, - borderRadius: BorderRadius.circular(100), - opacity1: 0.24, - opacity2: 0.24, - customWidget: filePath.isNotEmpty && isImageAdded - ? ClipOval( - child: SizedBox.fromSize( - size: Size.fromRadius(47.5.r), - child: Image.file( - filePath[0]!, - fit: BoxFit.cover, - width: double.infinity, - ), + child: DottedBorder( + strokeWidth: 1, + dashPattern: [7, 4], + borderType: BorderType.RRect, + radius: Radius.circular(14.r), + color: Color(0xFF434A53), + child: commonGlassUI( + borderwidth: 0, + width: double.infinity, + height: 130.h, + borderRadius: BorderRadius.circular(10.r), + customWidget: bannerPath.isNotEmpty && isbannerAdded + ? Stack(children: [ + Image.file( + bannerPath[0]!, + fit: BoxFit.cover, + width: double.infinity, ), - ) - : Center( - child: Image.asset( - "assets/images/png/cameraicon2.png", - height: 30.h, - width: 30.w, + Positioned( + right: 5, + bottom: 5, + child: GestureDetector( + onTap: () { + bannerPath.clear(); + isbannerAdded = false; + setState(() {}); + }, + child: Container( + width: 27, + height: 27, + decoration: ShapeDecoration( + color: Color(0xFF7E7E7E), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(5)), + ), + child: Icon( + Icons.delete_outline_outlined, + color: Colors.white, + ))), + ), + ]) + : Padding( + padding: EdgeInsets.symmetric(vertical: 16.h), + child: Column( + children: [ + Image.asset( + "assets/images/png/bi_download.png", + height: 36.h, + width: 36.w, + ), + sizedBoxHeight(10.h), + text14w400white('Upload banner image'), + sizedBoxHeight(8.h), + text8w400_8A8A8A( + "Allowed file extensions: jpg, png, gif Max file size: 10 MB"), + ], ), ), - borderwidth: 0.5), - ), - ), - sizedBoxHeight(20.h), - Center( - child: - text16w400_white("Add community profile picture")), - sizedBoxHeight(30.h), - text16w400_FCFCFC("Banner image"), - sizedBoxHeight(15.h), - InkWell( - onTap: () { - ImageUploadBottomSheet().showModal( - context, - false, - (result) { - // var file = File(result); - - // bannerPath.add(file); - // isbannerAdded = true; - // setState(() {}); - if (result != null && result.isNotEmpty) { - var file = File(result); - - // Check if the file size exceeds 10 MB - int fileSizeInBytes = file.lengthSync(); - double fileSizeInMB = - fileSizeInBytes / (1024 * 1024); - - if (fileSizeInMB > 10) { - // Show toast message if the file size exceeds 10 MB - - utils.showToast( - "The selected file is too large. Max file size is 10 MB."); - } else { - // Clear the existing image and add the new one - bannerPath.clear(); - bannerPath.add(file); - isbannerAdded = true; - setState(() {}); - } - } else { - // Handle case where no image is selected - bannerPath.clear(); - isbannerAdded = false; - setState(() {}); - } - if (Platform.isAndroid) { - Get.back(); - } - }, - ); - }, - child: DottedBorder( - strokeWidth: 1, - dashPattern: [7, 4], - borderType: BorderType.RRect, - radius: Radius.circular(14.r), - color: Color(0xFF434A53), - child: commonGlassUI( - borderwidth: 0, - width: double.infinity, - height: 130.h, - borderRadius: BorderRadius.circular(10.r), - customWidget: bannerPath.isNotEmpty && isbannerAdded - ? Stack(children: [ - Image.file( - bannerPath[0]!, - fit: BoxFit.cover, - width: double.infinity, - ), - Positioned( - right: 5, - bottom: 5, - child: GestureDetector( - onTap: () { - bannerPath.clear(); - isbannerAdded = false; - setState(() {}); - }, - child: Container( - width: 27, - height: 27, - decoration: ShapeDecoration( - color: Color(0xFF7E7E7E), - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(5)), - ), - child: Icon( - Icons.delete_outline_outlined, - color: Colors.white, - ))), - ), - ]) - : Padding( - padding: EdgeInsets.symmetric(vertical: 16.h), - child: Column( - children: [ - Image.asset( - "assets/images/png/bi_download.png", - height: 36.h, - width: 36.w, - ), - sizedBoxHeight(10.h), - text14w400white('Upload banner image'), - sizedBoxHeight(8.h), - text8w400_8A8A8A( - "Allowed file extensions: jpg, png, gif Max file size: 10 MB"), - ], - ), - ), + ), ), ), - ), - sizedBoxHeight(25.h), - - text16w400_FCFCFC("Community name*"), - sizedBoxHeight(15.h), - CustomTextFormField( - textEditingController: communitycontroller, - inputFormatters: [ - RemoveEmojiInputFormatter(), - // FilteringTextInputFormatter.allow(RegExp('[a-zA-Z ]')) - ], - hintText: 'Enter community name', - validator: (val) { - if (val == null || val.isEmpty) { - return 'Enter Community name'; - } - return null; - }, - ), - sizedBoxHeight(25.h), - text16w400_FCFCFC("Community description*"), - sizedBoxHeight(15.h), - CustomTextFormField( - textEditingController: communitydescrcontroller, - inputFormatters: [ - RemoveEmojiInputFormatter(), - // FilteringTextInputFormatter.allow(RegExp('[a-zA-Z ]')) - ], - hintText: 'Enter community description', - validator: (val) { - if (val == null || val.isEmpty) { - return 'Enter Community description'; - } - return null; - }, - ), - sizedBoxHeight(25.h), - text16w400_FCFCFC("Type of community*"), - sizedBoxHeight(15.h), - CustomDropDownRadio( - header: "", - title: "", - listData: const ['Public', 'Private', 'Secret'], - onItemSelected: _onItemSelected, - // (p0) {}, - leadingImage: SizedBox()), - // CommonDropdownradioBtn( - // hint: '', - // items: ['Public', 'Private', 'Secret'], - // showOtherOption: false), - sizedBoxHeight(25.h), - text16w400_FCFCFC("Location*"), - sizedBoxHeight(15.h), - CustomTextFormField( - textEditingController: locationcontroller, - inputFormatters: [ - RemoveEmojiInputFormatter(), - // FilteringTextInputFormatter.allow(RegExp('[a-zA-Z ]')) - ], - hintText: 'Enter location', - validator: (val) { - if (val == null || val.isEmpty) { - return 'Enter location'; - } - return null; - }, - ), - sizedBoxHeight(25.h), - text16w400_FCFCFC("Primary activity*"), - - sizedBoxHeight(20.h), - CustomDropDownRadio( - header: "", - title: "", - listData: _activitydrop, - // [ - // 'Sports', - // 'Hobby', - // ], - showOtherOption: false, - onItemSelected: getCatIdFromName, - leadingImage: SizedBox()), - - sizedBoxHeight(25.h), - sizedBoxHeight(25.h), - CustomButton( - text: "Create community", - onPressed: () { - // Get.toNamed(RouteName.addgroup); - if (bannerPath.isEmpty || - communitycontroller.text.isEmpty || - communitydescrcontroller.text.isEmpty || - _selectedtypecommunity.isEmpty || - locationcontroller.text.isEmpty || - selectedactivityid.isBlank!) { - utils.showToast('Please fill all fields'); - } else if (filePath.isEmpty) { - utils.showToast( - 'Please add community profile picture'); - } else { - print('done'); - // indiUploadata(); - // Uploadata(); - int communityTypeValue = - _TypecommunityMap[_selectedtypecommunity] ?? 0; - - Get.toNamed(RouteName.addgroup, arguments: { - 'communityname': communitycontroller.text, - 'communitylocation': locationcontroller.text, - 'communitydescription': - communitydescrcontroller.text, - 'communitytype': communityTypeValue, - 'activityid': selectedactivityid, - 'communityprofilephoto': filePath, - 'communitybannerimage': bannerPath, - 'isedited' : false, - 'communityid' : "", - }); - } - }, - ), - sizedBoxHeight(25.h), - sizedBoxHeight(150.h), - ]), - )) - ])), + sizedBoxHeight(25.h), + + text16w400_FCFCFC("Community name*"), + sizedBoxHeight(15.h), + CustomTextFormField( + textEditingController: communitycontroller, + inputFormatters: [ + RemoveEmojiInputFormatter(), + // FilteringTextInputFormatter.allow(RegExp('[a-zA-Z ]')) + ], + hintText: 'Enter community name', + validator: (val) { + if (val == null || val.isEmpty) { + return 'Enter Community name'; + } + return null; + }, + ), + sizedBoxHeight(25.h), + text16w400_FCFCFC("Community description*"), + sizedBoxHeight(15.h), + CustomTextFormField( + textEditingController: communitydescrcontroller, + inputFormatters: [ + RemoveEmojiInputFormatter(), + // FilteringTextInputFormatter.allow(RegExp('[a-zA-Z ]')) + ], + hintText: 'Enter community description', + validator: (val) { + if (val == null || val.isEmpty) { + return 'Enter Community description'; + } + return null; + }, + ), + sizedBoxHeight(25.h), + text16w400_FCFCFC("Type of community*"), + sizedBoxHeight(15.h), + CustomDropDownRadio( + header: "", + title: "", + listData: const ['Public', 'Private', 'Secret'], + onItemSelected: _onItemSelected, + // (p0) {}, + leadingImage: SizedBox()), + // CommonDropdownradioBtn( + // hint: '', + // items: ['Public', 'Private', 'Secret'], + // showOtherOption: false), + sizedBoxHeight(25.h), + text16w400_FCFCFC("Location*"), + sizedBoxHeight(15.h), + CustomTextFormField( + textEditingController: locationcontroller, + inputFormatters: [ + RemoveEmojiInputFormatter(), + // FilteringTextInputFormatter.allow(RegExp('[a-zA-Z ]')) + ], + hintText: 'Enter location', + validator: (val) { + if (val == null || val.isEmpty) { + return 'Enter location'; + } + return null; + }, + ), + sizedBoxHeight(25.h), + text16w400_FCFCFC("Primary activity*"), + + sizedBoxHeight(20.h), + CustomDropDownRadio( + header: "", + title: "", + listData: _activitydrop, + // [ + // 'Sports', + // 'Hobby', + // ], + showOtherOption: false, + onItemSelected: getCatIdFromName, + leadingImage: SizedBox()), + + sizedBoxHeight(25.h), + sizedBoxHeight(25.h), + CustomButton( + text: "Create community", + onPressed: () { + // Get.toNamed(RouteName.addgroup); + if (bannerPath.isEmpty || + communitycontroller.text.isEmpty || + communitydescrcontroller.text.isEmpty || + _selectedtypecommunity.isEmpty || + locationcontroller.text.isEmpty || + selectedactivityid.isBlank!) { + utils.showToast('Please fill all fields'); + } else if (filePath.isEmpty) { + utils.showToast( + 'Please add community profile picture'); + } else { + print('done'); + // indiUploadata(); + // Uploadata(); + int communityTypeValue = + _TypecommunityMap[_selectedtypecommunity] ?? 0; + + Get.toNamed(RouteName.addgroup, arguments: { + 'communityname': communitycontroller.text, + 'communitylocation': locationcontroller.text, + 'communitydescription': + communitydescrcontroller.text, + 'communitytype': communityTypeValue, + 'activityid': selectedactivityid, + 'communityprofilephoto': filePath, + 'communitybannerimage': bannerPath, + 'isedited' : false, + 'communityid' : "", + }); + } + }, + ), + sizedBoxHeight(25.h), + sizedBoxHeight(150.h), + ]), + )) + ])), + ), ); } } diff --git a/lib/sidemenu/Community/MyCommunity/View/MyCommunity.dart b/lib/sidemenu/Community/MyCommunity/View/MyCommunity.dart index a83cec3..a358416 100644 --- a/lib/sidemenu/Community/MyCommunity/View/MyCommunity.dart +++ b/lib/sidemenu/Community/MyCommunity/View/MyCommunity.dart @@ -110,6 +110,11 @@ class _MyCommunityState extends State { super.initState(); } + void refreshData() { + setState(() { + myfuture = MyCommunityAPI().getMyCommunity(); + });} + @override Widget build(BuildContext context) { return WillPopScope( @@ -127,8 +132,15 @@ class _MyCommunityState extends State { customActionWidget: Row( children: [ GestureDetector( - onTap: () { - Get.toNamed(RouteName.newcommunity); + onTap: () async { + var result = await Get.toNamed(RouteName.newcommunity); + if (result != null && result) { + refreshData(); + // CommunityDetail().getCommunityDetail(CommunityId); + print("Updating community details..."); + // setState(() {}); + + } }, child: Container( height: 30.h, @@ -250,10 +262,16 @@ class _MyCommunityState extends State { return Padding( padding: EdgeInsets.only(bottom: 25.h), child: GestureDetector( - onTap: () { - Get.toNamed(RouteName.communityDetails, arguments: { + onTap: () async { + var result = await Get.toNamed(RouteName.communityDetails, arguments: { "CommunityID": joinnedComData.manageCommunityXid }); + + if (result != null && result) { + refreshData(); + print("Updating community details..."); + + } }, child: commonGlassUI( borderwidth: 0.9,