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.
HMG_Patient_App_New/lib/widgets/attachment_options.dart

106 lines
3.5 KiB
Dart

import 'package:easy_localization/easy_localization.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
import 'package:hmg_patient_app_new/core/dependencies.dart';
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:flutter/material.dart';
class AttachmentOptions extends StatelessWidget {
final Future<void> Function() onCameraTap;
final Future<void> Function() onGalleryTap;
final VoidCallback onFilesTap;
final bool showFilesOption;
const AttachmentOptions({
Key? key,
required this.onCameraTap,
required this.onGalleryTap,
required this.onFilesTap,
this.showFilesOption = true
}) : super(key: key);
@override
Widget build(BuildContext context) {
final appState = getIt.get<AppState>();
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
checkInOptionCard(
appState,
AppAssets.open_camera,
LocaleKeys.openCamera.tr(context: context),
LocaleKeys.takePhotoWithCamera.tr(context: context),
).onPress(() async {
await onCameraTap();
}),
SizedBox(height: 16.h),
checkInOptionCard(
appState,
AppAssets.gallery,
LocaleKeys.openGallery.tr(context: context),
LocaleKeys.selectFromPhotoLibrary.tr(context: context),
).onPress(() async {
await onGalleryTap();
}),
if (showFilesOption) SizedBox(height: 16.h),
if (showFilesOption)
checkInOptionCard(
appState,
AppAssets.files,
LocaleKeys.openFiles.tr(context: context),
LocaleKeys.selectDocumentFiles.tr(context: context),
).onPress(() async {
onFilesTap();
}),
],
);
}
Widget checkInOptionCard(AppState appState, String icon, String title, String subTitle) {
return Container(
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
color: AppColors.whiteColor,
borderRadius: 20.h,
hasShadow: false,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Utils.buildSvgWithAssets(icon: icon, width: 40.h, height: 40.h, fit: BoxFit.fill),
SizedBox(height: 16.h),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
title.toText16(isBold: true, color: AppColors.textColor),
subTitle.toText12(isBold: true, color: AppColors.greyTextColor),
],
),
),
Transform.flip(
flipX: appState.isArabic(),
child: Utils.buildSvgWithAssets(
icon: AppAssets.forward_arrow_icon_small,
iconColor: AppColors.blackColor,
width: 18.h,
height: 13.h,
fit: BoxFit.contain,
),
),
],
),
],
).paddingAll(16.h),
);
}
}