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/CustomNextButton.dart'; import 'package:regroup/Utils/Common/CustomTextformfield.dart'; import 'package:regroup/Utils/Common/ImageUpload.dart'; import 'package:regroup/Utils/Common/blureffect.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 createState() => _AddEventState(); } class _AddEventState extends State { RxBool isChecked = false.obs; List bannerPath = []; bool isbannerAdded = false; TextEditingController dateController = TextEditingController(); TextEditingController dateController2 = TextEditingController(); TimeOfDay? starttime = TimeOfDay(hour: 15, minute: 0); TimeOfDay? endtime = 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: Color(0xFF222935), extendBody: true, appBar: CommonAppbar( titleTxt: "", ), body: Stack(children: [ const CommonBlurLeftRed(), const CommonBlurRightRed(), const CommonBlurLeft(), const CommonBlurRight(), Positioned.fill( child: SingleChildScrollView( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ text16400white("Event Title"), sizedBoxHeight(14.h), CustomTextFormField( leadingIcon: Container( 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: [7, 4], borderType: BorderType.RRect, radius: Radius.circular(14.r), color: Color(0xFF434A53), child: commonGlassContainer( border: 0, width: double.infinity, height: 130.h, borderradius: 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 event image"), sizedBoxHeight(8.h), text8w400_8A8A8A( "Allowed file extensions: jpg, png, gif Max file size: 10 MB"), ], ), ), ), ), ), sizedBoxHeight(20.h), commonGlassContainer( width: double.infinity, height: 60.h, borderradius: 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") ], ), Spacer(), Image.asset( 'assets/images/png/cancelicon.png', height: 20.h, width: 20.w, ) ]), ), ), border: 1), sizedBoxHeight(20.h), text16400white("Type of event"), sizedBoxHeight(14.h), CommonDropdownBtn( hint: 'Race', items: [], leadingImage: Container( 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: [], leadingImage: Container( 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: Container( 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: Container( 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: commonGlassContainer( width: 174.w, height: 50.h, borderradius: 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!)), ]), ), border: 1), ) ], ), 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: commonGlassContainer( width: 174.w, height: 50.h, borderradius: 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!)), ]), ), border: 1), ) ], ), ], ), sizedBoxHeight(8.h), Row( children: [ Obx(() { return commonGlassContainer( border: 1, borderradius: 2, height: 23.h, width: 23.w, opacity1: 0.24, opacity2: 0.24, customWidget: Transform.scale( scale: 1.4, child: Checkbox( side: 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: [], leadingImage: Container( 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: Container( 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: 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: Container( 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: [ commonGlassContainer( height: 50.h, width: 127.w, borderradius: 30.r, border: 1, customWidget: Center( child: text16400white("2"), )), commonGlassContainer( height: 50.h, width: 215.w, borderradius: 30.r, border: 1, customWidget: Center( child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ text16400white("Minutes"), sizedBoxWidth(5.w), 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 commonGlassContainer( width: double.infinity, height: 50.h, borderradius: 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), Spacer(), Image.asset( "assets/images/png/cancelicon.png", height: 20.h, width: 20.w, ), ], ), ), ), border: 1); } }