Files
Regroup/lib/Feed Module/Main_Screens/CalenderTab/AddEvent/AddEvent.dart
2024-08-01 13:35:58 +05:30

546 lines
24 KiB
Dart

import 'dart:io';
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:regroup/Common/CommonButton.dart';
import 'package:regroup/Common/CommonDropDown.dart';
import 'package:regroup/Common/CommonGlassmorphism.dart';
import 'package:regroup/Common/CommonWidget.dart';
import 'package:regroup/Utils/Common/CommonAppbar.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/texts.dart';
import 'package:regroup/resources/routes/route_name.dart';
import 'package:intl/intl.dart';
class AddEvent extends StatefulWidget {
const AddEvent({super.key});
@override
State<AddEvent> createState() => _AddEventState();
}
class _AddEventState extends State<AddEvent> {
RxBool isChecked = false.obs;
List<File?> bannerPath = [];
bool isbannerAdded = false;
TextEditingController dateController = TextEditingController();
TextEditingController dateController2 = TextEditingController();
TimeOfDay? starttime = const TimeOfDay(hour: 15, minute: 0);
TimeOfDay? endtime = const TimeOfDay(hour: 15, minute: 0);
String formatTimeOfDay(TimeOfDay time) {
final now = DateTime.now();
final dt = DateTime(now.year, now.month, now.day, time.hour, time.minute);
final format =
MediaQuery.of(context).alwaysUse24HourFormat ? 'HH:mm' : 'h:mm a';
return DateFormat(format).format(dt);
}
@override
Widget build(BuildContext context) {
return Scaffold(
// key: _scaffoldKey1,
backgroundColor: const Color(0xFF222935),
extendBody: true,
resizeToAvoidBottomInset: false,
appBar: const CommonAppbar(
titleTxt: "",
),
body: Stack(children: [
Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/png/Ellipse 1496.png"),
fit: BoxFit.fill)),
), SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text16400white("Event Title"),
sizedBoxHeight(14.h),
CustomTextFormField(
leadingIcon: SizedBox(
height: 22.h,
width: 18.w,
child: Center(
child: Image.asset(
"assets/images/png/Vector (5)12.png",
fit: BoxFit.cover,
height: 22.h,
width: 18.w,
),
),
),
hintText: "Tri-sport challenge",
),
text16400white("Event image"),
sizedBoxHeight(20.h),
GestureDetector(
onTap: () {
ImageUploadBottomSheet().showModal(
context,
false,
(result) {
var file = File(result);
bannerPath.add(file);
isbannerAdded = true;
setState(() {});
},
);
},
child: DottedBorder(
strokeWidth: 1,
dashPattern: const [7, 4],
borderType: BorderType.RRect,
radius: Radius.circular(14.r),
color: const Color(0xFF434A53),
child: commonGlassUI(
// border: 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: const Color(0xFF7E7E7E),
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(5)),
),
child: const 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 event image"),
sizedBoxHeight(8.h),
text8w400_8A8A8A(
"Allowed file extensions: jpg, png, gif Max file size: 10 MB"),
],
),
),
),
),
),
sizedBoxHeight(20.h),
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: [
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,
),
),
sizedBoxWidth(8.w),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
text14400white("Event1.png"),
sizedBoxHeight(2.h),
text12w400_FCFCFC_blur("10 kb")
],
),
const Spacer(),
Image.asset(
'assets/images/png/cancelicon.png',
height: 20.h,
width: 20.w,
)
]),
),
),
borderwidth: 1),
sizedBoxHeight(20.h),
text16400white("Type of event"),
sizedBoxHeight(14.h),
CommonDropdownBtn(
hint: 'Race',
items: const ['', ''],
leadingImage: SizedBox(
height: 22.h,
width: 18.w,
child: Center(
child: Image.asset(
"assets/images/png/Vector (5)12.png",
),
),
),
),
sizedBoxHeight(20.h),
text16400white("Sport"),
sizedBoxHeight(14.h),
CommonDropdownBtn(
hint: 'Cycling',
items: const [],
leadingImage: SizedBox(
height: 22.h,
width: 18.w,
child: Center(
child: Image.asset(
"assets/images/png/Vector (4).png",
),
),
),
),
sizedBoxHeight(20.h),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text16400white("Start date "),
sizedBoxHeight(10.h),
GestureDetector(
onTap: () =>
datePicker(context, dateController),
child: AbsorbPointer(
child: CustomTextFormField(
textEditingController: dateController,
hintText: "1-4-2024",
leadingIcon: SizedBox(
height: 20.h,
width: 20.w,
child: Center(
child: Image.asset(
"assets/images/png/calender.png",
height: 20.h,
width: 20.w,
),
),
),
),
),
)
],
),
),
sizedBoxWidth(10.h),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text16400white("End date"),
sizedBoxHeight(10.h),
GestureDetector(
onTap: () =>
datePicker(context, dateController2),
child: AbsorbPointer(
child: CustomTextFormField(
textEditingController: dateController2,
hintText: "4-4-2024",
leadingIcon: SizedBox(
height: 20.h,
width: 20.w,
child: Center(
child: Image.asset(
"assets/images/png/calender.png",
height: 20.h,
width: 20.w,
),
),
),
),
),
),
]))
]),
Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text16400white("Start time"),
sizedBoxHeight(14.h),
GestureDetector(
onTap: () async {
final TimeOfDay? pickedTime =
await showCustomTimePicker(context,
initialTime: starttime);
if (pickedTime != null) {
setState(() {
starttime = pickedTime;
});
}
},
child: commonGlassUI(
width: 174.w,
height: 50.h,
borderRadius: BorderRadius.circular( 30.r),
customWidget: Center(
child: Row(children: [
sizedBoxWidth(16.w),
Image.asset(
"assets/images/png/clock.png",
height: 20.h,
width: 20.w,
),
sizedBoxWidth(8.w),
text16w400_white(
formatTimeOfDay(starttime!)),
]),
),
borderwidth: 1),
)
],
),
const Spacer(),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text16400white("End time"),
sizedBoxHeight(14.h),
GestureDetector(
onTap: () async {
final TimeOfDay? pickedTime =
await showCustomTimePicker(context,
initialTime: endtime);
if (pickedTime != null) {
setState(() {
endtime = pickedTime;
});
}
},
child: commonGlassUI(
width: 174.w,
height: 50.h,
borderRadius: BorderRadius.circular( 30.r),
customWidget: Center(
child: Row(children: [
sizedBoxWidth(16.w),
Image.asset(
"assets/images/png/clock.png",
height: 20.h,
width: 20.w,
),
sizedBoxWidth(8.w),
text16w400_white(
formatTimeOfDay(endtime!)),
]),
),
borderwidth: 1),
)
],
),
],
),
sizedBoxHeight(8.h),
Row(
children: [
Obx(() {
return commonGlassUI(
borderwidth: 1,
borderRadius: BorderRadius.circular( 2),
height: 23.h,
width: 23.w,
opacity1: 0.24,
opacity2: 0.24,
customWidget: Transform.scale(
scale: 1.4,
child: Checkbox(
side: const BorderSide(color: Color(0xFF434A53)),
value: isChecked.value,
activeColor: Colors.transparent,
checkColor: Colors.white,
onChanged: ((value) {
isChecked.value = value!;
}),
),
),
);
}),
sizedBoxWidth(8.w),
text14w400_FCFCFC("Repeat event")
],
),
sizedBoxHeight(20.h),
text16400white("Post in"),
sizedBoxHeight(14.h),
CommonDropdownBtn(
hint: '',
items: const [],
leadingImage: SizedBox(
height: 22.h,
width: 28.w,
child: Center(
child: Image.asset("assets/images/png/Black.png"),
),
),
),
sizedBoxHeight(20.h),
text16400white("Add Users"),
sizedBoxHeight(14.h),
CustomTextFormField(
onTap: () {
Get.toNamed(RouteName.addUsers);
},
leadingIcon: SizedBox(
height: 22.h,
width: 18.w,
child: Center(
child: Image.asset(
"assets/images/png/Group122.png",
fit: BoxFit.cover,
height: 18.h,
width: 18.w,
),
),
),
hintText: "",
suffixIcon:
const Icon(Icons.arrow_forward, color: Color(0xFFFFFFFF)),
),
sizedBoxHeight(20.h),
containerWidget(
imagePath: "assets/images/png/Ellipse 52.png",
title: "Ryan Dorwart"),
sizedBoxHeight(10.h),
containerWidget(
imagePath: "assets/images/png/Ellipse 52.png",
title: "Ryan Dorwart"),
sizedBoxHeight(10.h),
Align(
alignment: Alignment.center,
child: text14400white("View more")),
sizedBoxHeight(30.h),
text16400white("Location"),
sizedBoxHeight(14.h),
CustomTextFormField(
leadingIcon: SizedBox(
height: 19.h,
width: 15.w,
child: Center(
child: Image.asset(
"assets/images/png/Group 58645.png",
height: 19.h,
width: 15.w,
),
),
),
hintText: "Elm street, London, United kingdom",
),
text16400white("Reminder"),
sizedBoxHeight(14.h),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
commonGlassUI(
height: 50.h,
width: 127.w,
borderRadius: BorderRadius.circular( 30.r),
borderwidth: 1,
customWidget: Center(
child: text16400white("2"),
)),
commonGlassUI(
height: 50.h,
width: 215.w,
borderRadius: BorderRadius.circular( 30.r),
borderwidth: 1,
customWidget: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
text16400white("Minutes"),
sizedBoxWidth(5.w),
const Icon(
Icons.keyboard_arrow_down,
color: Colors.white,
)
],
),
))
],
),
sizedBoxHeight(35.h),
CommonBtn(text: "Save"),
sizedBoxHeight(70.h),
]),
),
)
]));
}
Widget containerWidget({
required String imagePath,
required String title,
}) {
return commonGlassUI(
width: double.infinity,
height: 50.h,
borderRadius: BorderRadius.circular(30),
customWidget: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Center(
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
CircleAvatar(
backgroundImage: AssetImage(imagePath),
),
sizedBoxWidth(8.w),
text16400white(title),
const Spacer(),
Image.asset(
"assets/images/png/cancelicon.png",
height: 20.h,
width: 20.w,
),
],
),
),
),
borderwidth: 1);
}
}