Skip to content

Commit

Permalink
프리뷰 기능 별도 위젯으로 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
JerraldKim committed Sep 1, 2024
1 parent 75991e1 commit a1a4f85
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 43 deletions.
62 changes: 62 additions & 0 deletions lib/feature/ImageConfirmationDialog.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'ImageImporter.dart';

class ImageConfirmationDialog extends StatelessWidget {
final File imageFile;
final WidgetRef ref;

const ImageConfirmationDialog({
Key? key,
required this.imageFile,
required this.ref,
}) : super(key: key);

@override
Widget build(BuildContext context) {
return Dialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.file(
imageFile,
fit: BoxFit.cover,
),
Padding(
padding: const EdgeInsets.all(16.0),
child: Text(
'이 사진을 사용하시겠습니까?',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ElevatedButton(
onPressed: () {
Navigator.of(context).pop();
ref.read(imageFileProvider.notifier).clearImage();
},
child: Text('다시 선택'),
),
ElevatedButton(
onPressed: () {
Navigator.of(context).pop();
ref.read(imageFileProvider.notifier).state = imageFile;
},
child: Text('사용'),
),
],
),
],
),
);
}
}
45 changes: 2 additions & 43 deletions lib/feature/ProfilePicVerificationScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'ImageImporter.dart';
import 'ImageConfirmationDialog.dart'; // Import the new widget

class ProfilePicVerificationScreen extends ConsumerWidget {
const ProfilePicVerificationScreen({super.key});
Expand Down Expand Up @@ -157,49 +158,7 @@ class ProfilePicVerificationScreen extends ConsumerWidget {
showDialog(
context: context,
builder: (BuildContext context) {
return Dialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.file(
imageFile,
fit: BoxFit.cover,
),
Padding(
padding: const EdgeInsets.all(16.0),
child: Text(
'이 사진을 사용하시겠습니까?',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ElevatedButton(
onPressed: () {
Navigator.of(context).pop();
ref.read(imageFileProvider.notifier).clearImage();
},
child: Text('다시 선택'),
),
ElevatedButton(
onPressed: () {
Navigator.of(context).pop();
ref.read(imageFileProvider.notifier).state = imageFile;
},
child: Text('사용'),
),
],
),
],
),
);
return ImageConfirmationDialog(imageFile: imageFile, ref: ref); // Use the new widget
},
);
}
Expand Down

0 comments on commit a1a4f85

Please sign in to comment.