diff --git a/lib/Common/api_urls.dart b/lib/Common/api_urls.dart index 33af1f9..482250f 100644 --- a/lib/Common/api_urls.dart +++ b/lib/Common/api_urls.dart @@ -148,6 +148,12 @@ class ApiUrls { static const getpopularTagsdetails = "${baseUrl}fetch-popular-post"; + + static const postcreatecommunity = "${baseUrl}create-community"; + + static const getcommunityaddgroups = "${baseUrl}fetch-groups-to-add"; + + static const getcommunitygroups = "${baseUrl}fetch-community-all-groups"; } diff --git a/lib/Main_Screens/ProfileTab/EditProfile/View/ProfileTab.dart b/lib/Main_Screens/ProfileTab/EditProfile/View/ProfileTab.dart index 01b7234..21e4f2c 100644 --- a/lib/Main_Screens/ProfileTab/EditProfile/View/ProfileTab.dart +++ b/lib/Main_Screens/ProfileTab/EditProfile/View/ProfileTab.dart @@ -973,6 +973,7 @@ class _ProfileTabState extends State { arguments: { 'id': getEditProfileIndi!.data!.id, + 'iscommunity' : false, }); }, child: text16400white('View more')) diff --git a/lib/Utils/Common/ShimmerCommon.dart b/lib/Utils/Common/ShimmerCommon.dart index 8c2ce55..392b225 100644 --- a/lib/Utils/Common/ShimmerCommon.dart +++ b/lib/Utils/Common/ShimmerCommon.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:shimmer/shimmer.dart'; class ShimmerCommon extends StatelessWidget { @@ -12,15 +13,17 @@ class ShimmerCommon extends StatelessWidget { // Build shimmer effect for the body Widget _buildShimmerBody() { - return ListView.builder( + return ListView.separated( + separatorBuilder: (context, index) { + return SizedBox( + height: 10.h, + ); + }, shrinkWrap: true, scrollDirection: Axis.vertical, itemCount: 4, itemBuilder: (context, index) { - return SizedBox( - height: MediaQuery.of(context).size.height > 700 ? 220 : 270, - child: _buildShimmerInsightWidget(), - ); + return _buildShimmerInsightWidget(); }, ); } @@ -28,36 +31,121 @@ class ShimmerCommon extends StatelessWidget { // Build shimmer UI for InsightWidget Widget _buildShimmerInsightWidget() { return Shimmer.fromColors( - baseColor: Colors.grey[500]!, - highlightColor: Colors.grey[300]!, + baseColor: Colors.white12, + highlightColor: Colors.white24, child: Container( padding: const EdgeInsets.all(16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - width: double.infinity, - height: 20, - color: Colors.grey[500], + Row( + children: [ + CircleAvatar( + radius: 25.r, + backgroundColor: Colors.grey[300], + ), + SizedBox(width: 12.w), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 100.w, + height: 16.h, + color: Colors.grey[300], + ), + SizedBox(height: 5.h), + Row( + children: [ + Container( + width: 14.w, + height: 14.w, + color: Colors.grey[300], + ), + SizedBox(width: 7.w), + Container( + width: 60.w, + height: 12.h, + color: Colors.grey[300], + ), + SizedBox(width: 7.w), + Container( + width: 4.sp, + height: 4.sp, + color: Colors.grey[300], + ), + SizedBox(width: 6.w), + Container( + width: 30.w, + height: 12.h, + color: Colors.grey[300], + ), + ], + ) + ], + ), + Spacer(), + Container( + width: 16.w, + height: 18.h, + color: Colors.grey[300], + ), + SizedBox(width: 5.w), + ], ), - const SizedBox(height: 8), + SizedBox(height: 20.h), Container( + height: 360.h, width: double.infinity, - height: 20, - color: Colors.grey[500], - ), - const SizedBox(height: 8), - Container( - width: double.infinity, - height: 20, - color: Colors.grey[500], - ), - const SizedBox(height: 8), - Container( - width: double.infinity, - height: 20, - color: Colors.grey[500], + color: Colors.grey[300], ), + SizedBox(height: 20.h), + Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + // Container( + // width: 30.w, + // height: 30.h, + // color: Colors.grey[300], + // ), + CircleAvatar( + radius: 20.r, + backgroundColor: Colors.grey[300], + ), + SizedBox(width: 12.w), + Container( + width: 60.w, + height: 14.h, + color: Colors.grey[300], + ), + SizedBox(width: 20.w), + CircleAvatar( + radius: 20.r, + backgroundColor: Colors.grey[300], + ), + SizedBox(width: 12.w), + Container( + width: 60.w, + height: 14.h, + color: Colors.grey[300], + ), + SizedBox(width: 12.w), + CircleAvatar( + radius: 20.r, + backgroundColor: Colors.grey[300], + ), + ], + ), + SizedBox(height: 12.h), + Container( + height: 1.h, + width: double.infinity, + color: Colors.grey[300], + ), + SizedBox(height: 12.h), + ], + ) ], ), ), diff --git a/lib/sidemenu/Community/Group/view/Group.dart b/lib/sidemenu/Community/Group/view/Group.dart index d2e5ff0..b77bee3 100644 --- a/lib/sidemenu/Community/Group/view/Group.dart +++ b/lib/sidemenu/Community/Group/view/Group.dart @@ -4,6 +4,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:regroup/Common/CommonGlassmorphism.dart'; import 'package:regroup/Common/CommonWidget.dart'; +import 'package:regroup/sidemenu/Community/MyCommunity/view_model/getmethod.dart'; import 'package:regroup/sidemenu/view_model/getmethod.dart'; import 'package:regroup/Utils/Common/CommonAppbar.dart'; @@ -41,12 +42,13 @@ class _GroupState extends State { late Future myfuture; int id = Get.arguments["id"]; + bool iscommunity = Get.arguments["iscommunity"]; @override void initState() { // TODO: implement initState - myfuture = Sidegetmethod().getJoinedusergroups(id); + // myfuture = Sidegetmethod().getJoinedusergroups(id); super.initState(); } @@ -60,37 +62,69 @@ class _GroupState extends State { titleTxt: "Groups", ), 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), - ), - ) - ], - ); - } - if (snapshot.connectionState == ConnectionState.done) { - if (snapshot.hasError) { - return Center( - child: Text( - '${snapshot.error} occured', - style: TextStyle(fontSize: 18.spMin), - ), - ); - } - } - return joinedgroupsobj!.data!.isEmpty - ? _buildNoDataBody(context) - : _buildBody(context); - }, - ), + body: iscommunity == true + ? FutureBuilder( + future: Getcommunity().getCommunitygroups(1), + 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), + ), + ); + } + } + return communitygroupspobj!.data.isEmpty + ? _buildNoDataBody(context) + : _communitybuildBody(context); + }, + ) + : FutureBuilder( + future: Sidegetmethod().getJoinedusergroups(id), + 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), + ), + ); + } + } + return joinedgroupsobj!.data!.isEmpty + ? _buildNoDataBody(context) + : _buildBody(context); + }, + ), ); } @@ -371,6 +405,263 @@ class _GroupState extends State { ]); } + Widget _communitybuildBody(context) { + return Stack(children: [ + Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/png/Ellipse 1496.png"), + fit: BoxFit.fill)), + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16), + child: SingleChildScrollView( + child: Column( + children: [ + ListView.builder( + shrinkWrap: true, + physics: ScrollPhysics(), + itemCount: communitygroupspobj!.data.length, + itemBuilder: (context, index) { + return Padding( + padding: EdgeInsets.only(bottom: 25.h), + child: GestureDetector( + onTap: () {}, + child: commonGlassUI( + borderwidth: 0.9, + width: double.infinity, + height: 162.h, + borderRadius: BorderRadius.circular(10.r), + customWidget: Padding( + padding: EdgeInsets.symmetric( + horizontal: 16.w, vertical: 16.h), + child: Column( + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + height: 65.h, + width: 65.h, + decoration: BoxDecoration( + shape: BoxShape.circle, + // color: Colors.amber, + ), + child: + // Center( + // child: Image.asset(imagepath, fit: BoxFit.cover)), + communitygroupspobj! + .data[index] + .groups! + .groupImage == + null || + communitygroupspobj! + .data[index] + .groups! + .groupImage! + .isEmpty + ? CircleAvatar( + backgroundImage: AssetImage( + 'assets/images/png/img45.png', + ), + ) + : CircleAvatar( + backgroundImage: + NetworkImage( + communitygroupspobj! + .data[index] + .groups! + .groupImage!), + )), + sizedBoxWidth(13.w), + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + // Container( + // // width: 250.w, + // // color: Colors.red, + // width: double.infinity, + // child: + communitygroupspobj!.data[index].groups! + .title == + null || + communitygroupspobj!.data[index] + .groups!.title!.isEmpty + ? text18w700_FCFCFC('Regroup') + : SizedBox( + width: 200.w, + child: text18w700_FCFCFC( + communitygroupspobj! + .data[index] + .groups! + .title!), + ), + // ), + sizedBoxHeight(10.h), + communitygroupspobj!.data[index] + .communityData == + null || + communitygroupspobj! + .data[index] + .communityData! + .communityName! + .isEmpty + ? SizedBox() + : Row( + children: [ + Image.asset( + 'assets/images/png/community 1 (traced).png', + width: 18.w, + height: 18.h, + ), + sizedBoxWidth(4.w), + text14w400_FCFCFCblur( + communitygroupspobj! + .data[index] + .communityData! + .communityName!) + ], + ), + ], + ), + Spacer(), + PopupMenuButton( + surfaceTintColor: + const Color(0xFF222935), + constraints: BoxConstraints.tightFor( + width: 200.w), + offset: const Offset(0, 30), + color: const Color(0xFF222935), + tooltip: "", + itemBuilder: (BuildContext context) => + [ + PopupMenuItem( + onTap: () {}, + child: Padding( + padding: EdgeInsets.symmetric( + horizontal: 8.w), + child: Row( + children: [ + text14w400_FCFCFC( + "Mute group"), + const Spacer(), + Image.asset( + "assets/images/png/Black (1).png", + height: 18.h, + width: 18.w, + ) + ], + ), + ), + ), + const PopupMenuDivider(), + PopupMenuItem( + onTap: () {}, + child: Padding( + padding: EdgeInsets.symmetric( + horizontal: 8.w), + child: Row( + children: [ + text14w400_FCFCFC( + "Pin group"), + const Spacer(), + Image.asset( + "assets/images/png/f7_pin-fill (2).png", + height: 27.h, + width: 27.w, + ) + ], + ), + ), + ), + const PopupMenuDivider(), + PopupMenuItem( + onTap: () {}, + child: Padding( + padding: EdgeInsets.symmetric( + horizontal: 8.w), + child: Row( + children: [ + text14w400_FCFCFC( + "Make primary"), + const Spacer(), + Image.asset( + "assets/images/png/leave group.png", + height: 20.h, + width: 20.w, + ) + ], + ), + ), + ), + const PopupMenuDivider(), + PopupMenuItem( + onTap: () {}, + child: Padding( + padding: EdgeInsets.symmetric( + horizontal: 8.w), + child: Row( + children: [ + // text14w400_FCFCFC("Leave group"), + text14w400_D90B2E( + "Leave group"), + const Spacer(), + Image.asset( + "assets/images/png/LightGray22.png", + height: 18.h, + width: 18.w, + ) + ], + ), + ), + ), + ], + child: Image.asset( + "assets/images/png/Group 1000004071.png", + height: 18.h, + width: 20.w, + )), + ], + ), + sizedBoxHeight(16.h), + commonDivider(), + sizedBoxHeight(10.h), + Row( + children: [ + stackContainersGroups( + number: communitygroupspobj! + .data[index].groups!.totalMember + .toString(), + containerImages: communitygroupspobj! + .data[index].groups!.sevenMemberImage + .map((photo) => photo + .iamPrincipalData!.profilePhoto!) + .toList(), + ), + sizedBoxWidth(75.w), + communitygroupspobj!.data[index].groups == + null || + communitygroupspobj!.data[index] + .groups!.totalMember.isBlank! + ? SizedBox() + : text16w400_FCFCFC_blur( + '${communitygroupspobj!.data[index].groups!.totalMember} members', + ), + ], + ) + ], + ), + )), + ), + ); + }, + ) + ], + ))) + ]); + } + // Widget groupCard({ // required String? imagepath, // required String? title, diff --git a/lib/sidemenu/Community/MyCommunity/AddGroups.dart b/lib/sidemenu/Community/MyCommunity/AddGroups.dart index ff8d140..6d7dcba 100644 --- a/lib/sidemenu/Community/MyCommunity/AddGroups.dart +++ b/lib/sidemenu/Community/MyCommunity/AddGroups.dart @@ -1,15 +1,28 @@ +import 'dart:async'; +import 'dart:developer'; +import 'dart:io'; + +import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/widgets.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/CommonButton.dart'; import 'package:regroup/Common/CommonGlassmorphism.dart'; import 'package:regroup/Common/CommonWidget.dart'; +import 'package:regroup/Common/base_manager.dart'; import 'package:regroup/Utils/Common/CommonAppbar.dart'; +import 'package:regroup/Utils/Common/CustomNextButton.dart'; import 'package:regroup/Utils/Common/CustomTextformfield.dart'; import 'package:regroup/Utils/Common/sized_box.dart'; +import 'package:regroup/Utils/dialogs.dart'; import 'package:regroup/Utils/texts.dart'; import 'package:regroup/resources/routes/route_name.dart'; +import 'package:path/path.dart' as path; +import 'package:regroup/sidemenu/Community/MyCommunity/Model/communityaddgroupsModel.dart'; +import 'package:regroup/sidemenu/Community/MyCommunity/view_model/getmethod.dart'; +import 'package:regroup/sidemenu/Community/MyCommunity/view_model/postmethod.dart'; class AddGroup extends StatefulWidget { const AddGroup({super.key}); @@ -43,6 +56,99 @@ class _AddGroupState extends State { "subtitle": "Lorem ipsum dummy text", }, ]; + + int communitytype = Get.arguments["communitytype"]; + int activitytype = Get.arguments["activityid"]; + String communityname = Get.arguments["communityname"]; + String communitylocation = Get.arguments["communitylocation"]; + String communitydescription = Get.arguments["communitydescription"]; + List filepath = Get.arguments['communityprofilephoto']; + List bannerPath = Get.arguments['communitybannerimage']; + + StreamController searchcontroller = + StreamController(); + + @override + void initState() { + var updata = ""; + Getcommunity() + .getCommunityAddGroupsearch(updata, streamController: searchcontroller); + + super.initState(); + } + + @override + void dispose() { + searchcontroller.close(); + super.dispose(); + } + + final List _selectedIndices = []; + + void _onContainerTap(int id) { + setState(() { + if (_selectedIndices.contains(id)) { + _selectedIndices.remove(id); + } else { + _selectedIndices.add(id); + } + }); + } + + Uploadata() async { + utils.loader(); + List bannermedialist = []; + List profielpicturelist = []; + + for (var file in bannerPath.where((file) => file != null)) { + bannermedialist.add( + await MultipartFile.fromFile( + file!.path, + filename: path.basename(file.path), + ), + ); + } + + for (var file in filepath.where((file) => file != null)) { + profielpicturelist.add( + await MultipartFile.fromFile( + file!.path, + filename: path.basename(file.path), + ), + ); + } + + String selectedIndicesString = '[${_selectedIndices.join(',')}]'; + print('Selected Indices: $selectedIndicesString'); + + FormData formdata = FormData.fromMap({ + "community_profile_photo": profielpicturelist[0], + "community_banner_image": bannermedialist[0], + "community_name": communityname, + "community_location": communitylocation, + "community_description": communitydescription, + 'community_type_xid': communitytype, + 'activity_xid': activitytype, + 'manage_groups_xid': + selectedIndicesString.isEmpty ? null : selectedIndicesString, + }); + print('updata is ${formdata.toString()}'); + log('log is ${formdata.toString()}'); + final data = await PostMethodCommunity().postCreatecommunity(formdata); + if (data.status == ResponseStatus.SUCCESS) { + Get.back(); + print("community created"); + // Get.toNamed(RouteName.mycommunity); + Get.back(); + Get.back(); + return utils.showToast(data.message); + } else { + Get.back(); + print("community not created"); + return utils.showToast(data.message); + } + } + @override Widget build(BuildContext context) { return Scaffold( @@ -53,6 +159,17 @@ class _AddGroupState extends State { 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(); + }, + ), + ), body: Stack(children: [ Container( decoration: const BoxDecoration( @@ -81,122 +198,198 @@ class _AddGroupState extends State { ), ), 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), + // 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), ]), ), - ListView.builder( - shrinkWrap: true, - itemCount: groupData.length, - itemBuilder: (context, index) { - return Column( - children: [ - groupWidget( - index: index, - imagePath: groupData[index]["imagePath"], - title: groupData[index]["title"], - subtitle: groupData[index]["subtitle"], - isChecked: isCheckedList[index], - onCheckedChanged: (bool? value) { - isCheckedList[index] = value ?? false; - }, - ), - commonDivider(), - ], - ); - }, - ), + 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), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: CommonBtn( - text: "Add", - onTap: () { - Get.toNamed(RouteName.mycommunity); - }, - ), - ), ]), ) ])); } + Widget _buildNoDataBody(context) { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + "No Groups Found", + style: TextStyle( + color: Colors.white, + fontSize: 16.sp, + fontWeight: FontWeight.w600), + ) + ], + ), + ); + } + Widget groupWidget({ required int index, - required String imagePath, - required String title, - required String subtitle, + required String? imagePath, + required String? title, + required String? subtitle, required bool isChecked, required ValueChanged onCheckedChanged, }) { return Padding( padding: EdgeInsets.symmetric(vertical: 16.h, horizontal: 16.w), - child: Row(children: [ - CircleAvatar( - backgroundImage: AssetImage(imagePath), - radius: 20.r, - ), - sizedBoxWidth(10.w), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - text16w400_FCFCFC(title), - sizedBoxHeight(4.h), - text12w400_FCFCFC_blur(subtitle), - ], - ), - Spacer(), - Obx(() { - return commonGlassUI( - borderwidth: isCheckedList[index] ? 1.2 : 0.9, - borderRadius: BorderRadius.circular( 2), - height: 23.h, - width: 23.w, - opacity1: 0.24, - opacity2: 0.24, - borderColor: - isCheckedList[index] ? Color(0xFFD90B2E) : Color(0xFF434A53), - customWidget: Transform.scale( - scale: 1, - child: Checkbox( - side: BorderSide(color: Colors.transparent), - value: isCheckedList[index], - activeColor: Colors.transparent, - checkColor: Color(0xFFD90B2E), - onChanged: onCheckedChanged, + child: Row( + children: [ + imagePath == null || imagePath.isEmpty + ? CircleAvatar( + backgroundImage: AssetImage('assets/images/png/img2.png'), + radius: 20.r, + ) + : CircleAvatar( + backgroundImage: NetworkImage(imagePath), + radius: 20.r, ), - )); - }) - ]), + sizedBoxWidth(10.w), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + title == null || title.isEmpty + ? text16w400_FCFCFC('ReGroup') + : Text( + title, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 16.sp, + color: const Color(0xFFFCFCFC), + fontFamily: 'Helvetica', + fontWeight: FontWeight.w400), + ), + sizedBoxHeight(4.h), + subtitle == null || subtitle.isEmpty + ? text12w400_FCFCFC_blur('ReGroup') + : Text( + subtitle, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 12.sp, + color: const Color(0xFFFCFCFC).withOpacity(0.8), + fontFamily: 'Helvetica', + fontWeight: FontWeight.w400), + ), + ], + ), + ), + Spacer(), + commonGlassUI( + borderwidth: isChecked ? 1.2 : 0.9, + borderRadius: BorderRadius.circular(2), + height: 23.h, + width: 23.w, + opacity1: 0.24, + opacity2: 0.24, + borderColor: isChecked ? Color(0xFFD90B2E) : Color(0xFF434A53), + customWidget: Transform.scale( + scale: 1, + child: Checkbox( + side: BorderSide(color: Colors.transparent), + value: isChecked, + activeColor: Colors.transparent, + checkColor: Color(0xFFD90B2E), + onChanged: onCheckedChanged, + ), + ), + ), + ], + ), ); } } diff --git a/lib/sidemenu/Community/MyCommunity/Model/communityaddgroupsModel.dart b/lib/sidemenu/Community/MyCommunity/Model/communityaddgroupsModel.dart new file mode 100644 index 0000000..a7f27dc --- /dev/null +++ b/lib/sidemenu/Community/MyCommunity/Model/communityaddgroupsModel.dart @@ -0,0 +1,101 @@ +class CommunityAddgroupsModel { + CommunityAddgroupsModel({ + required this.status, + required this.statusCode, + required this.message, + required this.data, + }); + + final String? status; + final int? statusCode; + final String? message; + final List data; + + factory CommunityAddgroupsModel.fromJson(Map json){ + return CommunityAddgroupsModel( + status: json["status"], + statusCode: json["status_code"], + message: json["message"], + data: json["data"] == null ? [] : List.from(json["data"]!.map((x) => Datum.fromJson(x))), + ); + } + +} + +class Datum { + Datum({ + required this.id, + required this.title, + required this.groupImage, + required this.description, + required this.totalMember, + required this.sevenMemberImage, + }); + + final int? id; + final String? title; + final String? groupImage; + final String? description; + final int? totalMember; + final List sevenMemberImage; + + factory Datum.fromJson(Map json){ + return Datum( + id: json["id"], + title: json["title"], + groupImage: json["group_image"], + description: json["description"], + totalMember: json["total_member"], + sevenMemberImage: json["seven_member_image"] == null ? [] : List.from(json["seven_member_image"]!.map((x) => SevenMemberImage.fromJson(x))), + ); + } + +} + +class SevenMemberImage { + SevenMemberImage({ + required this.id, + required this.iamPrincipalXid, + required this.manageGroupXid, + required this.iamPrincipalData, + }); + + final int? id; + final int? iamPrincipalXid; + final int? manageGroupXid; + final IamPrincipalData? iamPrincipalData; + + factory SevenMemberImage.fromJson(Map json){ + return SevenMemberImage( + id: json["id"], + iamPrincipalXid: json["iam_principal_xid"], + manageGroupXid: json["manage_group_xid"], + iamPrincipalData: json["iam_principal_data"] == null ? null : IamPrincipalData.fromJson(json["iam_principal_data"]), + ); + } + +} + +class IamPrincipalData { + IamPrincipalData({ + required this.id, + required this.principalTypeXid, + required this.profilePhoto, + required this.isUserPinned, + }); + + final int? id; + final int? principalTypeXid; + final String? profilePhoto; + final bool? isUserPinned; + + factory IamPrincipalData.fromJson(Map json){ + return IamPrincipalData( + id: json["id"], + principalTypeXid: json["principal_type_xid"], + profilePhoto: json["profile_photo"], + isUserPinned: json["is_user_pinned"], + ); + } + +} diff --git a/lib/sidemenu/Community/MyCommunity/Model/communitygroupsModel.dart b/lib/sidemenu/Community/MyCommunity/Model/communitygroupsModel.dart new file mode 100644 index 0000000..09fcefd --- /dev/null +++ b/lib/sidemenu/Community/MyCommunity/Model/communitygroupsModel.dart @@ -0,0 +1,161 @@ +class CommunitygroupsModel { + CommunitygroupsModel({ + required this.status, + required this.statusCode, + required this.message, + required this.data, + }); + + final String? status; + final int? statusCode; + final String? message; + final List data; + + factory CommunitygroupsModel.fromJson(Map json){ + return CommunitygroupsModel( + status: json["status"], + statusCode: json["status_code"], + message: json["message"], + data: json["data"] == null ? [] : List.from(json["data"]!.map((x) => Datum.fromJson(x))), + ); + } + +} + +class Datum { + Datum({ + required this.manageCommunityXid, + required this.manageGroupXid, + required this.groups, + required this.communityData, + }); + + final int? manageCommunityXid; + final int? manageGroupXid; + final Groups? groups; + final CommunityData? communityData; + + factory Datum.fromJson(Map json){ + return Datum( + manageCommunityXid: json["manage_community_xid"], + manageGroupXid: json["manage_group_xid"], + groups: json["groups"] == null ? null : Groups.fromJson(json["groups"]), + communityData: json["community_data"] == null ? null : CommunityData.fromJson(json["community_data"]), + ); + } + +} + +class CommunityData { + CommunityData({ + required this.id, + required this.communityName, + required this.totalGroup, + required this.totalAnnouncements, + }); + + final int? id; + final String? communityName; + final int? totalGroup; + final int? totalAnnouncements; + + factory CommunityData.fromJson(Map json){ + return CommunityData( + id: json["id"], + communityName: json["community_name"], + totalGroup: json["total_group"], + totalAnnouncements: json["total_announcements"], + ); + } + +} + +class Groups { + Groups({ + required this.id, + required this.totalMember, + required this.sevenMemberImage, + required this.manageGroupTypeXid, + required this.title, + required this.backgroundImage, + required this.groupImage, + required this.location, + required this.link, + required this.description, + }); + + final int? id; + final int? totalMember; + final List sevenMemberImage; + final int? manageGroupTypeXid; + final String? title; + final String? backgroundImage; + final String? groupImage; + final String? location; + final String? link; + final String? description; + + factory Groups.fromJson(Map json){ + return Groups( + id: json["id"], + totalMember: json["total_member"], + sevenMemberImage: json["seven_member_image"] == null ? [] : List.from(json["seven_member_image"]!.map((x) => SevenMemberImage.fromJson(x))), + manageGroupTypeXid: json["manage_group_type_xid"], + title: json["title"], + backgroundImage: json["background_image"], + groupImage: json["group_image"], + location: json["location"], + link: json["link"], + description: json["description"], + ); + } + +} + +class SevenMemberImage { + SevenMemberImage({ + required this.id, + required this.iamPrincipalXid, + required this.manageGroupXid, + required this.iamPrincipalData, + }); + + final int? id; + final int? iamPrincipalXid; + final int? manageGroupXid; + final IamPrincipalData? iamPrincipalData; + + factory SevenMemberImage.fromJson(Map json){ + return SevenMemberImage( + id: json["id"], + iamPrincipalXid: json["iam_principal_xid"], + manageGroupXid: json["manage_group_xid"], + iamPrincipalData: json["iam_principal_data"] == null ? null : IamPrincipalData.fromJson(json["iam_principal_data"]), + ); + } + +} + +class IamPrincipalData { + IamPrincipalData({ + required this.id, + required this.principalTypeXid, + required this.profilePhoto, + required this.isUserPinned, + }); + + final int? id; + final int? principalTypeXid; + final String? profilePhoto; + final bool? isUserPinned; + + factory IamPrincipalData.fromJson(Map json){ + return IamPrincipalData( + id: json["id"], + principalTypeXid: json["principal_type_xid"], + profilePhoto: json["profile_photo"], + isUserPinned: json["is_user_pinned"], + ); + } + +} diff --git a/lib/sidemenu/Community/MyCommunity/NewCommunity.dart b/lib/sidemenu/Community/MyCommunity/NewCommunity.dart index f5f331f..bd23833 100644 --- a/lib/sidemenu/Community/MyCommunity/NewCommunity.dart +++ b/lib/sidemenu/Community/MyCommunity/NewCommunity.dart @@ -1,19 +1,32 @@ +import 'dart:developer'; import 'dart:io'; +import 'dart:async'; +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:get/get_connect/http/src/utils/utils.dart'; import 'package:regroup/Common/CommonButton.dart'; import 'package:regroup/Common/CommonGlassmorphism.dart'; +import 'package:regroup/Common/base_manager.dart'; +import 'package:regroup/Main_Screens/ProfileTab/EditProfile/Model/InterestModel.dart' + as primaryactlist; import 'package:regroup/Utils/Common/CommonAppbar.dart'; import 'package:regroup/Utils/Common/CommonDropdown.dart'; +import 'package:regroup/Utils/Common/CustomNextButton.dart'; import 'package:regroup/Utils/Common/CustomTextformfield.dart'; import 'package:regroup/Utils/Common/ImageUpload.dart'; import 'package:regroup/Utils/Common/sized_box.dart'; +import 'package:regroup/Utils/dialogs.dart'; import 'package:regroup/Utils/texts.dart'; import 'package:regroup/resources/routes/route_name.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 NewCommunity extends StatefulWidget { const NewCommunity({super.key}); @@ -28,214 +41,429 @@ class _NewCommunityState extends State { bool isImageAdded = false; bool isbannerAdded = false; + + TextEditingController communitycontroller = TextEditingController(); + TextEditingController locationcontroller = TextEditingController(); + TextEditingController communitydescrcontroller = TextEditingController(); + + final Map _TypecommunityMap = { + 'Public': 1, + 'Private': 2, + 'Secret': 3, + }; + + String _selectedtypecommunity = ''; + + void _onItemSelected(String value) { + setState(() { + _selectedtypecommunity = value; + }); + } + + primaryactlist.InterestModel? abilityModel; + List activity = []; + List _activitydrop = []; + + Future fetchActivitylist() async { + PrimaryActivityListApi abilityLsitAPI = PrimaryActivityListApi(); + ResponseData response = await abilityLsitAPI.getActivitylistApi(); + + if (response.status == ResponseStatus.SUCCESS) { + abilityModel = primaryactlist.InterestModel.fromJson(response.data!); + setState(() { + activity = abilityModel!.data ?? []; // Store the fetched cities + _activitydrop = + activity.map((platform) => platform.name.toString()).toList(); + }); + log(activity.toString()); + } else { + print('Failed to fetch abilities'); + } + } + + int? selectedactivityid; + + void getCatIdFromName(String selectedAbility) { + // Clear existing selections + selectedactivityid = null; + + // Find and add the ID of the selected ability + for (var activityItem in activity) { + if (selectedAbility == activityItem.name) { + selectedactivityid = activityItem.id!; + break; // Stop once the matching item is found + } + } + print('selected activity is $selectedactivityid'); + } + + @override + void initState() { + // TODO: implement initState + fetchActivitylist(); + super.initState(); + } + + // Uploadata() async { + // utils.loader(); + // List bannermedialist = []; + // List profielpicturelist = []; + + // for (var file in bannerPath.where((file) => file != null)) { + // bannermedialist.add( + // await MultipartFile.fromFile( + // file!.path, + // filename: path.basename(file.path), + // ), + // ); + // } + + // for (var file in filePath.where((file) => file != null)) { + // profielpicturelist.add( + // await MultipartFile.fromFile( + // file!.path, + // filename: path.basename(file.path), + // ), + // ); + // } + + // int communityTypeValue = _TypecommunityMap[_selectedtypecommunity] ?? 0; + + // FormData formdata = FormData.fromMap({ + // "community_profile_photo": profielpicturelist[0], + // "community_banner_image": bannermedialist[0], + // "community_name": communitycontroller.text, + // "community_location": locationcontroller.text, + // "community_description": communitydescrcontroller.text, + // 'community_type_xid': communityTypeValue, + // 'activity_xid': selectedactivityid, + // }); + // final data = await PostMethodCommunity().postCreatecommunity(formdata); + // if (data.status == ResponseStatus.SUCCESS) { + // Get.back(); + // print("community created"); + // Get.toNamed(RouteName.addgroup); + + // return utils.showToast(data.message); + // } else { + // Get.back(); + // print("community not created"); + // return utils.showToast(data.message); + // } + // } + @override Widget build(BuildContext context) { - return Scaffold( - // key: _scaffoldKey1, - backgroundColor: Color(0xFF222935), - extendBody: true, - resizeToAvoidBottomInset: false, - 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 GestureDetector( + onTap: () => FocusManager.instance.primaryFocus?.unfocus(), + child: Scaffold( + // key: _scaffoldKey1, + backgroundColor: Color(0xFF222935), + extendBody: true, + resizeToAvoidBottomInset: false, + appBar: CommonAppbar( + titleTxt: "New community", ), - 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, - true, - (result) { - var file = File(result); - - filePath.add(file); - isImageAdded = true; - 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(() {}); - }, - ); - }, - 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)), + 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 + bannerPath.clear(); + isbannerAdded = 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, ), - 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, + ), + ) + : 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); + + // 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(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), + ), + ), + ), + sizedBoxHeight(25.h), - text16w400_FCFCFC("Community name*"), - sizedBoxHeight(15.h), - CustomTextFormField( - validator: (val) { - if (val == null || val.isEmpty) { - return 'Enter Community name'; - } - return null; - }, - ), - sizedBoxHeight(25.h), - text16w400_FCFCFC("Type of community*"), - sizedBoxHeight(15.h), - CustomDropDownRadio( - header: "", - title: "", - listData: ['Public', 'Private', 'Secret'], - onItemSelected: (p0) {}, - leadingImage: SizedBox()), - // CommonDropdownradioBtn( - // hint: '', - // items: ['Public', 'Private', 'Secret'], - // showOtherOption: false), - sizedBoxHeight(25.h), - text16w400_FCFCFC("Location*"), - sizedBoxHeight(15.h), - CustomDropDownRadio( - header: "", - title: "", - listData: ['Public', 'Private', 'Secret'], - onItemSelected: (p0) {}, - leadingImage: SizedBox()), + 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(25.h), - text16w400_FCFCFC("Primary activity*"), + sizedBoxHeight(20.h), + CustomDropDownRadio( + header: "", + title: "", + listData: _activitydrop, + // [ + // 'Sports', + // 'Hobby', + // ], + showOtherOption: false, + onItemSelected: getCatIdFromName, + leadingImage: SizedBox()), - sizedBoxHeight(20.h), - CustomDropDownRadio( - header: "", - title: "", - listData: [ - 'Sports', - 'Hobby', - ], - showOtherOption: true, - onItemSelected: (p0) {}, - 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; - sizedBoxHeight(25.h), - sizedBoxHeight(25.h), - CommonBtn( - text: "Create community", - onTap: () { - Get.toNamed(RouteName.addgroup); - }, - ), - sizedBoxHeight(25.h), - sizedBoxHeight(150.h), - ]), - )) - ])); + Get.toNamed(RouteName.addgroup,arguments: { + 'communityname' : communitycontroller.text, + 'communitylocation' : locationcontroller.text, + 'communitydescription' : communitydescrcontroller.text, + 'communitytype' : communityTypeValue, + 'activityid' : selectedactivityid, + 'communityprofilephoto' : filePath, + 'communitybannerimage' : bannerPath, + }); + + } + }, + ), + sizedBoxHeight(25.h), + sizedBoxHeight(150.h), + ]), + )) + ])), + ); } } diff --git a/lib/sidemenu/Community/MyCommunity/view_model/getmethod.dart b/lib/sidemenu/Community/MyCommunity/view_model/getmethod.dart new file mode 100644 index 0000000..fc9ad63 --- /dev/null +++ b/lib/sidemenu/Community/MyCommunity/view_model/getmethod.dart @@ -0,0 +1,44 @@ +import 'dart:async'; +import 'dart:developer'; + +import 'package:regroup/Common/api_urls.dart'; +import 'package:regroup/Common/base_manager.dart'; +import 'package:regroup/Common/controller/data/network/network_api.dart'; +import 'package:regroup/sidemenu/Community/MyCommunity/Model/communityaddgroupsModel.dart'; +import 'package:regroup/sidemenu/Community/MyCommunity/Model/communitygroupsModel.dart'; + +CommunityAddgroupsModel? communityaddgroupobj; +CommunitygroupsModel? communitygroupspobj; + + + +class Getcommunity { + + Future> getCommunityAddGroupsearch(updata, + {required StreamController streamController}) async { + final response = + await NetworkApiServices().getApi( + "${ApiUrls.getcommunityaddgroups}?search=$updata", + + ); + + if (response.status == ResponseStatus.SUCCESS) { + communityaddgroupobj = CommunityAddgroupsModel.fromJson(response.data); + if (!streamController.isClosed) streamController.sink.add(communityaddgroupobj!); + } + return response; + } + + Future> getCommunitygroups(updata) async { + final response = await NetworkApiServices().getApi( + "${ApiUrls.getcommunitygroups}?manage_community_xid=$updata", + // optionalpar: false + ); + if (response.status == ResponseStatus.SUCCESS) { + communitygroupspobj = CommunitygroupsModel.fromJson(response.data); + log(communitygroupspobj!.data.toString()); + } + return response; + } + +} \ No newline at end of file diff --git a/lib/sidemenu/Community/MyCommunity/view_model/postmethod.dart b/lib/sidemenu/Community/MyCommunity/view_model/postmethod.dart new file mode 100644 index 0000000..6e43862 --- /dev/null +++ b/lib/sidemenu/Community/MyCommunity/view_model/postmethod.dart @@ -0,0 +1,18 @@ +import 'package:regroup/Common/api_urls.dart'; +import 'package:regroup/Common/base_manager.dart'; +import 'package:regroup/Common/controller/data/network/network_api.dart'; + +class PostMethodCommunity { + PostMethodCommunity(); + + Future> postCreatecommunity(updata) async { + print("updata is $updata"); + final response = await NetworkApiServices().postApi( + updata, + ApiUrls.postcreatecommunity, + ); + print("response is ${response.data}"); + print("response message is ${response.message}"); + return response; + } +} \ No newline at end of file diff --git a/lib/sidemenu/Community/MyCommunity/view_model/primaryactivity.dart b/lib/sidemenu/Community/MyCommunity/view_model/primaryactivity.dart new file mode 100644 index 0000000..818fd9c --- /dev/null +++ b/lib/sidemenu/Community/MyCommunity/view_model/primaryactivity.dart @@ -0,0 +1,32 @@ +import 'package:regroup/Common/api_urls.dart'; +import 'package:regroup/Common/base_manager.dart'; +import 'package:regroup/Common/controller/data/network/network_api.dart'; +import 'package:regroup/Main_Screens/ProfileTab/EditProfile/Model/InterestModel.dart'; + +InterestModel? interestlistobj; + + +class PrimaryActivityListApi { + PrimaryActivityListApi(); + var data = ""; + Future> getActivitylistApi() async { + final response = await NetworkApiServices().getApi( + ApiUrls.getinterestlist, + + ); + + if (response.status == ResponseStatus.SUCCESS) { + Map responseData = + Map.from(response.data); + if (responseData['status'] == "success") { + print("success"); + InterestModel interestlistobj = + InterestModel.fromJson(responseData); + } else { + // return ResponseData( + // responseData['message'], ResponseStatus.FAILED); + } + } + return response; + } +}