diff --git a/lib/Common/api_urls.dart b/lib/Common/api_urls.dart index d4c7974..7375ad9 100644 --- a/lib/Common/api_urls.dart +++ b/lib/Common/api_urls.dart @@ -176,6 +176,7 @@ class ApiUrls { static const geteditcommunity = "${baseUrl}edit-community"; + static const posteditcommunity = "${baseUrl}update-community"; diff --git a/lib/main.dart b/lib/main.dart index 1ca9fa7..171c6cc 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -125,7 +125,7 @@ class _MyAppState extends State with WidgetsBindingObserver { debugShowCheckedModeBanner: false, // initialRoute: RouteName.individualactivitystep2, - initialRoute: RouteName.individualactivitystep2, + initialRoute: RouteName.splashScreen, getPages: AppRoutes.appRoutes(), ), diff --git a/lib/sidemenu/Community/Admin/PopupItem/Community settings/EditCommunity/EditCommunity.dart b/lib/sidemenu/Community/Admin/PopupItem/Community settings/EditCommunity/EditCommunity.dart index 4e23501..264d57d 100644 --- a/lib/sidemenu/Community/Admin/PopupItem/Community settings/EditCommunity/EditCommunity.dart +++ b/lib/sidemenu/Community/Admin/PopupItem/Community settings/EditCommunity/EditCommunity.dart @@ -1,10 +1,11 @@ import 'dart:developer'; import 'dart:io'; +import 'package:dio/dio.dart'; import 'package:dotted_border/dotted_border.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; +import 'package:get/get.dart' hide MultipartFile, FormData; import 'package:regroup/Common/CommonGlassmorphism.dart'; import 'package:regroup/Common/base_manager.dart'; import 'package:regroup/Main_Screens/ProfileTab/EditProfile/Model/InterestModel.dart' @@ -20,8 +21,10 @@ import 'package:regroup/Utils/dialogs.dart'; import 'package:regroup/Utils/texts.dart'; import 'package:regroup/Utils/Common/CustomTextformfield.dart'; import 'package:regroup/sidemenu/Community/MyCommunity/view_model/getmethod.dart'; +import 'package:regroup/sidemenu/Community/MyCommunity/view_model/postmethod.dart'; import 'package:regroup/sidemenu/Community/MyCommunity/view_model/primaryactivity.dart'; import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart'; +import 'package:path/path.dart' as path; class EditCommunity extends StatefulWidget { const EditCommunity({super.key}); @@ -42,9 +45,6 @@ class _EditCommunityState extends State { @override void initState() { myfuture = Getcommunity().getCommunityeditpage(communityid); - // communitynameController.text = 'Active alliance network'; - // descriptionController.text = - // "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer ."; super.initState(); } @@ -98,7 +98,11 @@ class _EditCommunityState extends State { List activity = []; List _activitydrop = []; - String? selectedActivityName; + String? selectedActivityName = ''; + + bool isDataLoaded = false; + + List> _abilityMap = []; Future fetchActivitylist() async { PrimaryActivityListApi abilityListAPI = PrimaryActivityListApi(); @@ -110,26 +114,52 @@ class _EditCommunityState extends State { activity = abilityModel!.data ?? []; _activitydrop = activity.map((platform) => platform.name.toString()).toList(); + _abilityMap = activity.map((platform) { + return { + "id": platform.id, + "name": platform.name.toString(), + }; + }).toList(); }); - // Ensure dropdown list updates after setting the initial value - setState(() { - // Set the initial selected activity if data is available - int activitiesXids = - communityeditobj!.data!.communityData!.activityData!.id!; - selectedactivityid = activitiesXids; - selectedActivityName = activity - .firstWhere((item) => item.id == activitiesXids, - orElse: () => activity.first) - .name; - isactivityLoaded = true; - }); - log(activity.toString()); + // Debugging log for _abilityMap + print('Ability Map: $_abilityMap'); + + if (communityeditobj != null && communityeditobj!.data != null) { + int abilitiesXids = communityeditobj!.data!.communityData!.activityXid!; + selectedactivityid = abilitiesXids; + + String? name = await getSelectedName(selectedactivityid!); + setState(() { + selectedActivityName = name ?? ''; + isactivityLoaded = true; + isDataLoaded = true; // Mark data as loaded + }); + + // Debugging log for selectedActivityName + print('Selected activity ID is $selectedactivityid'); + print('Selected activity name is $selectedActivityName'); + } } else { - print('Failed to fetch abilities'); + print('Failed to fetch activities'); + setState(() { + isDataLoaded = false; // Ensure loader is not hidden in case of error + }); } } + Future getSelectedName(int selectedId) async { + print('Searching for ID: $selectedId in _abilityMap'); + + for (Map ability in _abilityMap) { + if (ability["id"] == selectedId) { + print('Found ability: ${ability["name"]}'); + return ability["name"] as String; + } + } + return null; + } + int? selectedactivityid; void getCatIdFromName(String selectedAbility) { @@ -140,451 +170,528 @@ class _EditCommunityState extends State { print('Selected activity ID is $selectedactivityid'); } + Uploadata() async { + utils.loader(); + List bannermedialist = []; + List profielpicturelist = []; + MultipartFile? imageFile; + + for (var file in bannerPath.where((file) => file != null)) { + bannermedialist.add( + await MultipartFile.fromFile( + file!.path, + filename: path.basename(file.path), + ), + ); + } + + if (filePath.isNotEmpty && filePath[0] != null) { + var profileFile = filePath[0]; + if (profileFile!.path.isNotEmpty) { + // Convert local file to MultipartFile + imageFile = await MultipartFile.fromFile( + profileFile.path, + filename: path.basename(profileFile.path), + ); + } else { + // Handle case where file path is empty + imageFile = await Helper.networkImageToMultipartFile( + communityeditobj!.data!.communityData!.communityProfilePhoto!, + ); + } + } else if (communityeditobj!.data!.communityData!.communityProfilePhoto != null) { + // Handle case where no file is provided, fallback to network image + imageFile = await Helper.networkImageToMultipartFile( + communityeditobj!.data!.communityData!.communityProfilePhoto!, + ); + } else { + // Handle case where no profile picture is provided + print('No profile picture provided.'); + return; + } + + int communityTypeValue = _typeCommunityMap[_selectedtypecommunity] ?? 0; + + FormData formdata = FormData.fromMap({ + "community_profile_photo": imageFile, + "community_banner_image": bannermedialist[0], + "community_name": communitynameController.text, + "community_location": locationcontroller.text, + "community_description": descriptionController.text, + 'community_type_xid': communityTypeValue, + 'activity_xid': selectedactivityid, + 'community_id': communityid, + }); + print('updata is ${formdata.toString()}'); + log('log is ${formdata.toString()}'); + final data = await PostMethodCommunity().postEditcommunity(formdata); + if (data.status == ResponseStatus.SUCCESS) { + Get.back(); + print("community updated"); + // Get.toNamed(RouteName.mycommunity); + Get.back(); + return utils.showToast(data.message); + } else { + Get.back(); + print("community not updated"); + return utils.showToast(data.message); + } + } + @override Widget build(BuildContext context) { - return Scaffold( - // key: _scaffoldKey1, - backgroundColor: Color(0xFF222935), - extendBody: true, - appBar: CommonAppbar( - titleTxt: "Edit community info", - ), - resizeToAvoidBottomInset: false, - body: FutureBuilder( - future: myfuture, - builder: (ctx, snapshot) { - if (snapshot.data == null) { - return const Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Center( - child: CircularProgressIndicator( - color: Color(0xFFC18948), + return GestureDetector( + onTap: () => FocusManager.instance.primaryFocus?.unfocus(), + child: Scaffold( + // key: _scaffoldKey1, + backgroundColor: Color(0xFF222935), + extendBody: true, + appBar: CommonAppbar( + titleTxt: "Edit community info", + ), + resizeToAvoidBottomInset: true, + body: FutureBuilder( + future: myfuture, + builder: (ctx, snapshot) { + if (snapshot.data == null) { + return const Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Center( + child: CircularProgressIndicator( + color: Color(0xFFC18948), + ), + ) + ], + ); + } + if (snapshot.connectionState == ConnectionState.done) { + if (snapshot.hasError) { + return Center( + child: Text( + '${snapshot.error} occured', + style: TextStyle(fontSize: 18.spMin), ), - ) - ], - ); - } - if (snapshot.connectionState == ConnectionState.done) { - if (snapshot.hasError) { - return Center( - child: Text( - '${snapshot.error} occured', - style: TextStyle(fontSize: 18.spMin), + ); + } + } + if (!isBannerLoaded) { + bannerimage = communityeditobj! + .data!.communityData!.communityBannerImage!; + _loadBannerImage(); // Call only if not already loaded + } + communitynameController.text = + communityeditobj!.data!.communityData!.communityName!; + descriptionController.text = + communityeditobj!.data!.communityData!.communityDescription!; + locationcontroller.text = + communityeditobj!.data!.communityData!.communityLocation!; + websitelinkcontroller.text = + communityeditobj!.data!.communityData!.communityDescription!; + var communityType = communityeditobj! + .data!.communityData!.communityTypeData!.name; + if (_selectedtypecommunity.isEmpty) { + _selectedtypecommunity = communityType ?? 'Public'; + } + if (!isactivityLoaded) { + fetchActivitylist(); + } + if (!isDataLoaded) { + // Show a loader or a placeholder until data is fully loaded + return const Center( + child: CircularProgressIndicator( + color: Color(0xFFC18948), ), ); } - } - if (!isBannerLoaded) { - bannerimage = - communityeditobj!.data!.communityData!.communityBannerImage!; - _loadBannerImage(); // Call only if not already loaded - } - communitynameController.text = - communityeditobj!.data!.communityData!.communityName!; - descriptionController.text = - communityeditobj!.data!.communityData!.communityDescription!; - locationcontroller.text = - communityeditobj!.data!.communityData!.communityLocation!; - websitelinkcontroller.text = - communityeditobj!.data!.communityData!.communityDescription!; - var communityType = - communityeditobj!.data!.communityData!.communityTypeData!.name; - if (_selectedtypecommunity.isEmpty) { - _selectedtypecommunity = communityType ?? 'Public'; - } - if (!isactivityLoaded) { - fetchActivitylist(); - } - return Stack(children: [ - Container( - decoration: const BoxDecoration( - image: DecorationImage( - image: AssetImage("assets/images/png/Ellipse 1496.png"), - fit: BoxFit.fill)), - ), - SingleChildScrollView( - child: Column(children: [ - // sizedBoxHeight(30.h), - Stack( - clipBehavior: Clip.none, - children: [ - Container( - height: 100.h, - width: 100.w, - decoration: BoxDecoration( - shape: BoxShape.circle, - border: Border.all( - color: Color(0xFF434A53), width: 0.5.w), + return Stack(children: [ + Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: + AssetImage("assets/images/png/Ellipse 1496.png"), + fit: BoxFit.fill)), + ), + SingleChildScrollView( + child: Column(children: [ + // sizedBoxHeight(30.h), + Stack( + clipBehavior: Clip.none, + children: [ + Container( + height: 100.h, + width: 100.w, + decoration: BoxDecoration( + shape: BoxShape.circle, + border: Border.all( + color: Color(0xFF434A53), width: 0.5.w), + ), + child: Center( + child: filePath.isNotEmpty + ? ClipOval( + child: SizedBox.fromSize( + size: Size.fromRadius(50.r), + child: filePath.isNotEmpty + ? Image.file( + filePath[0]!, + fit: BoxFit.cover, + width: double.infinity, + ) + : Image.asset( + 'assets/images/png/Ellipse 37.png', + fit: BoxFit.cover), + ), + ) + : ClipOval( + child: SizedBox.fromSize( + size: Size.fromRadius(50.r), + child: communityeditobj! + .data! + .communityData! + .communityProfilePhoto! + .isNotEmpty + ? Image.network( + communityeditobj! + .data! + .communityData! + .communityProfilePhoto!, + fit: BoxFit.cover, + errorBuilder: (context, error, + stackTrace) { + // Error handling when image fails to load + return Image.asset( + "assets/images/png/Ellipse 37.png", + fit: BoxFit.cover, + ); + }, + ) + : Image.asset( + 'assets/images/png/Ellipse 37.png', + fit: BoxFit.cover), + ), + )), ), - child: Center( - child: filePath.isNotEmpty - ? ClipOval( - child: SizedBox.fromSize( - size: Size.fromRadius(50.r), - child: filePath.isNotEmpty - ? Image.file( - filePath[0]!, - fit: BoxFit.cover, - width: double.infinity, - ) - : Image.asset( - 'assets/images/png/Ellipse 37.png', - fit: BoxFit.cover), - ), - ) - : ClipOval( - child: SizedBox.fromSize( - size: Size.fromRadius(50.r), - child: communityeditobj! - .data! - .communityData! - .communityProfilePhoto! - .isNotEmpty - ? Image.network( - communityeditobj! - .data! - .communityData! - .communityProfilePhoto!, - fit: BoxFit.cover, - errorBuilder: - (context, error, stackTrace) { - // Error handling when image fails to load - return Image.asset( - "assets/images/png/Ellipse 37.png", - fit: BoxFit.cover, - ); - }, - ) - : Image.asset( - 'assets/images/png/Ellipse 37.png', - fit: BoxFit.cover), - ), - )), - ), - Positioned( - right: -10, - bottom: 0, - 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(); + Positioned( + right: -10, + bottom: 0, + 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 { + filePath.clear(); + isImageAdded = false; + setState(() {}); } - } else { - filePath.clear(); - isImageAdded = false; - setState(() {}); - } - }, - ); - }, - child: Container( - height: 35.h, - width: 35.w, - decoration: BoxDecoration( - color: Color(0xFFD90B2E), - shape: BoxShape.circle, - border: Border.all( - color: Color(0xFFD90B2E), width: 0.5.w)), - child: Center( - child: Image.asset( - 'assets/images/png/cameraicon.png', - height: 14.h, - width: 15.w, + }, + ); + }, + child: Container( + height: 35.h, + width: 35.w, + decoration: BoxDecoration( + color: Color(0xFFD90B2E), + shape: BoxShape.circle, + border: Border.all( + color: Color(0xFFD90B2E), + width: 0.5.w)), + child: Center( + child: Image.asset( + 'assets/images/png/cameraicon.png', + height: 14.h, + width: 15.w, + ), ), ), - ), - )) - ], - ), - sizedBoxHeight(25.h), - text16w400_white("Edit community profile picture"), - sizedBoxHeight(30.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - text16w400_FCFCFC("Community banner image"), - sizedBoxHeight(16.h), - 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: 150.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: InkWell( - // onTap: () { - // setState(() { - // bannerPath.clear(); - // isbannerAdded = false; - // }); - // }, - // 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, - // ), - // ), - // ), - // ), - ], - ) - : GestureDetector( - onTap: () { - ImageUploadBottomSheet().showModal( - context, - false, - (result) { - if (result != null && - result.isNotEmpty) { - var file = File(result); + )) + ], + ), + sizedBoxHeight(25.h), + text16w400_white("Edit community profile picture"), + sizedBoxHeight(30.h), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + text16w400_FCFCFC("Community banner image"), + sizedBoxHeight(16.h), + 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: 150.h, + borderRadius: BorderRadius.circular(10.r), + customWidget: + bannerPath.isNotEmpty && isbannerAdded + ? Stack( + children: [ + Image.file( + bannerPath[0]!, + fit: BoxFit.cover, + width: double.infinity, + ), + ], + ) + : GestureDetector( + onTap: () { + ImageUploadBottomSheet().showModal( + context, + false, + (result) { + 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); + // 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: Padding( - padding: - EdgeInsets.symmetric(vertical: 16.h), - child: Column( - children: [ - Image.asset( - "assets/images/png/cameraicon2.png", - height: 36.h, - width: 36.w, + 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: Padding( + padding: EdgeInsets.symmetric( + vertical: 16.h), + child: Column( + children: [ + Image.asset( + "assets/images/png/cameraicon2.png", + height: 36.h, + width: 36.w, + ), + SizedBox(height: 10.h), + text14w400white( + 'Upload banner image'), + SizedBox(height: 8.h), + SizedBox( + width: 270.w, + child: Center( + child: text8w400_8A8A8A( + "Allowed file extensions: jpg, png, gif Max file size: 10 MB"), + ), + ), + ], + ), ), - SizedBox(height: 10.h), - text14w400white( - 'Upload banner image'), - SizedBox(height: 8.h), - SizedBox( - width: 270.w, - child: text8w400_8A8A8A( - "Allowed file extensions: jpg, png, gif Max file size: 10 MB"), + ), + ), + ), + sizedBoxHeight(16.w), + bannerPath.isNotEmpty && isbannerAdded + ? commonGlassUI( + width: double.infinity, + height: 60.h, + borderRadius: BorderRadius.circular(10.r), + customWidget: Center( + child: Padding( + padding: EdgeInsets.symmetric( + horizontal: 12.w), + child: Row( + children: [ + // Conditionally render image or placeholder + if (bannerPath.isNotEmpty && + isbannerAdded) + Container( + height: 40.h, + width: 40.w, + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular(5.r), + ), + child: Image.file( + bannerPath[0]!, + fit: BoxFit.cover, + width: double.infinity, + ), + ) + else + Container( + height: 40.h, + width: 40.w, + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular(5.r), + ), + child: Image.asset( + 'assets/images/png/img2.png', + fit: BoxFit.cover, + width: double.infinity, + ), + ), + SizedBox(width: 8.w), + Spacer(), + InkWell( + onTap: () { + setState(() { + // Clear the image and update the state + bannerPath.clear(); + isbannerAdded = false; + }); + // Optionally debug state values + print("bannerPath: $bannerPath"); + print( + "isbannerAdded: $isbannerAdded"); + }, + child: Image.asset( + 'assets/images/png/cancelicon.png', + height: 20.h, + width: 20.w, + ), ), ], ), ), ), + borderwidth: 1, + ) + : SizedBox(), + sizedBoxHeight(25.h), + text16w400_FCFCFC("Community name*"), + sizedBoxHeight(14.h), + CustomTextFormField( + textEditingController: communitynameController, + validator: (val) { + if (val == null || val.isEmpty) { + return 'Enter Community name'; + } + return null; + }, + hintText: 'Enter type of community', ), - ), - sizedBoxHeight(16.w), - bannerPath.isNotEmpty && isbannerAdded - ? commonGlassUI( - width: double.infinity, - height: 60.h, - borderRadius: BorderRadius.circular(10.r), - customWidget: Center( - child: Padding( - padding: - EdgeInsets.symmetric(horizontal: 12.w), - child: Row( - children: [ - // Conditionally render image or placeholder - if (bannerPath.isNotEmpty && - isbannerAdded) - Container( - height: 40.h, - width: 40.w, - decoration: BoxDecoration( - borderRadius: - BorderRadius.circular(5.r), - ), - child: Image.file( - bannerPath[0]!, - fit: BoxFit.cover, - width: double.infinity, - ), - ) - else - Container( - height: 40.h, - width: 40.w, - decoration: BoxDecoration( - borderRadius: - BorderRadius.circular(5.r), - ), - child: Image.asset( - 'assets/images/png/img2.png', - fit: BoxFit.cover, - width: double.infinity, - ), - ), - SizedBox(width: 8.w), - Spacer(), - InkWell( - onTap: () { - setState(() { - // Clear the image and update the state - bannerPath.clear(); - isbannerAdded = false; - }); - // Optionally debug state values - print("bannerPath: $bannerPath"); - print( - "isbannerAdded: $isbannerAdded"); - }, - child: Image.asset( - 'assets/images/png/cancelicon.png', - height: 20.h, - width: 20.w, - ), - ), - ], - ), - ), - ), - borderwidth: 1, - ) - : SizedBox(), - sizedBoxHeight(25.h), - text16w400_FCFCFC("Community name*"), - sizedBoxHeight(14.h), - CustomTextFormField( - textEditingController: communitynameController, - validator: (val) { - if (val == null || val.isEmpty) { - return 'Enter Community name'; - } - return null; - }, - hintText: 'Enter type of community', - ), - sizedBoxHeight(25.h), - text16w400_FCFCFC("Group description"), - sizedBoxHeight(14.h), - CustomTextFormField( - // maxlines: 3, - hintText: 'Enter description', - textEditingController: descriptionController, - ), - sizedBoxHeight(25.h), - text16w400_FCFCFC("Type of community*"), - sizedBoxHeight(14.h), - CustomDropDownRadio( - header: "", - title: "", - listData: _typeCommunityMap.keys.toList(), - onItemSelected: _onItemSelected, - leadingImage: SizedBox(), - initialSelectedValue: _selectedtypecommunity, - ), - sizedBoxHeight(25.h), - text16w400_FCFCFC("Location*"), - sizedBoxHeight(14.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(14.h), - CustomDropDownRadio( - showOtherOption: true, - header: "", - title: "", - listData: _activitydrop, - onItemSelected: getCatIdFromName, - leadingImage: SizedBox(), - initialSelectedValue: selectedActivityName.toString(), - ), - sizedBoxHeight(25.h), - text16w400_FCFCFC("Website link"), - sizedBoxHeight(14.h), - CustomTextFormField( - textEditingController: websitelinkcontroller, - validator: (val) { - if (!isValidWebBannerLink(val)) { - return 'Please enter a valid web banner link.'; - } - return null; - }, - hintText: 'Enter website link', - ), - sizedBoxHeight(25.h), - sizedBoxHeight(50.h), - CustomButton(text: 'Save changes', onPressed: () {}), - sizedBoxHeight(50.h), - ], - ), - ) - ]), - ) - ]); - }, - )); + sizedBoxHeight(25.h), + text16w400_FCFCFC("Group description"), + sizedBoxHeight(14.h), + CustomTextFormField( + // maxlines: 3, + hintText: 'Enter description', + textEditingController: descriptionController, + ), + sizedBoxHeight(25.h), + text16w400_FCFCFC("Type of community*"), + sizedBoxHeight(14.h), + CustomDropDownRadio( + header: "", + title: "", + listData: _typeCommunityMap.keys.toList(), + onItemSelected: _onItemSelected, + leadingImage: SizedBox(), + initialSelectedValue: _selectedtypecommunity, + ), + sizedBoxHeight(25.h), + text16w400_FCFCFC("Location*"), + sizedBoxHeight(14.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(14.h), + CustomDropDownRadio( + showOtherOption: false, + header: "", + title: "", + listData: _activitydrop, + onItemSelected: getCatIdFromName, + leadingImage: SizedBox(), + initialSelectedValue: selectedActivityName ?? '', + ), + sizedBoxHeight(25.h), + text16w400_FCFCFC("Website link"), + sizedBoxHeight(14.h), + CustomTextFormField( + textEditingController: websitelinkcontroller, + validator: (val) { + if (!isValidWebBannerLink(val)) { + return 'Please enter a valid web banner link.'; + } + return null; + }, + hintText: 'Enter website link', + ), + sizedBoxHeight(25.h), + sizedBoxHeight(50.h), + CustomButton( + text: 'Save changes', + onPressed: () { + if (bannerPath.isEmpty || + communitynameController.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'); + + Uploadata(); + } + }), + sizedBoxHeight(50.h), + ], + ), + ) + ]), + ) + ]); + }, + )), + ); } } diff --git a/lib/sidemenu/Community/MyCommunity/AddGroups.dart b/lib/sidemenu/Community/MyCommunity/AddGroups.dart index babe215..5c07b2c 100644 --- a/lib/sidemenu/Community/MyCommunity/AddGroups.dart +++ b/lib/sidemenu/Community/MyCommunity/AddGroups.dart @@ -152,151 +152,154 @@ class _AddGroupState extends State { @override Widget build(BuildContext context) { - return Scaffold( - // key: _scaffoldKey1, - backgroundColor: Color(0xFF222935), - extendBody: true, - appBar: CommonAppbar( - titleTxt: "Add groups", - ), - resizeToAvoidBottomInset: false, - bottomNavigationBar: Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 10.h), - child: CustomButton( - text: "Add", - onPressed: () { - // Get.toNamed(RouteName.mycommunity); - print('selected groups are ${_selectedIndices.toString()}'); - Uploadata(); - }, + return GestureDetector( + onTap: () => FocusManager.instance.primaryFocus?.unfocus(), + child: Scaffold( + // key: _scaffoldKey1, + backgroundColor: Color(0xFF222935), + extendBody: true, + appBar: CommonAppbar( + titleTxt: "Add groups", ), - ), - body: Stack(children: [ - Container( - decoration: const BoxDecoration( - image: DecorationImage( - image: AssetImage("assets/images/png/Ellipse 1496.png"), - fit: BoxFit.fill)), + resizeToAvoidBottomInset: false, + bottomNavigationBar: Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 10.h), + child: CustomButton( + text: "Add", + onPressed: () { + // Get.toNamed(RouteName.mycommunity); + print('selected groups are ${_selectedIndices.toString()}'); + Uploadata(); + }, + ), ), - SingleChildScrollView( - child: Column(children: [ - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - sizedBoxHeight(20.h), - CustomTextFormField( - leadingIcon: SizedBox( - height: 23, - width: 23, - child: Center( - child: Image.asset( - "assets/images/png/ion_search-outline.png", - height: 23, - width: 23, + body: Stack(children: [ + Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/png/Ellipse 1496.png"), + fit: BoxFit.fill)), + ), + SingleChildScrollView( + child: Column(children: [ + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + sizedBoxHeight(20.h), + CustomTextFormField( + leadingIcon: SizedBox( + height: 23, + width: 23, + child: Center( + child: Image.asset( + "assets/images/png/ion_search-outline.png", + height: 23, + width: 23, + ), ), ), + hintText: "Search groups", + onInput: (value) { + Getcommunity().getCommunityAddGroupsearch(value, + streamController: searchcontroller); + }, ), - hintText: "Search groups", - onInput: (value) { - Getcommunity().getCommunityAddGroupsearch(value, - streamController: searchcontroller); - }, - ), - sizedBoxHeight(25.h), - // Row( - // children: [ - // commonGlassUI( - // opacity1: 0.24, - // opacity2: 0.24, - // width: 50.w, - // height: 50.h, - // borderRadius: BorderRadius.circular( 100), - // customWidget: Center( - // child: Image.asset( - // "assets/images/png/Black.png", - // height: 30.h, - // width: 30.w, - // )), - // borderwidth: 0.5), - // sizedBoxWidth(8.w), - // text18w400_FCFCFC("Create group"), - // Spacer(), - // Icon( - // Icons.arrow_forward_ios_outlined, - // color: Colors.white, - // size: 14.sp, - // ), - // ], - // ), - // sizedBoxHeight(25.h), - sizedBoxHeight(30.h), - text18w700white("Existing Groups"), - sizedBoxHeight(20.h), - ]), - ), - StreamBuilder( - stream: searchcontroller.stream, - builder: (ctx, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { - return const Center( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - CircularProgressIndicator(), - ], - ), - ); - } else if (snapshot.hasError) { - return Center( - child: Text( - '${snapshot.error} occured', - style: TextStyle(fontSize: 18.sp), - ), - ); - } else { - return communityaddgroupobj!.data.isEmpty - ? _buildNoDataBody(context) - : ListView.builder( - shrinkWrap: true, - physics: ScrollPhysics(), - itemCount: communityaddgroupobj!.data.length, - itemBuilder: (context, index) { - final isChecked = _selectedIndices.contains( - communityaddgroupobj!.data[index].id!); - return Column( - children: [ - groupWidget( - index: - communityaddgroupobj!.data[index].id!, - imagePath: communityaddgroupobj! - .data[index].groupImage ?? - '', - title: communityaddgroupobj! - .data[index].title!, - subtitle: communityaddgroupobj! - .data[index].description!, - isChecked: isChecked, - // isCheckedList[index], - onCheckedChanged: (bool? value) { - // isCheckedList[index] = value ?? false; - _onContainerTap(communityaddgroupobj! - .data[index].id!); - }, - ), - commonDivider(), - ], - ); - }, - ); - } - }), - sizedBoxHeight(50.h), - ]), - ) - ])); + sizedBoxHeight(25.h), + // Row( + // children: [ + // commonGlassUI( + // opacity1: 0.24, + // opacity2: 0.24, + // width: 50.w, + // height: 50.h, + // borderRadius: BorderRadius.circular( 100), + // customWidget: Center( + // child: Image.asset( + // "assets/images/png/Black.png", + // height: 30.h, + // width: 30.w, + // )), + // borderwidth: 0.5), + // sizedBoxWidth(8.w), + // text18w400_FCFCFC("Create group"), + // Spacer(), + // Icon( + // Icons.arrow_forward_ios_outlined, + // color: Colors.white, + // size: 14.sp, + // ), + // ], + // ), + // sizedBoxHeight(25.h), + sizedBoxHeight(30.h), + text18w700white("Existing Groups"), + sizedBoxHeight(20.h), + ]), + ), + StreamBuilder( + stream: searchcontroller.stream, + builder: (ctx, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const Center( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + CircularProgressIndicator(), + ], + ), + ); + } else if (snapshot.hasError) { + return Center( + child: Text( + '${snapshot.error} occured', + style: TextStyle(fontSize: 18.sp), + ), + ); + } else { + return communityaddgroupobj!.data.isEmpty + ? _buildNoDataBody(context) + : ListView.builder( + shrinkWrap: true, + physics: ScrollPhysics(), + itemCount: communityaddgroupobj!.data.length, + itemBuilder: (context, index) { + final isChecked = _selectedIndices.contains( + communityaddgroupobj!.data[index].id!); + return Column( + children: [ + groupWidget( + index: + communityaddgroupobj!.data[index].id!, + imagePath: communityaddgroupobj! + .data[index].groupImage ?? + '', + title: communityaddgroupobj! + .data[index].title!, + subtitle: communityaddgroupobj! + .data[index].description!, + isChecked: isChecked, + // isCheckedList[index], + onCheckedChanged: (bool? value) { + // isCheckedList[index] = value ?? false; + _onContainerTap(communityaddgroupobj! + .data[index].id!); + }, + ), + commonDivider(), + ], + ); + }, + ); + } + }), + sizedBoxHeight(50.h), + ]), + ) + ])), + ); } Widget _buildNoDataBody(context) { diff --git a/lib/sidemenu/Community/MyCommunity/NewCommunity.dart b/lib/sidemenu/Community/MyCommunity/NewCommunity.dart index 7c39a31..d8df538 100644 --- a/lib/sidemenu/Community/MyCommunity/NewCommunity.dart +++ b/lib/sidemenu/Community/MyCommunity/NewCommunity.dart @@ -160,7 +160,7 @@ class _NewCommunityState extends State { // key: _scaffoldKey1, backgroundColor: Color(0xFF222935), extendBody: true, - resizeToAvoidBottomInset: false, + resizeToAvoidBottomInset: true, appBar: CommonAppbar( titleTxt: "New community", ), diff --git a/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart b/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart index 2dc972a..8c822f4 100644 --- a/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart +++ b/lib/sidemenu/Community/MyCommunity/View/CommunityDetails.dart @@ -425,7 +425,11 @@ class _CommunityDetailsState extends State { sizedBoxHeight(20.h), GestureDetector( onTap: () { - Get.toNamed(RouteName.addgroup); + // Get.toNamed(RouteName.addgroup); + Get.toNamed(RouteName.group, arguments: { + 'id': CommunityId, + 'iscommunity': true, + }); }, child: commonGlassUI( width: double.infinity, diff --git a/lib/sidemenu/Community/MyCommunity/view_model/postmethod.dart b/lib/sidemenu/Community/MyCommunity/view_model/postmethod.dart index 6e43862..5015f0a 100644 --- a/lib/sidemenu/Community/MyCommunity/view_model/postmethod.dart +++ b/lib/sidemenu/Community/MyCommunity/view_model/postmethod.dart @@ -15,4 +15,15 @@ class PostMethodCommunity { print("response message is ${response.message}"); return response; } + + Future> postEditcommunity(updata) async { + print("updata is $updata"); + final response = await NetworkApiServices().postApi( + updata, + ApiUrls.posteditcommunity, + ); + print("response is ${response.data}"); + print("response message is ${response.message}"); + return response; + } } \ No newline at end of file