2024-11-19 12:57:30 +00:00
import ' dart:async ' ;
import ' package:connectivity_plus/connectivity_plus.dart ' ;
2024-09-06 06:30:31 +00:00
import ' package:flutter/cupertino.dart ' ;
import ' package:flutter/gestures.dart ' ;
import ' package:flutter/material.dart ' ;
2024-11-19 12:57:30 +00:00
import ' package:flutter/painting.dart ' ;
2024-09-06 06:30:31 +00:00
import ' package:flutter/rendering.dart ' ;
2024-11-19 12:57:30 +00:00
import ' package:flutter/services.dart ' ;
2024-09-06 06:30:31 +00:00
import ' package:flutter/widgets.dart ' ;
2024-11-19 12:57:30 +00:00
import ' package:infinite_scroll_pagination/infinite_scroll_pagination.dart ' ;
import ' package:konectar_events/contacts_module/custom_widget/show_alert.dart ' ;
2024-09-06 06:30:31 +00:00
import ' package:konectar_events/model/keywords_model.dart ' ;
import ' package:konectar_events/model/neweventsmodel.dart ' ;
2024-11-19 12:57:30 +00:00
import ' package:konectar_events/utils/apicall.dart ' ;
2024-09-06 06:30:31 +00:00
import ' package:konectar_events/utils/constants.dart ' ;
2024-11-19 12:57:30 +00:00
import ' package:konectar_events/utils/dateformater.dart ' ;
2024-09-06 06:30:31 +00:00
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 < HomeScreen > createState ( ) = > _HomeScreenState ( ) ;
}
class _HomeScreenState extends State < HomeScreen > 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 < int > selectedIndex = [ ] ;
bool selectedFav = false ;
bool isExtended = false ;
2024-11-19 12:57:30 +00:00
String search = " " ;
2024-09-06 06:30:31 +00:00
final ScrollController _scrollController = ScrollController ( ) ;
final GlobalKey < ScaffoldState > _scaffoldKey = GlobalKey < ScaffoldState > ( ) ;
AnimationController ? animationController ;
bool _isSearch = false ;
List < String > therapeuticList = [ ] ;
2024-11-19 12:57:30 +00:00
static const _pageSize = 20 ;
String filter_startdate = " " ;
String filter_enddate = " " ;
final PagingController < int , EventsList > pagingController =
PagingController ( firstPageKey: 0 ) ;
List < ConnectivityResult > connectionStatus = [ ConnectivityResult . none ] ;
final Connectivity _connectivity = Connectivity ( ) ;
get developer = > null ;
late StreamSubscription < List < ConnectivityResult > > _connectivitySubscription ;
2024-09-06 06:30:31 +00:00
@ override
void dispose ( ) {
animationController ? . dispose ( ) ;
2024-11-19 12:57:30 +00:00
pagingController . dispose ( ) ;
2024-09-06 06:30:31 +00:00
super . dispose ( ) ;
}
@ override
void initState ( ) {
animationController = AnimationController (
duration: const Duration ( milliseconds: 1000 ) , vsync: this ) ;
WidgetsBinding . instance . addPostFrameCallback ( ( timeStamp ) {
2024-11-19 12:57:30 +00:00
initConnectivity ( ) ;
_connectivitySubscription =
_connectivity . onConnectivityChanged . listen ( _updateConnectionStatus ) ;
2024-09-06 06:30:31 +00:00
init ( ) ;
} ) ;
2024-11-19 12:57:30 +00:00
pagingController . addPageRequestListener ( ( pageKey ) {
_fetchPage ( pageKey ) ;
} ) ;
2024-09-06 06:30:31 +00:00
super . initState ( ) ;
}
2024-11-19 12:57:30 +00:00
Future < void > initConnectivity ( ) async {
late List < ConnectivityResult > 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 < void > _updateConnectionStatus ( List < ConnectivityResult > result ) async {
setState ( ( ) {
connectionStatus = result ;
} ) ;
// ignore: avoid_print
print ( ' Connectivity changed: $ connectionStatus ' ) ;
}
Future < void > _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 < EventsProvider > ( 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 < EventsProvider > ( context , listen: false ) . getEvents (
pageKey ,
searchtxt: search ,
startdate: filter_startdate ,
enddate: filter_enddate ) ;
// final newItems =
// await Provider.of<EventsProvider>(context, listen: false)
// .getOfflineMyEvents();
2024-12-03 05:59:45 +00:00
//OLD
2024-11-19 12:57:30 +00:00
final isLastPage = newItems . length < _pageSize ;
if ( isLastPage ) {
pagingController . appendLastPage ( newItems ) ;
} else {
final nextPageKey = pageKey + newItems . length ;
pagingController . appendPage ( newItems , nextPageKey ) ;
}
2024-12-03 05:59:45 +00:00
//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);
// }
2024-11-19 12:57:30 +00:00
} catch ( error ) {
pagingController . error = error ;
}
}
}
2024-09-06 06:30:31 +00:00
init ( ) async {
await Provider . of < EventsProvider > ( context , listen: false ) . initFiltersData ( ) ;
2024-11-19 12:57:30 +00:00
// await Provider.of<EventsProvider>(context, listen: false).getMyEvents(0);
2024-09-06 06:30:31 +00:00
await Provider . of < EventsProvider > ( context , listen: false )
. getAddedSessionNotes ( ) ;
2024-11-19 12:57:30 +00:00
//await ApiCall().dummyapi();
2024-09-06 06:30:31 +00:00
setState ( ( ) { } ) ;
}
@ override
Widget build ( BuildContext context ) {
return Consumer < EventsProvider > (
builder: ( BuildContext context , provider , Widget ? child ) {
// return SafeArea(
// top: false,
// child: Scaffold(
// appBar: CustomAppBar(
// title: "Events",
// backgroundcolor: Color.fromARGB(255, 0, 71, 132),
// ),
2024-10-07 12:45:45 +00:00
// // backgroundColor: const Color.fromARGB(255, 222 , 237, 247),
2024-09-06 06:30:31 +00:00
// 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 ,
2024-10-07 12:45:45 +00:00
// drawer: Drawer(
// child: Text("This will swipe from left to right"),
// ),
2024-09-06 06:30:31 +00:00
endDrawer: populateDrawer ( provider ) ,
appBar: AppBar (
automaticallyImplyLeading: false ,
2024-10-08 12:01:59 +00:00
backgroundColor: EventsConstants . blueColor ,
2024-10-07 12:45:45 +00:00
centerTitle: true ,
2024-09-06 06:30:31 +00:00
title: _isSearch
2024-10-07 12:45:45 +00:00
? Padding (
padding: EdgeInsets . only ( left: 30 ) ,
child: Container (
height: 40 ,
decoration: BoxDecoration (
color: Colors . white ,
borderRadius: BorderRadius . circular ( 5.0 ) ) ,
child: TextField (
controller: searchtextEditingController ,
2024-11-19 12:57:30 +00:00
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 ( ) ;
}
} ,
2024-10-07 12:45:45 +00:00
onChanged: ( String txt ) async {
if ( txt . length > = 2 ) {
2024-11-19 12:57:30 +00:00
search = txt ;
provider . isSearch = true ;
pagingController . refresh ( ) ;
// await provider.OnSearch(txt);
2024-10-07 12:45:45 +00:00
}
2024-11-19 12:57:30 +00:00
if ( txt . length = = 0 ) {
provider . isSearch = false ;
search = txt ;
pagingController . refresh ( ) ;
2024-10-07 12:45:45 +00:00
}
} ,
decoration: InputDecoration (
2024-10-08 12:01:59 +00:00
fillColor: EventsConstants . blueColor ,
2024-10-07 12:45:45 +00:00
contentPadding: EdgeInsets . symmetric ( vertical: 9.0 ) ,
border: OutlineInputBorder ( ) ,
hintText: " Search for events... " ,
// labelText: ' Search',
prefixIcon: Icon (
Icons . search ,
) ,
2024-09-06 06:30:31 +00:00
) ,
) ,
) ,
)
: Text (
" Events " ,
style: TextStyle ( color: Colors . white ) ,
) ,
2024-10-07 12:45:45 +00:00
// leading: IconButton(
// onPressed: () {},
// icon: Icon(
// Icons.person_4_outlined,
// size: 20,
// color: Colors.white,
// )),
2024-09-06 06:30:31 +00:00
actions: [
IconButton (
onPressed: ( ) async {
await provider . onSearchReset ( ) ;
setState ( ( ) {
_isSearch = ! _isSearch ;
if ( ! _isSearch ) {
searchtextEditingController . clear ( ) ;
2024-11-19 12:57:30 +00:00
search = " " ;
pagingController . refresh ( ) ;
2024-09-06 06:30:31 +00:00
}
} ) ;
} ,
icon: Icon (
_isSearch ? Icons . close : Icons . search ,
color: Colors . white ,
) )
] ,
) ,
2024-11-19 12:57:30 +00:00
body: Stack ( children: < Widget > [
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 < Widget > [
// 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 ) ,
2024-09-06 06:30:31 +00:00
) ,
2024-11-19 12:57:30 +00:00
) ,
] ;
} ,
body: Container (
2024-12-03 05:59:45 +00:00
//color: EventsConstants.bgcolor,
color: Colors . white ,
2024-11-19 12:57:30 +00:00
child: buildPaginationListView ( context , provider ) ) ,
2024-09-06 06:30:31 +00:00
) ,
2024-11-19 12:57:30 +00:00
) ,
] ) ,
2024-09-06 06:30:31 +00:00
) ,
) ;
2024-11-19 12:57:30 +00:00
// ),
// );
2024-09-06 06:30:31 +00:00
}
Widget getFilterBarUI ( EventsProvider provider ) {
return Stack (
children: < Widget > [
Positioned (
top: 0 ,
left: 0 ,
right: 0 ,
child: Container (
height: 24 ,
decoration: BoxDecoration (
2024-10-08 12:01:59 +00:00
color: EventsConstants . bgcolor ,
2024-09-06 06:30:31 +00:00
boxShadow: < BoxShadow > [
BoxShadow (
color: Colors . grey . withOpacity ( 0.2 ) ,
offset: const Offset ( 0 , - 2 ) ,
blurRadius: 8.0 ) ,
] ,
) ,
) ,
) ,
Container (
2024-12-03 05:59:45 +00:00
//color: EventsConstants.bgcolor,
color: Colors . white ,
2024-09-06 06:30:31 +00:00
child: Padding (
padding:
const EdgeInsets . only ( left: 16 , right: 16 , top: 8 , bottom: 4 ) ,
child: Row (
children: < Widget > [
// 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,
// ),
// ),
// ),
2024-10-07 12:45:45 +00:00
2024-09-06 06:30:31 +00:00
Container (
child: Wrap (
children: [
Padding (
padding: const EdgeInsets . only ( left: 8.0 , right: 2.0 ) ,
child: CupertinoSwitch (
activeColor: Color . fromARGB ( 255 , 0 , 71 , 132 ) ,
value: provider . isFavSeleted ,
2024-11-19 12:57:30 +00:00
onChanged: ( value ) {
2024-09-06 06:30:31 +00:00
provider . isFavSeleted = value ;
if ( provider . isFavSeleted ) {
2024-11-19 12:57:30 +00:00
pagingController . refresh ( ) ;
//_pagingController.
// _pagingController
// .addPageRequestListener((pageKey) {
// await _fetchPage(0);
// });
2024-09-06 06:30:31 +00:00
} else {
2024-11-19 12:57:30 +00:00
provider . isFavSeleted = false ;
provider . isAllSelected = ! provider . isAllSelected ;
pagingController . refresh ( ) ;
// _pagingController
// .addPageRequestListener((pageKey) {
// await _fetchPage(0);
// });
2024-09-06 06:30:31 +00:00
}
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,
// ),
// ),
// ),
// ),
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<dynamic>(
// context,
// MaterialPageRoute<dynamic>(
// builder: (BuildContext context) =>
// populateDrawer(provider),
// fullscreenDialog: false),
// );
_scaffoldKey . currentState ? . openEndDrawer ( ) ;
} ,
child: Padding (
padding: const EdgeInsets . only ( left: 8 ) ,
child: Row (
children: < Widget > [
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: < Widget > [
Padding (
padding: const EdgeInsets . only ( right: 12 , top: 8 , bottom: 8 ) ,
child: Container (
decoration: BoxDecoration (
2024-10-08 12:01:59 +00:00
color: EventsConstants . bgcolor ,
2024-09-06 06:30:31 +00:00
borderRadius: const BorderRadius . all (
Radius . circular ( 24.0 ) ,
) ,
boxShadow: < 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 ) {
2024-11-19 12:57:30 +00:00
search = txt ;
provider . isSearch = true ;
pagingController . refresh ( ) ;
// await provider.OnSearch(txt);
2024-09-06 06:30:31 +00:00
}
if ( txt . length < = 3 ) {
2024-11-19 12:57:30 +00:00
provider . isSearch = false ;
pagingController . refresh ( ) ;
//await provider.onSearchReset();
2024-09-06 06:30:31 +00:00
}
} ,
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>[
// 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 ( ) ) ;
2024-11-19 12:57:30 +00:00
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();
2024-09-06 06:30:31 +00:00
} ,
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 > [
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: < Widget > [
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: < Widget > [
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 < void > dialogBuilder ( BuildContext context , EventsProvider provider ) {
return showDialog < void > (
context: context ,
builder: ( BuildContext context ) {
// return AlertDialog(
// title: const Text('Session Notes'),
return populateDrawer ( provider ) ;
// actions: <Widget>[
// 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 < String > sortEvents = [ " All Events " , " My Events " ] ;
Widget dropDown ( {
Widget ? underline ,
Widget ? icon ,
TextStyle ? style ,
TextStyle ? hintStyle ,
Color ? dropdownColor ,
} ) = >
DropdownButton < String > (
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 < String > (
value: session , child: Text ( session ) ) )
. toList ( ) ) ;
populateDrawer ( EventsProvider provider ) {
return Theme (
2024-10-08 12:01:59 +00:00
data: Theme . of ( context ) . copyWith ( canvasColor: EventsConstants . bgcolor ) ,
2024-09-06 06:30:31 +00:00
child: Container (
width: MediaQuery . of ( context ) . size . width * 0.60 ,
2024-10-08 12:01:59 +00:00
color: EventsConstants . bgcolor ,
2024-09-06 06:30:31 +00:00
child: Drawer (
child: SingleChildScrollView (
scrollDirection: Axis . vertical ,
child: Column (
2024-11-19 12:57:30 +00:00
crossAxisAlignment: CrossAxisAlignment . end ,
2024-09-06 06:30:31 +00:00
children: < Widget > [
// DrawerHeader(
// child: Center(
// child: Text('Filters'),
// // child: Image.asset("assets/images/lf_logo.png",
// // height: 100, width: 100),
// ),
// ),
Container (
2024-11-19 12:57:30 +00:00
color: EventsConstants . bgcolor ,
2024-09-06 06:30:31 +00:00
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 ( ) ,
2024-11-19 12:57:30 +00:00
// Align(
// alignment: Alignment.topRight,
// child: Container(
// height: 30,
// child: OutlinedButton(
// onPressed: () {
// },
// child: Text(
// 'Apply',
// style: TextStyle(
// // fontFamily: "SourceSerif",
// fontSize: 14,
// color: Colors.white,
// fontWeight: FontWeight.normal),
// ),
// style: OutlinedButton.styleFrom(
// shape: StadiumBorder(),
// backgroundColor: Colors.green,
// ),
// ),
// ),
// ),
2024-09-06 06:30:31 +00:00
SizedBox (
width: 8.0 ,
) ,
] ,
) ,
) ,
Divider (
height: 7 ,
color: Colors . black ,
) ,
// SizedBox(
// width: (MediaQuery.of(context).size.width * 0.99) / 2,
// child: ListTile(
// title: Text('Search Scope'),
// subtitle: customAutoCompletedropdown(),
// onTap: () {},
// ),
// ),
// StringAutoCompleteTags(
// initialTags: [
// TagsData(name: "cancer screening ", id: "1"),
// TagsData(name: "cosmetic surgery", id: "2"),
// TagsData(name: "sleep medicine", id: "3"),
// TagsData(name: "ADHD", id: "4"),
// ],
// hintText: "Enter scope",
// ),
// Container(
// padding: const EdgeInsets.all(4.0),
// height: 40,
// width: double.infinity,
// decoration: BoxDecoration(
// border: Border.all(color: Colors.grey),
// borderRadius: BorderRadius.circular(8.0)),
// child: dropDown(underline: Container())),
Wrap (
//spacing: 4,
// runSpacing: 4,
// crossAxisAlignment: WrapCrossAlignment.start,
// runAlignment: WrapAlignment.spaceEvenly,
// alignment: WrapAlignment.spaceEvenly,
// direction: Axis.horizontal,
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
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 < TagsData > taglist = [ ] ;
taglist = provider . therapeuticList
. map ( ( e ) = >
TagsData ( id: e . id , name: e . therapeuticName ) )
. toList ( ) ;
if ( textEditingValue . text = = ' ' ) {
return const Iterable < TagsData > . 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 < TagsData > . empty ( ) ;
}
if ( textEditingValue . text . length > = 3 ) {
List < Keyword > 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 < TagsData > . 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 < TagsData > . 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: ( ) { } ,
) ,
) ,
] ,
) ,
2024-11-19 12:57:30 +00:00
] ,
) ,
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 ,
) ) ,
) ,
) ,
) ,
2024-09-06 06:30:31 +00:00
] ,
) ,
] ,
) ,
) ,
) ,
) ,
) ;
}
Widget buildDateWidget ( TextEditingController controller , String hint ) {
return SizedBox (
2024-11-19 12:57:30 +00:00
//width: isTablet ? 200 : MediaQuery.of(context).size.width,
2024-09-06 06:30:31 +00:00
height: isTablet ? 50 : 40 ,
child: TextField (
controller: controller ,
//editing controller of this TextField
decoration: InputDecoration (
2024-11-19 12:57:30 +00:00
border: OutlineInputBorder ( ) ,
2024-09-06 06:30:31 +00:00
// border: OutlineInputBorder(
// borderRadius: BorderRadius.circular(10.0),
// ),
// labelStyle: const TextStyle(fontSize: 16),
2024-11-19 12:57:30 +00:00
suffixIcon: const Icon (
Icons . calendar_today ,
size: 16 ,
) , //icon of text field
2024-09-06 06:30:31 +00:00
// labelText: "Enter Date" //label text of field
2024-11-19 12:57:30 +00:00
// hintText: hint,
2024-09-06 06:30:31 +00:00
) ,
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 ( ) ,
2024-11-19 12:57:30 +00:00
firstDate: DateTime
. now ( ) , //DateTime.now() - not to allow to choose before today.
2024-09-06 06:30:31 +00:00
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
2024-11-19 12:57:30 +00:00
if ( hint = = " Start Date " ) {
filter_startdate = formattedDate ;
} else {
filter_enddate = formattedDate ;
}
2024-09-06 06:30:31 +00:00
setState ( ( ) {
// output date to TextField value.
2024-11-19 12:57:30 +00:00
2024-09-06 06:30:31 +00:00
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 < String > 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 < double > animation = Tween < double > ( 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 ] ,
) ;
} ,
) ;
}
2024-11-19 12:57:30 +00:00
Set < int > selectedIndexes = { } ;
Widget buildPaginationListView (
BuildContext context , EventsProvider provider ) {
return RefreshIndicator (
onRefresh: ( ) async = > pagingController . refresh ( ) ,
child: PagedListView < int , EventsList > (
pagingController: pagingController ,
2024-12-03 05:59:45 +00:00
padding: EdgeInsets . zero ,
2024-11-19 12:57:30 +00:00
builderDelegate: PagedChildBuilderDelegate < EventsList > (
itemBuilder: ( BuildContext context , item , int index ) {
2024-12-03 05:59:45 +00:00
print (
" VALUE RENDER ${ item . eventId } - ${ item . name1 } - ${ item . eventUserInterest } " ) ;
2024-11-19 12:57:30 +00:00
final int count = provider . eventList . length > 10
? 10
: provider . eventList . length ;
final Animation < double > animation =
Tween < double > ( 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 ,
) ;
} ,
) ) ,
) ;
}
2024-09-06 06:30:31 +00:00
Widget _buildlistCard (
{ required Animation < double > ? 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 (
2024-12-09 09:05:56 +00:00
//elevation: 4,
color: EventsConstants . homeCardBackgound ,
//surfaceTintColor: Colors.white,
surfaceTintColor: EventsConstants . homeCardBackgound ,
2024-09-06 06:30:31 +00:00
// 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: ( ) {
2024-12-09 09:05:56 +00:00
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: ( ) { } ,
) ;
}
2024-09-06 06:30:31 +00:00
// Navigator.of(context).push(new MaterialPageRoute<Null>(
// builder: (BuildContext context) {
// return new EventsTab();
// },
// fullscreenDialog: true));
} ,
child: Card (
2024-12-03 05:59:45 +00:00
elevation: 1 ,
2024-10-08 12:01:59 +00:00
shadowColor: EventsConstants . bgcolor ,
2024-09-06 06:30:31 +00:00
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(),
) ,
) ;
}
2024-12-03 05:59:45 +00:00
buildCardView (
BuildContext context , EventsList event , EventsProvider provider ) {
2024-12-09 09:05:56 +00:00
// print(
// "CHECK EVENT INTERESTED : ${provider.checkIfUserInterested(event.eventId ?? "")}}");
2024-09-06 06:30:31 +00:00
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),
2024-12-09 09:05:56 +00:00
// color: Colors.white,
color: EventsConstants . homeCardBackgound ,
2024-09-06 06:30:31 +00:00
borderRadius: BorderRadius . all ( Radius . circular ( 20 ) ) ) ,
// height: MediaQuery.of(context).size.height * 0.2,
2024-12-03 05:59:45 +00:00
// height: 136,
2024-09-06 06:30:31 +00:00
// height: double.minPositive,
padding: isTablet
2024-12-09 09:05:56 +00:00
? EdgeInsets . symmetric ( horizontal: 12.0 , vertical: 12.0 )
2024-09-06 06:30:31 +00:00
: 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 ,
2024-11-19 12:57:30 +00:00
child: RichText (
text: TextSpan ( children: [
// WidgetSpan(
// child: Icon(Icons.bookmark,
// color: EventsConstants.blueColor,
// size: isTablet ? 14 : 18)
// // provider.ifOfflineExists(event.eventId!)
// // ? Icon(Icons.bookmark,
// // color: EventsConstants.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 ,
2024-12-09 09:05:56 +00:00
fontSize: isTablet ? 18 : 16 ,
2024-11-19 12:57:30 +00:00
// fontFamily: "SourceSerif",
) ,
// maxLines: isTablet ? 4 : 4,
// softWrap: true,
// overflow: TextOverflow.ellipsis,
2024-09-06 06:30:31 +00:00
) ,
2024-11-19 12:57:30 +00:00
] ) ) ,
2024-09-06 06:30:31 +00:00
) ,
2024-12-03 05:59:45 +00:00
//const Spacer(),
2024-09-06 06:30:31 +00:00
SizedBox (
height: 14 ,
) ,
// Positioned(
// child:
Align (
alignment: FractionalOffset . bottomLeft ,
child: Row (
2024-12-03 05:59:45 +00:00
crossAxisAlignment: CrossAxisAlignment . end ,
2024-09-06 06:30:31 +00:00
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 (
2024-11-19 12:57:30 +00:00
text:
2024-12-03 05:59:45 +00:00
' ${ CustomDateFormatter ( ) . formatYearDate ( CustomDateFormatter ( ) . convertStringToDate ( event . start ! ) ) } to ${ CustomDateFormatter ( ) . formatYearDate ( CustomDateFormatter ( ) . convertStringToDate ( event . end ! ) ) } ' ,
2024-09-06 06:30:31 +00:00
style: TextStyle (
color: Colors . black ,
//fontStyle: FontStyle.italic,
2024-12-09 09:05:56 +00:00
fontSize: isTablet ? 16 : 12 ) ,
2024-09-06 06:30:31 +00:00
) ,
] ,
) ,
) ,
SizedBox (
height: 5.0 ,
) ,
RichText (
textAlign: TextAlign . justify ,
text: TextSpan (
children: [
WidgetSpan (
child: Icon ( Icons . location_on , size: 16 ) ,
) ,
TextSpan (
text:
2024-10-07 12:45:45 +00:00
' ${ event . city ! = null & & event . city ! = " " ? " $ {event.city } , " : ""} ${ event . region ! = null & & event . region ! = " " ? " $ {event.region } , " : ""} ${ event . country ! = null & & event . country ! = " " ? " $ {event.country } " : ""} ' ,
2024-09-06 06:30:31 +00:00
style: TextStyle (
color: Colors . black ,
//fontStyle: FontStyle.italic,
2024-11-19 12:57:30 +00:00
2024-12-09 09:05:56 +00:00
fontSize: isTablet ? 16 : 12 ) ,
2024-09-06 06:30:31 +00:00
) ,
] ,
) ,
) ,
] ,
) ,
Align (
alignment: FractionalOffset . bottomRight ,
2024-11-19 12:57:30 +00:00
child: Row (
2024-09-06 06:30:31 +00:00
children: [
2024-11-19 12:57:30 +00:00
Column (
crossAxisAlignment: CrossAxisAlignment . end ,
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
children: [
2024-12-09 09:05:56 +00:00
provider . ifOfflineExists ( event . eventId ? ? " " )
2024-11-19 12:57:30 +00:00
? Padding (
padding: EdgeInsets . only ( right: 10 ) ,
child: Icon ( Icons . bookmark ,
color: EventsConstants . blueColor ,
size: isTablet ? 14 : 18 ) ,
)
: SizedBox . shrink ( ) ,
SizedBox (
width: 40 ,
height: 30 ,
child: FloatingActionButton . extended (
elevation: 1 ,
shape: CircleBorder ( ) ,
backgroundColor: EventsConstants . bgcolor ,
2024-12-03 05:59:45 +00:00
//backgroundColor: EventsConstants.homeCardBackgound,
2024-11-19 12:57:30 +00:00
onPressed: ( ) async {
// event.isfav = !event.isfav;
2024-12-03 05:59:45 +00:00
if ( event . eventUserInterest ! ) {
2024-11-19 12:57:30 +00:00
//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 < double > 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 (
2024-09-06 06:30:31 +00:00
Icons . favorite ,
2024-11-19 12:57:30 +00:00
color: Colors . grey ,
2024-09-06 06:30:31 +00:00
size: 14 ,
2024-11-19 12:57:30 +00:00
) ) ) ,
) ,
SizedBox (
height: 2 ,
) ,
2024-12-03 05:59:45 +00:00
event . eventUserInterest !
2024-11-19 12:57:30 +00:00
? 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 ) ,
) ,
] ,
2024-09-06 06:30:31 +00:00
) ,
2024-11-19 12:57:30 +00:00
)
: Center (
child: RichText (
text: TextSpan (
children: [
TextSpan (
text: ' Follow ' ,
style: TextStyle (
color: Colors . grey [ 600 ] ,
fontSize: isTablet ? 14 : 10 ) ,
) ,
] ,
2024-09-06 06:30:31 +00:00
) ,
2024-11-19 12:57:30 +00:00
) ,
2024-09-06 06:30:31 +00:00
) ,
2024-11-19 12:57:30 +00:00
] ,
) ,
2024-09-06 06:30:31 +00:00
] ,
) ,
) ,
// 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 ;
}
}