2026-01-13 11:36:24 +05:30

95 lines
2.7 KiB
Dart

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/screens/rise/views/ongoing_tab.dart';
import 'package:onufitness/screens/rise/views/upcoming_tab.dart';
import '../controllers/rise_controller.dart';
class ExploreTab extends StatefulWidget {
const ExploreTab({super.key});
@override
State<ExploreTab> createState() => _ExploreTabState();
}
class _ExploreTabState extends State<ExploreTab> {
final controller = Get.find<RiseController>();
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
apiCall();
});
}
apiCall() async {
await controller.fetchOngoingChallenges();
await controller.fetchUpcomingChallenges();
}
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 2,
child: GestureDetector(
onTap: () {
FocusScope.of(context).unfocus();
},
child: Column(
children: [
Container(
margin: EdgeInsets.all(16.w),
decoration: BoxDecoration(
color: textFieldFillColor,
borderRadius: BorderRadius.circular(25.r),
),
child: TabBar(
indicator: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.circular(25.r),
),
labelColor: Colors.white,
unselectedLabelColor: Color(darkGreyColor),
dividerColor: Colors.transparent,
tabs: [
Tab(
child: Container(
padding: EdgeInsets.symmetric(horizontal: 20.w),
child: Text(
'Ongoing',
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 14.sp,
),
),
),
),
Tab(
child: Container(
padding: EdgeInsets.symmetric(horizontal: 20.w),
child: Text(
'Upcoming',
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 14.sp,
),
),
),
),
],
),
),
Expanded(
child: TabBarView(children: [OngoingTab(), UpcomingTab()]),
),
],
),
),
);
}
}