import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:onufitness/constants/asset_constants.dart'; import 'package:onufitness/constants/text_constant.dart'; import 'package:onufitness/screens/echoboard/controllers/profile_controller.dart'; import 'package:onufitness/screens/echoboard/models/goal_badges_response_model.dart'; void showBadgesBottomSheet({ required BuildContext context, required String userID, required ProfileController profileController, }) async { showModalBottomSheet( context: context, isScrollControlled: true, backgroundColor: Colors.transparent, builder: (context) { return DraggableScrollableSheet( expand: false, maxChildSize: 0.9, minChildSize: 0.3, initialChildSize: 0.6, builder: (_, controller) { return Container( padding: EdgeInsets.all(16.w), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only( topLeft: Radius.circular(20.r), topRight: Radius.circular(20.r), ), ), child: Column( children: [ Expanded( child: FutureBuilder>( future: profileController.fetchCompletedGoalsForBadges( userId: userID, ), builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return Center( child: CircularProgressIndicator(color: Colors.black), ); } if (!snapshot.hasData || snapshot.data!.isEmpty) { return SizedBox( width: double.infinity, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( height: 90.h, width: 90.h, decoration: BoxDecoration( shape: BoxShape.circle, color: Colors.grey.shade100, ), padding: EdgeInsets.all(20.w), child: Icon( Icons.emoji_events_outlined, size: 40.sp, color: Colors.grey.shade400, ), ), SizedBox(height: 16.h), Text( "No Badges Found", style: TextStyle( fontSize: mediumSizeText + 1, fontWeight: FontWeight.w600, color: Colors.black87, ), ), SizedBox(height: 6.h), ], ), ); } final goals = snapshot.data!; return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ // Heading Padding( padding: EdgeInsets.symmetric( horizontal: 16.w, vertical: 12.h, ), child: Text( "Completed Goals", style: TextStyle( fontSize: mediumSizeText, fontWeight: FontWeight.bold, color: Colors.black87, ), ), ), // Optional divider Divider( color: Colors.grey.shade300, thickness: 1, height: 1, ), // List of goals Expanded( child: ListView.builder( controller: controller, itemCount: goals.length, padding: EdgeInsets.symmetric(vertical: 8.h), itemBuilder: (context, index) { final goal = goals[index]; return Padding( padding: EdgeInsets.symmetric( vertical: 6.h, horizontal: 16.w, ), child: ListTile( contentPadding: EdgeInsets.zero, leading: Image.asset( AssetConstants.goalAchievementsReward, height: 40.h, width: 40.w, ), title: Text( goal.goalTitle ?? "Goal Title", style: TextStyle( fontSize: mediumSizeText, fontWeight: FontWeight.w600, ), ), tileColor: Colors.grey.shade50, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12.r), ), ), ); }, ), ), ], ); }, ), ), // Safe area padding for bottom SizedBox(height: MediaQuery.of(context).viewPadding.bottom), ], ), ); }, ); }, ); }