Houshan-Basa/lib/ui/screens/gmedia/send_image_modal.dart

175 lines
6.6 KiB
Dart

// ignore_for_file: use_build_context_synchronously
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hoshan/core/gen/assets.gen.dart';
import 'package:hoshan/core/services/file_manager/pick_file_services.dart';
import 'package:hoshan/ui/theme/colors.dart';
import 'package:hoshan/ui/theme/cubit/theme_mode_cubit.dart';
import 'package:hoshan/ui/theme/text.dart';
import 'package:hoshan/ui/widgets/components/button/loading_button.dart';
import 'package:file_picker/file_picker.dart';
import 'package:hoshan/ui/widgets/components/snackbar/snackbar_manager.dart';
class SendImageModal extends ModalRoute<void> {
final Function(PlatformFile image) onFileSelected;
SendImageModal({required this.onFileSelected});
@override
Duration get transitionDuration => const Duration(milliseconds: 500);
@override
bool get opaque => false;
@override
bool get barrierDismissible => true;
@override
Color get barrierColor => Colors.black.withAlpha(210);
@override
String get barrierLabel => 'Images';
@override
bool get maintainState => true;
@override
Widget buildTransitions(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation, Widget child) {
// You can add your own animations for the overlay content
return FadeTransition(
opacity: animation,
child: ScaleTransition(
scale: animation,
child: child,
),
);
}
@override
Widget buildPage(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation) {
return Material(
type: MaterialType.transparency,
child: SafeArea(
child: Directionality(
textDirection: TextDirection.rtl,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ListTile(
title: Text(
'انتخاب تصویر',
style: AppTextStyles.headline6
.copyWith(color: Theme.of(context).colorScheme.onSurface),
),
),
Container(
width: double.infinity,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(16),
border: Border.all(
color: Theme.of(context).colorScheme.onSurface)),
margin: const EdgeInsets.all(16),
padding: const EdgeInsets.all(16),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.photo_library_rounded,
size: 78,
color: Theme.of(context).colorScheme.primary,
),
const SizedBox(
height: 8,
),
LoadingButton(
backgroundColor: Theme.of(context).colorScheme.primary,
onPressed: () async {
FilePickerResult? result =
await FilePicker.platform.pickFiles(
type: FileType.image,
);
if (result != null && result.files.isNotEmpty) {
final check = await PickFileService.isImageValid(
result.xFiles.first);
if (check) {
onFileSelected(result.files.first);
Navigator.of(context).pop();
} else {
Navigator.of(context).pop();
SnackBarManager(context).show(
message:
'سایز یا اندازه فایل مورد نظر بیش از اندازه است',
status: SnackBarStatus.error);
}
}
},
child: Text(
'انتخاب تصویر',
style:
AppTextStyles.body4.copyWith(color: Colors.white),
),
),
],
),
),
Text(
'فقط فرمت‌های jpg ،png ،jpeg',
style: AppTextStyles.body5.copyWith(
color: AppColors.gray[
context.read<ThemeModeCubit>().isDark() ? 900 : 400]),
),
const SizedBox(
height: 16,
),
ListTile(
leading: Column(
children: [
const SizedBox(
height: 2,
),
Assets.icon.outline.infoCircle.svg(
color: Theme.of(context).colorScheme.onSurface,
width: 22,
height: 22),
],
),
title: Text(
'فرمت‌های قابل قبول و غیر قابل قبول برای هوش مصنوعی',
style: AppTextStyles.body4
.copyWith(color: Theme.of(context).colorScheme.onSurface),
),
),
Padding(
padding: const EdgeInsets.all(16.0),
child: Assets.image.expectedFormat
.image(width: MediaQuery.sizeOf(context).width),
)
// Wrap(
// children: List.generate(
// 5,
// (index) => const Padding(
// padding: EdgeInsets.all(8.0),
// child: ImageNetwork(
// url:
// 'https://s3-alpha-sig.figma.com/img/3e4e/9825/3c786b8ce2f4b99d58a6e235c97e9705?Expires=1742774400&Key-Pair-Id=APKAQ4GOSFWCW27IBOMQ&Signature=isPXc0erkoZOon3ILDBuJwB7v57nAQg7ezzF0UZ~ga9KVpXa5SLAe5o0k29qH5c93tGYncveGfrf0UF2AIszVAee1MLNZu~ToFiB2tYZ9se8yKxba9XT1Qa-4f~KTLuJ5yOPgZFzQeUQOzzd00VZlu5~J5ZxxhHkrbd3-Wz8dzp7fYV-zorwsInlRphP6cU-4C7WleRz8-YULFEgrU5xYSSqZMH8WaAgcL-Ws32Gcts4LP0sJZo5sx3JgPSmhAH9alt7GByu5U7q3CtGAiFux70LkNg-BRQdwsj1zyQEewxqjI~ZXyBRRLxOxnkzmu3uOd~u6~A1KTb9CoEArluQEA__',
// width: 61,
// height: 61,
// radius: 16,
// ),
// ),
// ),
// )
],
),
),
),
);
}
}