import 'dart:async'; import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/painting.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; import 'package:konectar_events/contacts_module/custom_widget/custom_switch.dart'; import 'package:konectar_events/contacts_module/custom_widget/show_alert.dart'; import 'package:konectar_events/model/keywords_model.dart'; import 'package:konectar_events/model/neweventsmodel.dart'; import 'package:konectar_events/utils/apicall.dart'; import 'package:konectar_events/utils/appcolors.dart'; import 'package:konectar_events/utils/constants.dart'; import 'package:konectar_events/utils/dateformater.dart'; import 'package:konectar_events/utils/util.dart'; import 'package:konectar_events/view/eventslist.dart'; import 'package:konectar_events/view/eventstab.dart'; import 'package:konectar_events/viewmodel/eventsprovider.dart'; import 'package:konectar_events/widgets/autocompletetags_widget.dart'; import 'package:dropdown_button2/dropdown_button2.dart'; import 'package:intl/intl.dart'; import 'package:konectar_events/widgets/responsive_utils.dart'; import 'package:konectar_events/widgets/snackbar.dart'; import 'package:provider/provider.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; class HomeScreen extends StatefulWidget { const HomeScreen({super.key}); @override State createState() => _HomeScreenState(); } class _HomeScreenState extends State with TickerProviderStateMixin { String? dvalue; final TextEditingController textEditingController = TextEditingController(); final TextEditingController startDatetextEditingController = TextEditingController(); final TextEditingController endDatetextEditingController = TextEditingController(); final TextEditingController datetextEditingController = TextEditingController(); final TextEditingController selecttextEditingController = TextEditingController(); final TextEditingController searchtextEditingController = TextEditingController(); Color? iconColor = Colors.blueGrey[300]; IconData icon = Icons.favorite; List selectedIndex = []; bool selectedFav = false; bool isExtended = false; String search = ""; final ScrollController _scrollController = ScrollController(); final GlobalKey _scaffoldKey = GlobalKey(); AnimationController? animationController; bool _isSearch = false; List therapeuticList = []; static const _pageSize = 20; String filter_startdate = ""; String filter_enddate = ""; final PagingController pagingController = PagingController(firstPageKey: 0); List connectionStatus = [ConnectivityResult.none]; final Connectivity _connectivity = Connectivity(); get developer => null; late StreamSubscription> _connectivitySubscription; @override void dispose() { animationController?.dispose(); pagingController.dispose(); super.dispose(); } @override void initState() { animationController = AnimationController( duration: const Duration(milliseconds: 1000), vsync: this); WidgetsBinding.instance.addPostFrameCallback((timeStamp) { initConnectivity(); _connectivitySubscription = _connectivity.onConnectivityChanged.listen(_updateConnectionStatus); init(); }); pagingController.addPageRequestListener((pageKey) { _fetchPage(pageKey); }); super.initState(); } Future initConnectivity() async { late List result; // Platform messages may fail, so we use a try/catch PlatformException. try { result = await _connectivity.checkConnectivity(); } on PlatformException catch (e) { developer.log('Couldn\'t check connectivity status', error: e); return; } // If the widget was removed from the tree while the asynchronous platform // message was in flight, we want to discard the reply rather than calling // setState to update our non-existent appearance. if (!mounted) { return Future.value(null); } return _updateConnectionStatus(result); } Future _updateConnectionStatus(List result) async { setState(() { connectionStatus = result; }); // ignore: avoid_print print('Connectivity changed: $connectionStatus'); } Future _fetchPage(int pageKey) async { print("DATE SELECTED :$filter_enddate,$filter_startdate"); await initConnectivity(); if (connectionStatus.toString().contains("ConnectivityResult.none")) { try { final newItems = await Provider.of(context, listen: false) .getOfflineMyEvents(); final isLastPage = newItems.length < _pageSize; if (isLastPage) { pagingController.appendLastPage(newItems); } else { final nextPageKey = pageKey + newItems.length; pagingController.appendPage(newItems, nextPageKey); } } catch (error) { pagingController.error = error; } } else { try { final newItems = await Provider.of(context, listen: false).getEvents( pageKey, searchtxt: search, startdate: filter_startdate, enddate: filter_enddate); // final newItems = // await Provider.of(context, listen: false) // .getOfflineMyEvents(); //OLD final isLastPage = newItems.length < _pageSize; if (isLastPage) { pagingController.appendLastPage(newItems); } else { final nextPageKey = pageKey + newItems.length; pagingController.appendPage(newItems, nextPageKey); } //NEW // final isLastPage = pageKey + _pageSize >= newItems.length; // final nextItems = newItems // .skip(pageKey) // .take(_pageSize) // .toList(); // Get next batch of items // if (isLastPage) { // pagingController.appendLastPage(nextItems); // } else { // final nextPageKey = pageKey + nextItems.length; // pagingController.appendPage(nextItems, nextPageKey); // } } catch (error) { pagingController.error = error; } } } init() async { await ApiCall().fetchApiConstants(); await Provider.of(context, listen: false) .initConfigModules(); // await Provider.of(context, listen: false).initFiltersData(); // await Provider.of(context, listen: false).getMyEvents(0); //await ApiCall().dummyapi(); setState(() {}); } @override void didChangeDependencies() { super.didChangeDependencies(); init(); } @override Widget build(BuildContext context) { return Consumer( builder: (BuildContext context, provider, Widget? child) { // return SafeArea( // top: false, // child: Scaffold( // appBar: CustomAppBar( // title: "Events", // backgroundcolor: Color.fromARGB(255, 0, 71, 132), // ), // // backgroundColor: const Color.fromARGB(255, 222 , 237, 247), // backgroundColor: Constants.bgcolor, // // endDrawer: populateDrawer(provider),Color(0xf6f8fc) // // backgroundColor:Color(0xf6f8fc), // body: Padding( // padding: const EdgeInsets.all(8.0), // child: Column( // children: [ // Row( // children: [ // Expanded( // child: Padding( // padding: const EdgeInsets.only(left: 5.0), // child: Container( // padding: const EdgeInsets.all(20.0), // decoration: BoxDecoration( // borderRadius: BorderRadius.circular(30.0), // //color: Color.fromARGB(179, 248, 238, 238), // color: Colors.white, // ), // height: 60, // child: Center( // child: Expanded( // child: TextField( // textAlignVertical: TextAlignVertical.center, // cursorHeight: 14.0, // maxLines: 1, // controller: // selecttextEditingController, //editing controller of this TextField // decoration: InputDecoration( // // border: OutlineInputBorder(), // hintText: 'Search Events', // enabledBorder: OutlineInputBorder( // borderRadius: BorderRadius.circular(20.0), // borderSide: const BorderSide( // color: Colors.transparent, // width: 0.0), // ), // focusedBorder: OutlineInputBorder( // borderSide: const BorderSide( // color: Colors.transparent, // width: 0.0), // ), // contentPadding: EdgeInsets.symmetric( // vertical: 10.0, horizontal: 20.0), // border: OutlineInputBorder( // borderRadius: // BorderRadius.circular(20.0), // borderSide: // BorderSide(color: Colors.yellow)), // // prefixIcon: Icon( // // Icons.search, // // size: 16, // // ), // // suffixIcon: IconButton( // // onPressed: () {}, // // icon: Icon( // // Icons.filter_list_alt, // // size: 16, // // ), // // ), // hintStyle: const TextStyle(fontSize: 16), // ), // ), // ), // ), // ), // ), // ), // Padding( // padding: const EdgeInsets.only(right: 5.0), // child: Align( // alignment: Alignment.topRight, // child: IconButton( // icon: Icon( // Icons.sort_rounded, // size: isTablet ? 24 : 20, // ), // onPressed: () { // dialogBuilder(context, provider); // // showModalBottomSheet( // // context: context, // // scrollControlDisabledMaxHeightRatio: 1.0, // // isScrollControlled: true, // // builder: (context) { // // return DraggableScrollableSheet( // // initialChildSize: 0.5, // // minChildSize: 0.25, // // maxChildSize: 0.75, // // expand: true, // // builder: (context, scrollController) { // // return Container(); // // }); // // }); // // return FractionallySizedBox( // // heightFactor: 0.5, // // child: populateDrawer(provider), // // ); // // }); // }, // ), // ), // ) // ], // ), // buildListView(context, provider), // // buildEventsGrid(context, provider), // ], // ), // )), // ); return headerview(context, provider); }); } Widget headerview(BuildContext context, EventsProvider provider) { // return SafeArea( return Container( child: Scaffold( key: _scaffoldKey, // drawer: Drawer( // child: Text("This will swipe from left to right"), // ), endDrawer: populateDrawer(provider), appBar: AppBar( automaticallyImplyLeading: false, backgroundColor: AppColors.blueColor, centerTitle: true, title: _isSearch ? Padding( padding: EdgeInsets.only(left: 30), child: Container( height: 40, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(5.0)), child: TextField( controller: searchtextEditingController, onEditingComplete: () { String txt = searchtextEditingController.text; if (txt.length >= 2) { search = txt; provider.isSearch = true; pagingController.refresh(); // await provider.OnSearch(txt); } if (txt.length == 0) { provider.isSearch = false; pagingController.refresh(); } }, onChanged: (String txt) async { if (txt.length >= 2) { search = txt; provider.isSearch = true; pagingController.refresh(); // await provider.OnSearch(txt); } if (txt.length == 0) { provider.isSearch = false; search = txt; pagingController.refresh(); } }, decoration: InputDecoration( fillColor: AppColors.blueColor, contentPadding: EdgeInsets.symmetric(vertical: 9.0), border: OutlineInputBorder(), hintText: "Search for events...", // labelText: ' Search', prefixIcon: Icon( Icons.search, ), ), ), ), ) : Text( "Events", style: TextStyle(color: Colors.white), ), // leading: IconButton( // onPressed: () {}, // icon: Icon( // Icons.person_4_outlined, // size: 20, // color: Colors.white, // )), actions: [ IconButton( onPressed: () async { await provider.onSearchReset(); setState(() { _isSearch = !_isSearch; if (!_isSearch) { searchtextEditingController.clear(); search = ""; pagingController.refresh(); } }); }, icon: Icon( _isSearch ? Icons.close : Icons.search, color: Colors.white, )) ], ), body: Stack(children: [ InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, highlightColor: Colors.transparent, hoverColor: Colors.transparent, onTap: () { FocusScope.of(context).requestFocus(FocusNode()); }, child: NestedScrollView( controller: _scrollController, headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { return [ // SliverList( // delegate: SliverChildBuilderDelegate( // (BuildContext context, int index) { // return Container( // color: Constants.blueColor, // child: Column( // children: [ // // CustomAppBar( // // title: "Events", // // backgroundcolor: // // Color.fromARGB(255, 0, 71, 132), // // ), // // getSearchBarUI(provider), // ], // ), // ); // }, childCount: 1), // ), SliverPersistentHeader( pinned: true, floating: true, delegate: ContestTabHeader( getFilterBarUI(provider), ), ), ]; }, body: Container( //color: AppColors.bgcolor, color: Colors.white, child: buildPaginationListView(context, provider)), ), ), ]), ), ); // ), // ); } Widget getFilterBarUI(EventsProvider provider) { return Stack( children: [ Positioned( top: 0, left: 0, right: 0, child: Container( height: 24, decoration: BoxDecoration( color: AppColors.bgcolor, boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.2), offset: const Offset(0, -2), blurRadius: 8.0), ], ), ), ), Container( //color: AppColors.bgcolor, color: Colors.white, child: Padding( padding: const EdgeInsets.only(left: 16, right: 16, top: 8, bottom: 4), child: Row( children: [ // Container( // height: 40, // child: OutlinedButton( // onPressed: () async { // // setState(() { // await provider.onSelectAll(); // // }); // setState(() {}); // }, // child: Text( // 'All', // style: TextStyle( // // fontFamily: "SourceSerif", // fontSize: 14, // color: provider.isAllSelected // ? Colors.white // : Colors.black, // fontWeight: FontWeight.normal), // ), // style: OutlinedButton.styleFrom( // shape: StadiumBorder(), // backgroundColor: // provider.isAllSelected ? Colors.green : Colors.white, // ), // ), // ), // const SizedBox( // width: 8, // ), // Container( // height: 40, // child: OutlinedButton( // onPressed: () async { // // setState(() { // await provider.onSelectMy(); // // }); // setState(() {}); // }, // child: Text( // 'My Events', // style: TextStyle( // // fontFamily: "SourceSerif", // fontSize: 14, // color: provider.isFavSeleted // ? Colors.white // : Colors.grey, // fontWeight: FontWeight.normal), // ), // style: OutlinedButton.styleFrom( // shape: StadiumBorder(), // backgroundColor: // provider.isFavSeleted ? Colors.green : Colors.white, // ), // ), // ), Container( child: Wrap( children: [ Padding( padding: const EdgeInsets.only(left: 8.0, right: 2.0), child: CustomSwitch( activeclor: AppColors.blueColor, switchvalue: provider.isFavSeleted, onchanged: (value) { provider.isFavSeleted = value; if (provider.isFavSeleted) { pagingController.refresh(); } else { provider.isFavSeleted = false; provider.isAllSelected = !provider.isAllSelected; pagingController.refresh(); } setState(() {}); }, ), // ), ), Padding( padding: const EdgeInsets.only(right: 8.0, top: 9.0), child: !provider.isFavSeleted ? const Text( 'My Events', style: TextStyle(fontSize: 15, color: Colors.grey), ) : const Text( 'My Events', style: TextStyle( fontSize: 15, ), ), ) ], ), ), const Spacer(), // Expanded( // child: Padding( // padding: const EdgeInsets.all(8.0), // child: Text( // '530 hotels found', // style: TextStyle( // fontWeight: FontWeight.w100, // fontSize: 16, // ), // ), // ), // ), !provider.enableFilters ? SizedBox.shrink() : Material( color: Colors.transparent, child: InkWell( focusColor: Colors.transparent, highlightColor: Colors.transparent, hoverColor: Colors.transparent, splashColor: Colors.grey.withOpacity(0.2), borderRadius: const BorderRadius.all( Radius.circular(4.0), ), onTap: () { FocusScope.of(context).requestFocus(FocusNode()); // Navigator.push( // context, // MaterialPageRoute( // builder: (BuildContext context) => // populateDrawer(provider), // fullscreenDialog: false), // ); _scaffoldKey.currentState?.openEndDrawer(); }, child: Padding( padding: const EdgeInsets.only(left: 8), child: Row( children: [ Text( 'Filters', style: TextStyle( fontWeight: FontWeight.w100, fontSize: 16, ), ), Padding( padding: const EdgeInsets.all(8.0), child: Icon( Icons.sort, color: Color.fromARGB(255, 0, 71, 132), ), ), ], ), ), ), ), ], ), ), ), const Positioned( top: 0, left: 0, right: 0, child: Divider( height: 1, ), ) ], ); } Widget getSearchBarUI(EventsProvider provider) { return Padding( padding: const EdgeInsets.only(left: 16, right: 16, top: 8, bottom: 8), child: Row( children: [ Padding( padding: const EdgeInsets.only(right: 12, top: 8, bottom: 8), child: Container( decoration: BoxDecoration( color: AppColors.bgcolor, borderRadius: const BorderRadius.all( Radius.circular(24.0), ), boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.2), offset: const Offset(0, 2), blurRadius: 8.0), ], ), child: Padding( padding: const EdgeInsets.only(left: 8, right: 8, top: 1, bottom: 1), child: TextField( onChanged: (String txt) async { if (txt.length >= 3) { search = txt; provider.isSearch = true; pagingController.refresh(); // await provider.OnSearch(txt); } if (txt.length <= 3) { provider.isSearch = false; pagingController.refresh(); //await provider.onSearchReset(); } }, style: const TextStyle( fontSize: 14, ), cursorColor: Colors.blue, controller: searchtextEditingController, decoration: InputDecoration( border: InputBorder.none, hintText: ' Search for events...', ), ), ), ), ), Container( // decoration: BoxDecoration( // color: Constants.blueColor, // borderRadius: const BorderRadius.all( // Radius.circular(24.0), // ), // boxShadow: [ // BoxShadow( // color: Colors.grey.withOpacity(0.4), // offset: const Offset(0, 2), // blurRadius: 8.0), // ], // ), child: Material( color: Colors.transparent, child: InkWell( borderRadius: const BorderRadius.all( Radius.circular(28.0), ), onTap: () async { FocusScope.of(context).requestFocus(FocusNode()); if (searchtextEditingController.text.length >= 3) { search = searchtextEditingController.text; provider.isSearch = true; pagingController.refresh(); // await provider.OnSearch(searchtextEditingController.text); } else { //search = searchtextEditingController.text; provider.isSearch = false; pagingController.refresh(); } // await provider.onSearchReset(); }, child: Padding( padding: const EdgeInsets.all(16.0), child: Icon(FontAwesomeIcons.magnifyingGlass, size: 18, color: Colors.white), ), ), ), ), ], ), ); } Widget getAppBarUI() { return Container( decoration: BoxDecoration( color: Color.fromARGB(255, 0, 71, 132), boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.2), offset: const Offset(0, 2), blurRadius: 8.0), ], ), child: Padding( padding: EdgeInsets.only( top: MediaQuery.of(context).padding.top, left: 8, right: 8), child: Row( children: [ Container( alignment: Alignment.centerLeft, width: AppBar().preferredSize.height + 40, height: AppBar().preferredSize.height, // child: Material( // color: Colors.transparent, // child: InkWell( // borderRadius: const BorderRadius.all( // Radius.circular(32.0), // ), // onTap: () { // Navigator.pop(context); // }, // child: Padding( // padding: const EdgeInsets.all(8.0), // child: Icon(Icons.arrow_back), // ), // ), // ), ), Center( child: Text( 'Events', style: TextStyle( fontWeight: FontWeight.w600, fontSize: 22, ), ), ), Container( width: AppBar().preferredSize.height + 40, height: AppBar().preferredSize.height, child: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.end, children: [ Material( color: Colors.transparent, child: InkWell( borderRadius: const BorderRadius.all( Radius.circular(32.0), ), onTap: () {}, child: Padding( padding: const EdgeInsets.all(8.0), child: Icon(Icons.favorite_border), ), ), ), Material( color: Colors.transparent, child: InkWell( borderRadius: const BorderRadius.all( Radius.circular(32.0), ), onTap: () {}, child: Padding( padding: const EdgeInsets.all(8.0), child: Icon(Icons.local_activity), ), ), ), ], ), ) ], ), ), ); } Future dialogBuilder(BuildContext context, EventsProvider provider) { return showDialog( context: context, builder: (BuildContext context) { // return AlertDialog( // title: const Text('Session Notes'), return populateDrawer(provider); // actions: [ // TextButton( // style: TextButton.styleFrom( // textStyle: Theme.of(context).textTheme.labelLarge, // ), // child: const Text('Submit'), // onPressed: () { // Navigator.of(context).pop(); // }, // ), // TextButton( // style: TextButton.styleFrom( // textStyle: Theme.of(context).textTheme.labelLarge, // ), // child: const Text('Cancel'), // onPressed: () { // Navigator.of(context).pop(); // }, // ), // ], // ); }, ); } List sortEvents = ["All Events", "My Events"]; Widget dropDown({ Widget? underline, Widget? icon, TextStyle? style, TextStyle? hintStyle, Color? dropdownColor, }) => DropdownButton( value: dvalue, underline: underline, icon: Align(alignment: Alignment.centerRight, child: icon), dropdownColor: dropdownColor, isExpanded: true, style: TextStyle( fontFamily: "SourceSerif", color: Colors.black, fontSize: 12.0, ), // iconEnabledColor: iconEnabledColor, onChanged: (String? newValue) { setState(() { dvalue = newValue; }); }, hint: Text("Select", style: hintStyle), items: sortEvents .map((session) => DropdownMenuItem( value: session, child: Text(session))) .toList()); populateDrawer(EventsProvider provider) { return Theme( data: Theme.of(context).copyWith(canvasColor: AppColors.bgcolor), child: Container( width: MediaQuery.of(context).size.width * 0.60, color: AppColors.bgcolor, child: Drawer( child: SingleChildScrollView( scrollDirection: Axis.vertical, child: Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ Container( color: AppColors.bgcolor, padding: EdgeInsets.only(top: 20, left: 5.0), ), Padding( padding: const EdgeInsets.only(left: 8.0), child: Row( children: [ InkWell( onTap: () { Navigator.pop(context); }, child: Icon( Icons.arrow_back_ios, color: Colors.black, size: isTablet ? 20 : 16, ), ), SizedBox( width: 8.0, ), Text( 'Filters', style: TextStyle(fontSize: 20), ), const Spacer(), SizedBox( width: 8.0, ), ], ), ), Divider( height: 7, color: Colors.black, ), Wrap( children: [ SizedBox( width: isTablet ? MediaQuery.of(context).size.width / 2 : MediaQuery.of(context).size.width, child: ListTile( //title: Text('Search Scope'), subtitle: StringAutoCompleteTags( initialTags: provider.therapeuticList .map((e) => TagsData(id: e.id, name: e.therapeuticName)) .toList(), hintText: "Enter scope", filtername: "scope", getList: (TextEditingValue textEditingValue) { List taglist = []; taglist = provider.therapeuticList .map((e) => TagsData(id: e.id, name: e.therapeuticName)) .toList(); if (textEditingValue.text == '') { return const Iterable.empty(); } if (textEditingValue.text.length > 1) { return taglist.where((TagsData option) { return option.name.contains( textEditingValue.text.toLowerCase()); }); } return taglist.where((TagsData option) { return option.name.contains( textEditingValue.text.toLowerCase()); }); }, ), onTap: () {}, selectedColor: Colors.white, selectedTileColor: Colors.white, ), ), SizedBox( width: isTablet ? MediaQuery.of(context).size.width / 2 : MediaQuery.of(context).size.width, child: ListTile( // title: Text('Search Keyword'), subtitle: StringAutoCompleteTags( initialTags: provider.keywordList .map((e) => TagsData(id: e.id, name: e.name)) .toList(), filtername: "keyword", hintText: "Enter Keyword", getList: (TextEditingValue textEditingValue) async { if (textEditingValue.text == '') { return const Iterable.empty(); } if (textEditingValue.text.length >= 3) { List keywordlist = await provider .getKeywordList(textEditingValue.text); return keywordlist .map((e) => TagsData(id: e.id, name: e.name)) .toList() .where((TagsData option) { return option.name.contains( textEditingValue.text.toLowerCase()); }); } else { return const Iterable.empty(); } }, ), onTap: () {}, ), ), SizedBox( width: isTablet ? MediaQuery.of(context).size.width / 2 : MediaQuery.of(context).size.width, child: ListTile( // title: Text('Search Speakers'), subtitle: StringAutoCompleteTags( initialTags: [ TagsData(name: "Gavino Casu", id: "1"), TagsData(name: "Calvin Marentz", id: "2"), TagsData(name: "Vineet Bhandari", id: "3"), TagsData(name: "Jose Travino", id: "4"), ], hintText: "Enter Speakers", filtername: "speakers", getList: (TextEditingValue textEditingValue) { if (textEditingValue.text == '') { return const Iterable.empty(); } return [ TagsData(name: "Gavino Casu", id: "1"), TagsData(name: "Calvin Marentz", id: "2"), TagsData(name: "Vineet Bhandari", id: "3"), TagsData(name: "Jose Travino", id: "4"), ].where((TagsData option) { return option.name.contains( textEditingValue.text.toLowerCase()); }); }, ), onTap: () {}, ), ), ], ), Divider( height: 1, color: Colors.black, ), ExpansionTile( shape: Border(), title: Text("More"), children: [ Column( children: [ SizedBox( width: isTablet ? MediaQuery.of(context).size.width / 2 : MediaQuery.of(context).size.width, child: ListTile( title: Text('Start Date'), subtitle: buildDateWidget( startDatetextEditingController, "Start Date"), onTap: () {}, ), ), SizedBox( width: isTablet ? MediaQuery.of(context).size.width / 2 : MediaQuery.of(context).size.width, child: ListTile( title: Text('End Date'), subtitle: buildDateWidget( endDatetextEditingController, "End Date"), onTap: () {}, ), ), ], ), ], ), SizedBox( height: 20, ), Column( children: [ Align( alignment: Alignment.bottomCenter, child: SizedBox( width: 200, height: 50, child: FloatingActionButton.extended( backgroundColor: Colors.green, onPressed: () { print("&&&"); print(provider.selectedTherapeutic); if (provider.selectedTherapeutic.isNotEmpty) { provider.OnFilters(); } pagingController.refresh(); setState(() { Navigator.pop(context); }); }, elevation: 0, label: const Text("Apply Filters", style: TextStyle( color: Colors.white, )), ), ), ), SizedBox( height: 10, ), Align( alignment: Alignment.bottomCenter, child: SizedBox( width: 200, height: 50, child: FloatingActionButton.extended( backgroundColor: Colors.blue, onPressed: () { startDatetextEditingController.clear(); endDatetextEditingController.clear(); filter_enddate = ""; filter_startdate = ""; setState(() {}); pagingController.refresh(); Navigator.pop(context); }, elevation: 0, label: const Text("Clear Filters", style: TextStyle( color: Colors.white, )), ), ), ), ], ), ], ), ), ), ), ); } Widget buildDateWidget(TextEditingController controller, String hint) { return SizedBox( //width: isTablet ? 200 : MediaQuery.of(context).size.width, height: isTablet ? 50 : 40, child: TextField( controller: controller, //editing controller of this TextField decoration: InputDecoration( border: OutlineInputBorder(), // border: OutlineInputBorder( // borderRadius: BorderRadius.circular(10.0), // ), // labelStyle: const TextStyle(fontSize: 16), suffixIcon: const Icon( Icons.calendar_today, size: 16, ), //icon of text field // labelText: "Enter Date" //label text of field // hintText: hint, ), readOnly: true, //set it true, so that user will not able to edit text onTap: () async { DateTime? pickedDate = await showDatePicker( context: context, anchorPoint: Offset(20.0, 30.0), initialDate: DateTime.now(), firstDate: DateTime .now(), //DateTime.now() - not to allow to choose before today. lastDate: DateTime(2101)); if (pickedDate != null) { print( pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000 String formattedDate = DateFormat('yyyy-MM-dd').format(pickedDate); print( formattedDate); //formatted date output using intl package => 2021-03-16 //you can implement different kind of Date Format here according to your requirement if (hint == "Start Date") { filter_startdate = formattedDate; } else { filter_enddate = formattedDate; } setState(() { // output date to TextField value. controller.text = formattedDate; }); } else { print("Date is not selected"); } }, ), ); } Widget buildTextFieldWidget() { return SizedBox( width: isTablet ? 200 : MediaQuery.of(context).size.width, height: isTablet ? 50 : 40, child: TextField( controller: selecttextEditingController, //editing controller of this TextField decoration: InputDecoration( // border: OutlineInputBorder(), border: OutlineInputBorder( borderRadius: BorderRadius.circular(10.0), ), labelStyle: const TextStyle(fontSize: 16), ), ), ); } Widget customAutoCompletedropdown(List list) { // sectionItem.value = list[0].name; // if (list.isEmpty) { // print("list is empty"); //} //InputClass selectedObj = list[0]; return SizedBox( width: isTablet ? 200 : MediaQuery.of(context).size.width, height: isTablet ? 60 : 40, child: DropdownButtonFormField2( isExpanded: true, decoration: InputDecoration( // Add Horizontal padding using menuItemStyleData.padding so it matches // the menu padding when button's width is not specified. contentPadding: const EdgeInsets.symmetric(vertical: 5), border: OutlineInputBorder( borderRadius: BorderRadius.circular(15), ), // Add more decoration.. ), hint: Text( 'Select Item', style: TextStyle( fontSize: 14, color: Theme.of(context).hintColor, ), ), items: list .map((item) => DropdownMenuItem( value: item, child: Text( item, style: const TextStyle( fontSize: 14, ), ), )) .toList(), value: list[0], onSaved: (value) {}, onChanged: (value) { // setState(() { }, buttonStyleData: const ButtonStyleData( padding: EdgeInsets.symmetric(horizontal: 16), height: 40, width: 200, ), dropdownStyleData: const DropdownStyleData( maxHeight: 200, ), menuItemStyleData: const MenuItemStyleData( height: 40, ), dropdownSearchData: DropdownSearchData( searchController: textEditingController, searchInnerWidgetHeight: 50, searchInnerWidget: Container( height: 50, padding: const EdgeInsets.only( top: 8, bottom: 4, right: 8, left: 8, ), child: TextFormField( expands: true, maxLines: null, controller: textEditingController, decoration: InputDecoration( isDense: true, contentPadding: const EdgeInsets.symmetric( horizontal: 10, vertical: 8, ), hintText: 'Search...', hintStyle: const TextStyle(fontSize: 12), border: OutlineInputBorder( borderRadius: BorderRadius.circular(8), ), ), ), ), searchMatchFn: (item, searchValue) { return item.value!.toString().contains(searchValue); }, ), //This to clear the search value when you close the menu onMenuStateChange: (isOpen) { if (!isOpen) { textEditingController.clear(); } }, ), ); } Widget buildListView(BuildContext context, EventsProvider provider) { return ListView.builder( itemCount: provider.isSearch ? provider.searchList.length : provider.eventList.length, padding: const EdgeInsets.only(top: 2), shrinkWrap: true, scrollDirection: Axis.vertical, itemBuilder: (BuildContext context, int index) { final int count = provider.eventList.length > 10 ? 10 : provider.eventList.length; final Animation animation = Tween(begin: 0.0, end: 1.0) .animate(CurvedAnimation( parent: animationController!, curve: Interval((1 / count) * index, 1.0, curve: Curves.fastOutSlowIn))); animationController?.forward(); return _buildlistCard( animation: animation, animationController: animationController!, provider: provider, eventsList: provider.isSearch ? provider.searchList[index] : provider.eventList[index], ); }, ); } Set selectedIndexes = {}; Widget buildPaginationListView( BuildContext context, EventsProvider provider) { return RefreshIndicator( onRefresh: () async => pagingController.refresh(), child: PagedListView( pagingController: pagingController, padding: EdgeInsets.zero, builderDelegate: PagedChildBuilderDelegate( itemBuilder: (BuildContext context, item, int index) { print( "VALUE RENDER ${item.eventId} - ${item.name1}- ${item.eventUserInterest}"); final int count = provider.eventList.length > 10 ? 10 : provider.eventList.length; final Animation animation = Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation( parent: animationController!, curve: Interval((1 / count) * index, 1.0, curve: Curves.fastOutSlowIn))); animationController?.forward(); return _buildlistCard( animation: animation, animationController: animationController!, provider: provider, eventsList: provider.isSearch ? item : item, ); }, )), ); } Widget _buildlistCard( {required Animation? animation, required AnimationController? animationController, required EventsProvider provider, required EventsList eventsList}) { return AnimatedBuilder( animation: animationController!, builder: (BuildContext context, Widget? child) { return FadeTransition( opacity: animation!, child: Transform( transform: Matrix4.translationValues( 0.0, 50 * (1.0 - animation.value), 0.0), child: Padding( padding: const EdgeInsets.only( left: 10, right: 10, top: 8, bottom: 12), child: InkWell( splashColor: Colors.transparent, onTap: () { Navigator.of(context, rootNavigator: true) .push(MaterialPageRoute( builder: (context) => EventsListingScreen( event: eventsList, ), )); }, child: Card( //elevation: 4, color: AppColors.homeCardBackgound, //surfaceTintColor: Colors.white, surfaceTintColor: AppColors.homeCardBackgound, // shadowColor: Constants.bgcolor, child: buildCardView(context, eventsList, provider), ), )))); }); } Widget buildEventsGrid(BuildContext context, EventsProvider provider) { final textTheme = Theme.of(context) .textTheme .apply(displayColor: Theme.of(context).colorScheme.onSurface); // Set the default number of columns to 3. int columnsCount = 2; // Define the icon size based on the screen width // Use the ResponsiveUtils class to determine the device's screen size. if (ResponsiveUtils.isMobile(context)) { columnsCount = 1; } else if (ResponsiveUtils.isDesktop(context)) { columnsCount = 3; } // Build the grid view using the number of columns. return Expanded( child: GridView.builder( // Set padding and spacing between cards. padding: const EdgeInsets.symmetric(vertical: 5), scrollDirection: Axis.vertical, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( // Set the number of columns based on the device's screen size. crossAxisCount: columnsCount, // Set the aspect ratio of each card. // childAspectRatio: isTablet ? 2 : 2, // crossAxisSpacing: isTablet ? 30 : 20, // mainAxisSpacing: isTablet ? 40 : 20, childAspectRatio: isTablet ? 2 : 2.2, crossAxisSpacing: isTablet ? 30 : 1, mainAxisSpacing: isTablet ? 40 : 4, ), // Set the number of items in the grid view. itemCount: provider.eventList.length, itemBuilder: (BuildContext context, int index) { // Build each card in the grid view. return InkWell( onTap: () { if (provider.eventList[index].sessionName != "") { Navigator.of(context, rootNavigator: true) .push(MaterialPageRoute( builder: (context) => EventsTab( event: provider.eventList[index], ), )); } else { //Alert Alert( data: "Data for the ", onPressed: () {}, ); } // Navigator.of(context).push(new MaterialPageRoute( // builder: (BuildContext context) { // return new EventsTab(); // }, // fullscreenDialog: true)); }, child: Card( elevation: 1, shadowColor: AppColors.bgcolor, child: buildCardView( context, provider.eventList[index], provider))); }, // Set the grid view to shrink wrap its contents. shrinkWrap: true, // Disable scrolling in the grid view. // physics: const NeverScrollableScrollPhysics(), ), ); } buildCardView( BuildContext context, EventsList event, EventsProvider provider) { // print( // "CHECK EVENT INTERESTED : ${provider.checkIfUserInterested(event.eventId ?? "")}}"); double height = isTablet ? MediaQuery.of(context).size.height * 0.35 : MediaQuery.of(context).size.height * 0.65; return ConstrainedBox( constraints: BoxConstraints.tightFor(), child: Container( decoration: BoxDecoration( // color: Color.fromARGB(179, 248, 238, 238), // color: Colors.white, color: AppColors.homeCardBackgound, borderRadius: BorderRadius.all(Radius.circular(20))), // height: MediaQuery.of(context).size.height * 0.2, // height: 136, // height: double.minPositive, padding: isTablet ? EdgeInsets.symmetric(horizontal: 12.0, vertical: 12.0) : EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), child: // Column( // crossAxisAlignment: CrossAxisAlignment.end, // // mainAxisAlignment: MainAxisAlignment.spaceEvenly, // children: [ // SizedBox( // height: isTablet ? 1 : 3, // ), // Container( // // height: isTablet ? height * 0.50 : height * 0.30, // padding: const EdgeInsets.only(top: 5.0), // width: double.maxFinite, // child: Column( // crossAxisAlignment: CrossAxisAlignment.end, // mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Align( alignment: FractionalOffset.topLeft, child: RichText( text: TextSpan(children: [ // WidgetSpan( // child: Icon(Icons.bookmark, // color: AppColors.blueColor, // size: isTablet ? 14 : 18) // // provider.ifOfflineExists(event.eventId!) // // ? Icon(Icons.bookmark, // // color: AppColors.blueColor, // // size: isTablet ? 14 : 18) // // : SizedBox.shrink(), // ), TextSpan( text: event.name1 ?? "", style: TextStyle( // decoration: TextDecoration.underline, // decorationColor: Colors.blue, color: Colors.black, fontWeight: FontWeight.bold, fontSize: isTablet ? 18 : 16, // fontFamily: "SourceSerif", ), // maxLines: isTablet ? 4 : 4, // softWrap: true, // overflow: TextOverflow.ellipsis, ), ])), ), //const Spacer(), SizedBox( height: 14, ), // Positioned( // child: Align( alignment: FractionalOffset.bottomLeft, child: Row( crossAxisAlignment: CrossAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.end, children: [ RichText( text: TextSpan( children: [ WidgetSpan( child: Icon(Icons.calendar_month, size: 16), ), TextSpan( text: ' ${CustomDateFormatter().formatYearDate(CustomDateFormatter().convertStringToDate(event.start!))} to ${CustomDateFormatter().formatYearDate(CustomDateFormatter().convertStringToDate(event.end!))}', style: TextStyle( color: Colors.black, //fontStyle: FontStyle.italic, fontSize: isTablet ? 16 : 12), ), ], ), ), SizedBox( height: 5.0, ), provider.getLocationDetails(event).length == 0 ? SizedBox.shrink() : Container( constraints: BoxConstraints( minWidth: 100, maxWidth: double.maxFinite), //width: MediaQuery.of(context).size.width / 2, // padding: EdgeInsets.only(right: 13), child: RichText( textAlign: TextAlign.justify, text: TextSpan( children: [ WidgetSpan( child: Icon(Icons.location_on, size: 16), ), // WidgetSpan( // child: Flexible( // // width: 200, // child: Text( // provider.getLocationDetails(event), // overflow: TextOverflow.fade, // ), // )), TextSpan( spellOut: true, text: ' ${provider.getLocationDetails(event)}', // ' ${event.city != null && event.city != "" ? "${event.city}, " : ""}${event.region != null && event.region != "" ? "${event.region}, " : ""}${event.country != null && event.country != "" ? "${event.country}" : ""}', style: TextStyle( color: Colors.black, overflow: TextOverflow.ellipsis, //fontStyle: FontStyle.italic, fontSize: isTablet ? 16 : 12), ), ], ), ), ), provider.ifOfflineExists(event.eventId ?? "") ? Padding( padding: EdgeInsets.only(right: 10), child: RichText( text: TextSpan(children: [ WidgetSpan( child: Icon(Icons.bookmark, color: AppColors.blueColor, size: isTablet ? 14 : 16), ), TextSpan( text: ' Saved', style: TextStyle( color: Colors.black, //fontStyle: FontStyle.italic, fontSize: isTablet ? 16 : 12), ), ]), )) : SizedBox.shrink(), ], ), provider.enableFollow ? Align( alignment: FractionalOffset.bottomRight, child: Row( children: [ Column( crossAxisAlignment: CrossAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ SizedBox( width: 40, height: 30, child: FloatingActionButton.extended( elevation: 1, shape: CircleBorder(), backgroundColor: AppColors.bgcolor, //backgroundColor: AppColors.homeCardBackgound, onPressed: () async { // event.isfav = !event.isfav; if (event.eventUserInterest!) { //If event is added to fav then unfollow String msg = await provider .removeEventsToFavs( event.eventId!); SnackBarWidget.displaySnackBar( "Removed from My Events!", context); } else { String msg = await provider.addEventsToFavs( event.eventId!); SnackBarWidget.displaySnackBar( "Added to My Events", context); } pagingController.refresh(); setState(() {}); // if (event.isfav) { // // await provider.favsEventsData(event); // } else { // // await provider.delateEventsData(event); // } }, label: AnimatedSwitcher( duration: Duration(seconds: 1), transitionBuilder: (Widget child, Animation animation) => FadeTransition( opacity: animation, child: SizeTransition( child: child, sizeFactor: animation, axis: Axis.horizontal, ), ), child: event.eventUserInterest! ? Column( children: [ Icon( Icons.favorite, color: Colors.red, size: 14, ), ], ) : Icon( Icons.favorite, color: Colors.grey, size: 14, ))), ), SizedBox( height: 2, ), event.eventUserInterest! ? RichText( text: TextSpan( children: [ WidgetSpan( child: Icon(Icons.check, color: Colors.grey[600], size: isTablet ? 14 : 10), ), TextSpan( text: ' Following', style: TextStyle( color: Colors.grey[600], fontSize: isTablet ? 14 : 10), ), ], ), ) : Center( child: RichText( text: TextSpan( children: [ TextSpan( text: 'Follow ', style: TextStyle( color: Colors.grey[600], fontSize: isTablet ? 14 : 10), ), ], ), ), ), ], ), ], ), ) : SizedBox.shrink(), // Align( // alignment: Alignment.bottomRight, // child: SizedBox( // height: 30, // child: OutlinedButton( // onPressed: () { // setState(() { // // selectedIndex.add(index); // if (selectedIndex.isNotEmpty) { // int count = selectedIndex // .where( // (element) => element == index, // ) // .length; // if (count >= 1) { // iconColor = Colors.grey; // selectedFav = false; // icon = Icons.favorite; // selectedIndex.remove(index); // } else { // selectedIndex.add(index); // if (selectedIndex.contains(index)) { // iconColor = Colors.red; // icon = Icons.favorite; // selectedFav = true; // } // } // } else { // selectedIndex.add(index); // if (selectedIndex.contains(index)) { // iconColor = Colors.red; // icon = Icons.favorite; // selectedFav = true; // } // //} // } // }); // }, // child: Icon( // icon, // size: isTablet ? 20 : 18, // color: selectedFav && selectedIndex.contains(index) // ? iconColor // : Colors.grey, // ), // style: OutlinedButton.styleFrom( // shape: CircleBorder(), // ), // ), // ), // ), ], ), ), // ), ], ), // Image.asset( // "assets/images/events2.jpg", // fit: BoxFit.cover, // ), //), // Divider( // color: Colors.blueGrey, // thickness: 2, // height: 2, // ), // SizedBox( // height: 5, // ), // Text( // 'Organizer: Hematology/Oncology Pharmacy Association (HOPA)', // style: TextStyle( // color: Colors.black, // fontStyle: FontStyle.italic, // fontFamily: "SourceSerif", // fontSize: isTablet ? 18 : 14), // maxLines: 2, // softWrap: true, // overflow: TextOverflow.ellipsis, // ), // SizedBox( // // height: 100, // child: Padding( // padding: const EdgeInsets.symmetric(vertical: 4.0), // child: Column( // mainAxisAlignment: MainAxisAlignment.start, // crossAxisAlignment: CrossAxisAlignment.start, // children: [ // Row( // children: [], // ), // RichText( // text: TextSpan( // children: [ // WidgetSpan( // child: SizedBox( // width: 80, // height: 18, // child: WidgetStack( // stackedWidgets: [ // for (var n = 0; n < 5; n++) // CircleAvatar( // child: Icon( // Icons.person, // size: 14, // color: Colors.blueGrey[300], // )) // ], // positions: RestrictedPositions( // maxCoverage: 0.3, // minCoverage: 0.4, // ), // buildInfoWidget: (surplus) { // return Center( // child: Text( // '+$surplus', // style: Theme.of(context).textTheme.headline5, // )); // }, // ), // ), // ), // TextSpan( // text: '5', // style: TextStyle( // color: Colors.black, // fontFamily: "SourceSerif", // fontSize: 16), // ), // TextSpan( // text: ' attendees', // style: TextStyle( // color: Colors.black, // fontFamily: "SourceSerif", // fontSize: 14), // ), // ], // ), // ), // RichText( // text: TextSpan( // children: [ // WidgetSpan( // child: SizedBox( // width: 50, // height: 18, // child: WidgetStack( // stackedWidgets: [ // for (var n = 0; n < 3; n++) // CircleAvatar( // child: Icon( // Icons.person, // size: 14, // color: Colors.blueGrey[300], // )) // ], // positions: RestrictedPositions( // maxCoverage: 0.3, // minCoverage: 0.4, // ), // buildInfoWidget: (surplus) { // return Center( // child: Text( // '+$surplus', // style: Theme.of(context).textTheme.headline5, // )); // }, // ), // ), // ), // TextSpan( // text: '3', // style: TextStyle( // color: Colors.black, // fontFamily: "SourceSerif", // fontSize: 16), // ), // TextSpan( // text: ' client attendees', // style: TextStyle( // color: Colors.black, // fontFamily: "SourceSerif", // fontSize: 14), // ), // ], // ), // ), // ], // ), // ), // ), // Row( // children: [ // SizedBox( // height: 30, // child: OutlinedButton( // onPressed: () {}, // child: Text('Add to My Events'), // style: OutlinedButton.styleFrom( // shape: StadiumBorder(), // ), // ), // ), // ], // ) // ], // ), ), ); } } class ContestTabHeader extends SliverPersistentHeaderDelegate { ContestTabHeader( this.searchUI, ); final Widget searchUI; @override Widget build( BuildContext context, double shrinkOffset, bool overlapsContent) { return Container(color: Colors.white, child: searchUI); } @override double get maxExtent => 52.0; @override double get minExtent => 52.0; @override bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) { return true; } }