import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:onufitness/constants/color_constant.dart'; import 'package:onufitness/constants/text_constant.dart'; import 'package:onufitness/screens/rise/widgets/ongoing_upcoming_pagination_widget.dart'; import 'package:onufitness/utils/helper_function.dart'; import 'package:onufitness/screens/rise/controllers/rise_controller.dart'; class OngoingTab extends StatelessWidget { OngoingTab({super.key}); final RiseController controller = Get.find(); @override Widget build(BuildContext context) { return GestureDetector( onTap: () { FocusScope.of(context).unfocus(); }, child: Column( children: [ // Search bar Container( margin: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.h), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(12.r), ), child: TextField( controller: controller.ongoingSearchController, textInputAction: TextInputAction.search, onSubmitted: (value) { FocusScope.of(context).unfocus(); }, onChanged: (value) { controller.ongoingSearchText.value = value; }, decoration: InputDecoration( hintText: 'Search Challenges..', hintStyle: TextStyle( color: lightGreyColor, fontSize: smallSizeText, ), prefixIcon: Icon( Icons.search, color: lightGreyColor, size: 20.sp, ), suffixIcon: Obx(() { return controller.ongoingSearchText.value != "" ? GestureDetector( onTap: () { controller.clearOngoingSearch(); controller.ongoingSearchText.value = ""; FocusScope.of(context).unfocus(); }, child: Icon( Icons.clear, color: Color(darkGreyColor), size: 20.sp, ), ) : SizedBox.shrink(); }), enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: lightGreyColor), borderRadius: BorderRadius.circular(8.r), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: lightGreyColor), borderRadius: BorderRadius.circular(8.r), ), contentPadding: EdgeInsets.symmetric( horizontal: 16.w, vertical: 12.h, ), filled: true, fillColor: Colors.white, ), ), ), // Content Expanded( child: Obx(() { if (controller.ongoingChallenges.isEmpty && controller.isOngoingLoading.value) { return Center(child: CircularProgressIndicator()); } if (controller.ongoingChallenges.isEmpty) { return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon(Icons.search_off, size: 64.sp, color: Colors.grey), SizedBox(height: 16.h), Text( 'No ongoing challenges found', style: TextStyle( fontSize: 16.sp, color: Colors.grey[600], ), ), SizedBox(height: 8.h), ElevatedButton( onPressed: () => controller.refreshOngoingChallenges(), style: ElevatedButton.styleFrom( backgroundColor: Colors.white, padding: EdgeInsets.symmetric( horizontal: 24.w, vertical: 12.h, ), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(30.r), ), elevation: 5, shadowColor: Colors.black26, ), child: Icon(Icons.refresh), ), ], ), ); } return RefreshIndicator( onRefresh: () async { await controller.refreshOngoingChallenges(); }, child: isTablet ? paginationGridView(controller, true) : paginationListView(controller, true), ); }), ), ], ), ); } }