You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.1 KiB
Dart
81 lines
2.1 KiB
Dart
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
|
|
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
|
|
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
|
|
import 'package:hmg_patient_app_new/theme/colors.dart';
|
|
|
|
Widget buildTime(Duration duration, {bool isHomePage = false}) {
|
|
String twoDigits(int n) => n.toString().padLeft(2, '0');
|
|
final hours = twoDigits(duration.inHours);
|
|
final minutes = twoDigits(duration.inMinutes.remainder(60));
|
|
final seconds = twoDigits(duration.inSeconds.remainder(60));
|
|
|
|
return Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
buildTimeColumn(hours, LocaleKeys.hours.tr()),
|
|
buildTimeColumn(minutes, LocaleKeys.mins.tr()),
|
|
buildTimeColumn(seconds, LocaleKeys.secs.tr(), isLast: true),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget buildTimeColumn(String time, String label, {bool isLast = false}) {
|
|
return Column(
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Column(
|
|
children: [
|
|
Row(
|
|
children: [
|
|
buildDigit(time[0]),
|
|
SizedBox(width: 2.w),
|
|
buildDigit(time[1]),
|
|
],
|
|
),
|
|
SizedBox(height: 4.h),
|
|
buildLabel(label),
|
|
],
|
|
),
|
|
if (!isLast) ...[
|
|
SizedBox(width: 8.w),
|
|
buildTimeSeparator(),
|
|
SizedBox(width: 8.w),
|
|
],
|
|
],
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget buildDigit(String digit) {
|
|
return Text(
|
|
digit,
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.black,
|
|
fontSize: 27.f,
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget buildLabel(String label) {
|
|
return label.toText12(isBold: false, color: AppColors.textColor, fontWeight: FontWeight.w500);
|
|
}
|
|
|
|
Widget buildTimeSeparator() {
|
|
return Padding(
|
|
padding: EdgeInsets.only(bottom: 16.h),
|
|
child: Text(
|
|
":",
|
|
style: TextStyle(
|
|
color: Colors.black,
|
|
fontSize: 28.f,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
);
|
|
}
|