diff --git a/lib/ui/pages/home_page.dart b/lib/ui/pages/home_page.dart index 7e963b1..b4558b1 100644 --- a/lib/ui/pages/home_page.dart +++ b/lib/ui/pages/home_page.dart @@ -20,43 +20,40 @@ import 'package:flutter_svg/svg.dart'; import 'view_all_page.dart'; - class HomePage extends StatefulWidget { HomePage({super.key}); @override _HomePageState createState() => _HomePageState(); - } -class _HomePageState extends State { - String address_locality=""; - String address_country=""; +class _HomePageState extends State { + String address_locality = ""; + String address_country = ""; late LocationController _controller; late locationModel lc; @override - void initState(){ - + void initState() { super.initState(); - _controller=LocationController(); - lc=locationModel(country: "", locality: ""); + _controller = LocationController(); + lc = locationModel(country: "", locality: ""); _updateLocation(); } - Future _updateLocation() async{ - try{ + Future _updateLocation() async { + try { lc = await _controller.getCurrentLocation(); setState(() { address_locality = lc.locality; address_country = lc.country; }); - }catch(e){ + } catch (e) { print('Error updating location: $e'); setState(() { - address_locality="No address"; - address_country=""; + address_locality = "No address"; + address_country = ""; }); } } @@ -96,7 +93,9 @@ class _HomePageState extends State { Navigator.push( context, MaterialPageRoute( - builder: (context) => const ViewAllPage(isPopularEvent: true,)), + builder: (context) => const ViewAllPage( + isPopularEvent: true, + )), ); }, child: const Text( @@ -104,8 +103,7 @@ class _HomePageState extends State { style: TextStyle( fontWeight: FontWeight.w500, fontSize: 14, - color: AppColors.primaryColor - ), + color: AppColors.primaryColor), ), ) ], @@ -124,30 +122,33 @@ class _HomePageState extends State { }, ), const SizedBox(height: 12), - Divider(height: 1, - endIndent: 16, - indent: 16, - thickness: 0.5, - color: Theme.of(context).disabledColor.withOpacity(0.1), + Divider( + height: 1, + endIndent: 16, + indent: 16, + thickness: 0.5, + color: Theme.of(context).disabledColor.withOpacity(0.1), ), const SizedBox(height: 8), Padding( - padding: const EdgeInsets.symmetric(horizontal: 24,vertical: 12), + padding: + const EdgeInsets.symmetric(horizontal: 24, vertical: 12), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ const Text( "Event This Month", style: TextStyle( - fontWeight: FontWeight.w600, - fontSize: 18), + fontWeight: FontWeight.w600, fontSize: 18), ), GestureDetector( onTap: () { Navigator.push( context, MaterialPageRoute( - builder: (context) => const ViewAllPage(isPopularEvent: false,)), + builder: (context) => const ViewAllPage( + isPopularEvent: false, + )), ); }, child: const Text( @@ -155,8 +156,7 @@ class _HomePageState extends State { style: TextStyle( fontWeight: FontWeight.w400, fontSize: 12, - color: AppColors.primaryColor - ), + color: AppColors.primaryColor), ), ) ], @@ -192,9 +192,9 @@ class _HomePageState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row(children: [ - Image.asset( - 'assets/images/location.png', + Row(children: [ + Image.asset( + 'assets/images/location.png', width: 20, ), const SizedBox(width: 8), @@ -207,7 +207,7 @@ class _HomePageState extends State { ), ), ]), - const SizedBox(height: 8), + const SizedBox(height: 8), Text( address_locality, style: const TextStyle( @@ -218,7 +218,7 @@ class _HomePageState extends State { ], ), ), - const Spacer(), + const Spacer(), GestureDetector( onTap: () { // Navigate to the specific page here @@ -246,13 +246,13 @@ class _HomePageState extends State { ); _buildSearch() => GestureDetector( - onTap: () { - Navigator.push( + onTap: () { + Navigator.push( context, MaterialPageRoute(builder: (context) => const MySearchWidget()), ); - }, - child: Container( + }, + child: Container( height: 48, width: double.infinity, margin: const EdgeInsets.symmetric(horizontal: 24), @@ -268,14 +268,13 @@ class _HomePageState extends State { const Text( "Search event...", style: TextStyle( - color: AppColors.greyTextColor, - fontWeight: FontWeight.w500 - ), + color: AppColors.greyTextColor, + fontWeight: FontWeight.w500), ) ], ), ), - ); + ); _listPopularEvent(List events) => SizedBox( width: MediaQuery.of(context).size.width, @@ -284,13 +283,8 @@ class _HomePageState extends State { physics: const BouncingScrollPhysics(), scrollDirection: Axis.horizontal, autoplay: true, - pagination: const SwiperPagination( - alignment: Alignment.bottomCenter - ), - control: const SwiperControl( - size: 0, - padding: EdgeInsets.all(0) - ), + pagination: const SwiperPagination(alignment: Alignment.bottomCenter), + control: const SwiperControl(size: 0, padding: EdgeInsets.all(0)), itemCount: events.length, itemBuilder: (context, index) => GestureDetector( onTap: () => Navigator.pushNamed( diff --git a/lib/ui/widgets/search_widget.dart b/lib/ui/widgets/search_widget.dart index a34f881..5f36aa6 100644 --- a/lib/ui/widgets/search_widget.dart +++ b/lib/ui/widgets/search_widget.dart @@ -113,7 +113,7 @@ class _MySearchWidgetState extends State { context, NamedRoutes.detailScreen)), child: CardEventThisMonth( - eventModel: eventList[index], + eventModel: filteredList[index], ), ); }, @@ -136,11 +136,12 @@ class _MySearchWidgetState extends State { List tempFilteredList = []; for (var event in eventList) { if (event.title.toLowerCase().contains(searchText.toLowerCase())) { + print(event.title.toLowerCase()); tempFilteredList.add(event); } } setState(() { - filteredList = tempFilteredList; // Set the filtered list + filteredList = tempFilteredList; // Set the filtered }); } }