improvements
parent
6adea49150
commit
37c3b54237
@ -0,0 +1,95 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/string_extensions.dart';
|
||||
import 'package:test_sa/extensions/text_extensions.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
import 'package:test_sa/models/new_models/work_order_detail_model.dart';
|
||||
import 'package:test_sa/modules/cm_module/utilities/service_request_utils.dart';
|
||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
|
||||
class TotalWorkingTimeDetailBottomSheet extends StatelessWidget {
|
||||
final List<ActivityMaintenanceTimers> activityMaintenanceTimers;
|
||||
|
||||
const TotalWorkingTimeDetailBottomSheet({Key? key, this.activityMaintenanceTimers = const []}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: MediaQuery.of(context).size.height * 0.5,
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
width: 40.toScreenWidth,
|
||||
height: 5.toScreenHeight,
|
||||
decoration: BoxDecoration(color: AppColor.neutral40, borderRadius: BorderRadius.circular(30)),
|
||||
),
|
||||
8.height,
|
||||
Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: Text(
|
||||
"Total Working Time",
|
||||
style: AppTextStyles.heading3.copyWith(fontWeight: FontWeight.w600, color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
||||
),
|
||||
),
|
||||
ListView.separated(
|
||||
itemCount: activityMaintenanceTimers.length,
|
||||
separatorBuilder: (cxt, index) => const Divider().defaultStyle(context),
|
||||
padding: const EdgeInsets.only(top: 16, bottom: 16),
|
||||
itemBuilder: (cxt, index) {
|
||||
int totalWorkingHours = DateTime.parse(activityMaintenanceTimers[index].endTime!).difference(DateTime.parse(activityMaintenanceTimers[index].startTime!)).inSeconds;
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
text: "From: ",
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(color: context.isDark ? null : AppColor.neutral20, fontWeight: FontWeight.w500),
|
||||
children: [TextSpan(text: activityMaintenanceTimers[index].startTime!.toServiceRequestDetailsFormat, style: Theme.of(context).textTheme.bodySmall)])),
|
||||
4.height,
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
text: "To: ",
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(color: context.isDark ? null : AppColor.neutral20, fontWeight: FontWeight.w500),
|
||||
children: [TextSpan(text: activityMaintenanceTimers[index].endTime!.toServiceRequestDetailsFormat, style: Theme.of(context).textTheme.bodySmall)])),
|
||||
4.height,
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
text: "Duration: ",
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(color: context.isDark ? null : AppColor.neutral20, fontWeight: FontWeight.w500),
|
||||
children: [TextSpan(text: " ${ServiceRequestUtils.formatTimerDuration(totalWorkingHours.round())}", style: Theme.of(context).textTheme.bodySmall)])),
|
||||
],
|
||||
);
|
||||
}).expanded,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TimerModel {
|
||||
int? id;
|
||||
String? startTime;
|
||||
String? endTime;
|
||||
dynamic workingHours;
|
||||
|
||||
TimerModel({this.id, this.startTime, this.endTime, this.workingHours});
|
||||
|
||||
TimerModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
startTime = json['startTime'];
|
||||
endTime = json['endTime'];
|
||||
workingHours = json['workingHours'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['startTime'] = startTime;
|
||||
data['endTime'] = endTime;
|
||||
data['workingHours'] = workingHours;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue