473 lines
18 KiB
Dart
473 lines
18 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:regroup/Common/CommonButton.dart';
|
|
import 'package:regroup/Common/base_manager.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/onboarding/Signup/Model/Onboarding/Individual/GroupModel.dart';
|
|
import 'package:regroup/onboarding/Signup/view_model/getmethod.dart';
|
|
import 'package:regroup/onboarding/Signup/view_model/postmethod.dart';
|
|
import 'package:regroup/resources/routes/route_name.dart';
|
|
import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart';
|
|
|
|
class SelectIndividualGroup extends StatefulWidget {
|
|
const SelectIndividualGroup({super.key});
|
|
|
|
@override
|
|
State<SelectIndividualGroup> createState() => _SelectIndividualGroupState();
|
|
}
|
|
|
|
class _SelectIndividualGroupState extends State<SelectIndividualGroup> {
|
|
StreamController<GrouplistModel> searchcontroller = StreamController();
|
|
|
|
@override
|
|
void initState() {
|
|
var updata = "";
|
|
Getonboard().getGroupsearch(updata, streamController: searchcontroller);
|
|
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
searchcontroller.close();
|
|
super.dispose();
|
|
}
|
|
|
|
final List<int> _selectedIndices = [];
|
|
|
|
void _onContainerTap(int id) {
|
|
setState(() {
|
|
if (_selectedIndices.contains(id)) {
|
|
_selectedIndices.remove(id);
|
|
} else {
|
|
_selectedIndices.add(id);
|
|
}
|
|
});
|
|
}
|
|
|
|
Uploadata() async {
|
|
utils.loader();
|
|
String selectedIndicesString = '[${_selectedIndices.join(',')}]';
|
|
print('Selected Indices: $selectedIndicesString');
|
|
Map<String, dynamic> updata = {
|
|
"manage_group_xid": selectedIndicesString,
|
|
};
|
|
print('Payload: $updata');
|
|
|
|
final data = await Onboard().postGroups(updata);
|
|
if (data.status == ResponseStatus.SUCCESS) {
|
|
// Get.back();
|
|
print("groups selected");
|
|
// Get.toNamed(RouteName.individualcommunitystep4);
|
|
Get.toNamed(RouteName.communitycommitscreen);
|
|
|
|
return utils.showToast(data.message);
|
|
} else {
|
|
Get.back();
|
|
print("Not done");
|
|
return utils.showToast(data.message);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GestureDetector(
|
|
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
|
|
child: Scaffold(
|
|
backgroundColor: const Color.fromARGB(255, 18, 32, 47),
|
|
body: 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.w, vertical: 40.h),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Align(
|
|
alignment: Alignment.topRight,
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
Get.toNamed(RouteName.communitycommitscreen);
|
|
},
|
|
child: Text(
|
|
'Skip',
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 16.sp,
|
|
fontFamily: 'Helvetica',
|
|
fontWeight: FontWeight.w400,
|
|
decoration: TextDecoration.underline,
|
|
decorationColor: Colors.white),
|
|
),
|
|
),
|
|
),
|
|
sizedBoxHeight(30.h),
|
|
Align(
|
|
alignment: Alignment.center,
|
|
child: text16400white('Step 3 of 3')),
|
|
sizedBoxHeight(20.h),
|
|
Container(
|
|
width: double.infinity,
|
|
height: 25.h,
|
|
decoration: ShapeDecoration(
|
|
shape: RoundedRectangleBorder(
|
|
side: const BorderSide(
|
|
width: 1, color: Color(0xFF434A53)),
|
|
borderRadius: BorderRadius.circular(30),
|
|
),
|
|
),
|
|
child: Padding(
|
|
padding: EdgeInsets.symmetric(
|
|
horizontal: 8.w, vertical: 2.h),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: Container(
|
|
// width: 216.w,
|
|
height: 15.h,
|
|
decoration: ShapeDecoration(
|
|
gradient: const LinearGradient(
|
|
begin: Alignment(0.98, -0.21),
|
|
end: Alignment(-0.98, 0.21),
|
|
colors: [
|
|
Color(0xA5D90B2E),
|
|
Color(0x42D90B2E)
|
|
],
|
|
),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(30),
|
|
),
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
Container(
|
|
width: 15,
|
|
height: 15,
|
|
decoration: ShapeDecoration(
|
|
gradient: const LinearGradient(
|
|
begin: Alignment(0.98, -0.21),
|
|
end: Alignment(-0.98, 0.21),
|
|
colors: [
|
|
Color(0xFFD90B2E),
|
|
Color(0x60D90B2E)
|
|
],
|
|
),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius:
|
|
BorderRadius.circular(30),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
)),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
sizedBoxHeight(40.h),
|
|
Center(
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
text20400white('Find your group'),
|
|
sizedBoxWidth(5.w),
|
|
InkWell(
|
|
onTap: () {
|
|
groupBottomsheet();
|
|
},
|
|
child: Image.asset(
|
|
'assets/images/png/informationicon.png'))
|
|
],
|
|
)),
|
|
sizedBoxHeight(10.w),
|
|
Center(
|
|
child: Container(
|
|
width: 108.w,
|
|
decoration: const ShapeDecoration(
|
|
shape: RoundedRectangleBorder(
|
|
side: BorderSide(
|
|
width: 1,
|
|
strokeAlign: BorderSide.strokeAlignCenter,
|
|
color: Color(0xFF858585),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
sizedBoxHeight(30.h),
|
|
CustomTextFormField(
|
|
// textEditingController: searchcontroller,
|
|
texttype: TextInputType.text,
|
|
hintText: "Search groups",
|
|
leadingIcon:
|
|
// const Icon(Icons.mail_outline),
|
|
// SvgPicture.asset(
|
|
// // width: 23.w,
|
|
// // height: 23.h,
|
|
// 'assets/images/svg/search.svg',
|
|
// ),
|
|
Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
|
child: const Icon(
|
|
Icons.search,
|
|
size: 35,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
// validatorText: "Enter your full name",
|
|
inputFormatters: [
|
|
// LengthLimitingTextInputFormatter(20),
|
|
RemoveEmojiInputFormatter(),
|
|
],
|
|
onInput: (value) {
|
|
// Onboard().postGroupsearch({"search": value},
|
|
// streamController: searchcontroller);
|
|
// searchGroups(value!);
|
|
Getonboard().getGroupsearch(value,
|
|
streamController: searchcontroller);
|
|
},
|
|
),
|
|
sizedBoxHeight(30.h),
|
|
StreamBuilder<GrouplistModel>(
|
|
stream: searchcontroller.stream,
|
|
builder: (ctx, snapshot) {
|
|
if (snapshot.connectionState ==
|
|
ConnectionState.waiting) {
|
|
// Display shimmer effect while waiting for data
|
|
return const Center(
|
|
child: CircularProgressIndicator());
|
|
} else if (snapshot.hasError) {
|
|
// Handle error state
|
|
return Center(
|
|
child: Text(
|
|
'${snapshot.error} occurred',
|
|
style: const TextStyle(fontSize: 18),
|
|
),
|
|
);
|
|
} else {
|
|
// Data has been loaded, show actual UI
|
|
return grouplistobj!.data!.isEmpty
|
|
? _buildNoDataBody(context)
|
|
: Expanded(
|
|
child: GridView.builder(
|
|
physics: const ScrollPhysics(),
|
|
gridDelegate:
|
|
const SliverGridDelegateWithFixedCrossAxisCount(
|
|
crossAxisCount: 2,
|
|
crossAxisSpacing: 12.0,
|
|
mainAxisSpacing: 12.0,
|
|
),
|
|
itemCount: grouplistobj!.data!.length,
|
|
itemBuilder: (context, index) {
|
|
return SizedBox(
|
|
height:
|
|
150.0, // Adjust this height according to your design
|
|
child: GroupSelect(
|
|
titleString:
|
|
grouplistobj!.data![index].title!,
|
|
image: grouplistobj
|
|
?.data?[index]?.groupImage ??
|
|
'',
|
|
index: grouplistobj!.data![index].id!,
|
|
isSelected: _selectedIndices.contains(
|
|
grouplistobj!.data![index].id!),
|
|
onTap: _onContainerTap,
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
},
|
|
),
|
|
// sizedBoxHeight(40.h),
|
|
CustomButton(
|
|
text: "Continue",
|
|
onPressed: () {
|
|
// Get.toNamed(RouteName.individualcommunitystep4);
|
|
if (_selectedIndices.isEmpty) {
|
|
utils.showToast('Please select group');
|
|
} else {
|
|
print(_selectedIndices.toString());
|
|
// String selectedIndicesString =
|
|
// _selectedIndices.join(',');
|
|
// print(
|
|
// 'Selected Indices: [$selectedIndicesString]');
|
|
Uploadata();
|
|
}
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
)),
|
|
);
|
|
}
|
|
|
|
Widget _buildNoDataBody(context) {
|
|
return Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
"No Data Found",
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 16.sp,
|
|
fontWeight: FontWeight.w600),
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
void groupBottomsheet() {
|
|
Get.bottomSheet(
|
|
isScrollControlled: true,
|
|
Container(
|
|
// height: 700.h,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(14.r),
|
|
color: const Color(0xFF222935)),
|
|
child: Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 20.h),
|
|
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
|
// sizedBoxHeight(20.h),
|
|
Row(
|
|
children: [
|
|
Spacer(),
|
|
Image.asset(
|
|
"assets/images/png/x-circle.png",
|
|
height: 28.h,
|
|
width: 28.w,
|
|
),
|
|
],
|
|
),
|
|
Image.asset(
|
|
"assets/images/png/Group 1000004385.png",
|
|
height: 185.h,
|
|
width: 185.w,
|
|
),
|
|
|
|
sizedBoxHeight(20.h),
|
|
text16w400_FCFCFC(
|
|
'''Use this screen to find specific groups within your area. Groups span any club, society or hobbyist group e.g. sports clubs, social clubs, service clubs, musical groups or voluntary societies. If you are still exploring your options, you can skip this step. You can always join or create new groups later.''',
|
|
textAlign: TextAlign.center),
|
|
sizedBoxHeight(20.h),
|
|
|
|
SizedBox(
|
|
width: 239.w,
|
|
child: CommonBtn(
|
|
text: "Understood",
|
|
onTap: () {
|
|
Get.back();
|
|
},
|
|
)),
|
|
|
|
// sizedBoxHeight(40.h)
|
|
]))));
|
|
}
|
|
}
|
|
|
|
class GroupSelect extends StatelessWidget {
|
|
final String titleString;
|
|
final String? image;
|
|
final int index;
|
|
final Function(int) onTap;
|
|
final bool isSelected;
|
|
|
|
GroupSelect({
|
|
Key? key,
|
|
required this.titleString,
|
|
required this.image,
|
|
required this.index,
|
|
required this.onTap,
|
|
required this.isSelected,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(crossAxisAlignment: CrossAxisAlignment.center, children: [
|
|
Container(
|
|
width: 72.w,
|
|
height: 72.h,
|
|
decoration: ShapeDecoration(
|
|
image: image == null || image!.isEmpty
|
|
? const DecorationImage(
|
|
image: AssetImage("assets/images/png/groupindividual3.png"),
|
|
fit: BoxFit.fill,
|
|
)
|
|
: DecorationImage(
|
|
image: NetworkImage(image!),
|
|
fit: BoxFit.fill,
|
|
),
|
|
shape:
|
|
RoundedRectangleBorder(borderRadius: BorderRadius.circular(100)),
|
|
),
|
|
),
|
|
const SizedBox(height: 15.0),
|
|
Text(
|
|
titleString,
|
|
style: const TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 12.0,
|
|
overflow: TextOverflow.ellipsis),
|
|
),
|
|
const SizedBox(height: 15.0),
|
|
GestureDetector(
|
|
onTap: () => onTap(index),
|
|
child: Container(
|
|
width: 169.w,
|
|
height: 23.h,
|
|
decoration: ShapeDecoration(
|
|
gradient: isSelected
|
|
? LinearGradient(colors: [
|
|
Color(0xFFD90B2E),
|
|
Color(0xFFD90B2E),
|
|
])
|
|
: LinearGradient(
|
|
begin: Alignment(0.98, -0.21),
|
|
end: Alignment(-0.98, 0.21),
|
|
colors: [
|
|
Colors.white.withOpacity(0.04),
|
|
Colors.white.withOpacity(0.05)
|
|
],
|
|
),
|
|
shape: RoundedRectangleBorder(
|
|
side: isSelected
|
|
? BorderSide(width: 1.w, color: Colors.transparent)
|
|
: BorderSide(width: 1.w, color: Color(0xFF434A53)),
|
|
borderRadius: BorderRadius.circular(30),
|
|
),
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
isSelected
|
|
? text10400white("Leave group")
|
|
: text10400white("Join")
|
|
],
|
|
),
|
|
),
|
|
),
|
|
]);
|
|
}
|
|
}
|