import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../../../core/constants/translation_keys.dart'; import '../../../custom_widgets/custom_app_bar.dart'; import '../../../custom_widgets/custom_no_record.dart'; import '../../../res/app_colors.dart'; import '../controllers/user_activity_controller.dart'; class UserActivityView extends GetView { const UserActivityView({Key? key}) : super(key: key); @override Widget build(BuildContext context) { controller.context = context; return Scaffold( appBar: DashBoardAppBar( title: TranslationKeys.makeTranslation( TranslationKeys.textUserActivityTitle), onBackButtonPressed: () { Get.back(); }, ), body: Obx(() { return Column(children: [ Padding( padding: const EdgeInsets.all(8.0), child: Card( surfaceTintColor: Colors.white, margin: const EdgeInsets.symmetric(horizontal: 20, vertical: 10), elevation: 5.0, child: Container( padding: const EdgeInsets.all(8), decoration: const BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(10)) // Add border radius ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ InkWell( child: SizedBox( width: 120, child: Padding( padding: const EdgeInsets.only(left: 0, right: 0), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( Icons.calendar_month_rounded, size: 18.0, color: Colors.black.withOpacity(0.6), ), const SizedBox( width: 5, ), Text( controller.fromDate.value, style: Theme.of(context) .textTheme .bodyMedium! .copyWith(fontSize: 12), ), ], ), ), ), onTap: () { controller.selectFromDate(); }, ), Container( height: 30, // Adjust the height as needed width: 1, // Adjust the width as needed color: Colors.grey, // Adjust the color as needed ), InkWell( child: SizedBox( width: 120, child: Padding( padding: const EdgeInsets.only(left: 0, right: 0), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( Icons.calendar_month_rounded, size: 18.0, color: Colors.black.withOpacity(0.6), ), const SizedBox( width: 5, ), Text( controller.toDate.value, style: Theme.of(context) .textTheme .bodyMedium! .copyWith(fontSize: 12), ), ], ), ), ), onTap: () { controller.selectToDate(); }, ), ], ), ), ), ), const SizedBox(height: 5), controller.isLoading.value ? const SizedBox() : controller.userActivities.isNotEmpty ? Expanded( flex: 2, child: ListView.builder( itemCount: controller.userActivities.length, itemBuilder: (context, index) { return Padding( padding: EdgeInsets.only( left: 10, right: 10, top: index == 0 ? 10 : 5, bottom: index == controller.userActivities.length - 1 ? 10 : 5), child: Card( surfaceTintColor: Colors.white, child: Padding( padding: const EdgeInsets.all(12.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( controller.userActivities[index].date .toString(), style: Theme.of(context) .textTheme .bodyMedium), const SizedBox( height: 10, ), Text( controller .userActivities[index].activity, style: Theme.of(context) .textTheme .titleSmall), const SizedBox( height: 5, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( "${TranslationKeys.makeTranslation(TranslationKeys.textUserActivityChannel)} ${controller.userActivities[index]?.channel ?? ' Found'}", style: Theme.of(context) .textTheme .bodyMedium), Text( TranslationKeys.makeTranslation( "${TranslationKeys.makeTranslation(TranslationKeys.textUserActivityDevice)}: ${controller.userActivities[index].deviceName}"), style: Theme.of(context) .textTheme .bodyMedium ?.copyWith( color: AppColors .minusColor)), ]), ], ), ), ), ); }, ), ) : const CustomNoRecord( title: "No Record Found", description: "We couldn't find any activity at this moment") ]); })); } }