Skip to content

Commit

Permalink
feat: add restriction to adding at leat 4 images
Browse files Browse the repository at this point in the history
  • Loading branch information
boroboro01 committed Oct 16, 2024
1 parent 3210d1b commit 12b08fd
Showing 1 changed file with 29 additions and 19 deletions.
48 changes: 29 additions & 19 deletions lib/screens/selling/photo_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ class _PhotoScreenState extends State<PhotoScreen> {
@override
Widget build(BuildContext context) {
final imageProvider = context.watch<ImageProviderModel>();
bool isButtonEnabled = imageProvider.images.length >= 4;

return Scaffold(
body: SingleChildScrollView(
child: Column(
Expand Down Expand Up @@ -256,22 +258,26 @@ class _PhotoScreenState extends State<PhotoScreen> {
onTap: () async {
await pickImage();
},
child: const PhotoPlaceholder(
image: null,
),
child: const PhotoPlaceholder(image: null),
),
Consumer<ImageProviderModel>(
builder: (context, imageProvider, child) {
return Row(
children: imageProvider.images.map((image) {
return Padding(
padding: const EdgeInsets.symmetric(
horizontal: 5.0),
child: Image.file(
File(image.path),
width: 160.0,
height: 160.0,
fit: BoxFit.cover,
),
);
}).toList(),
);
},
),
...imageProvider.images.map((image) {
return Padding(
padding:
const EdgeInsets.symmetric(horizontal: 5.0),
child: Image.file(
File(image.path),
width: 160.0,
height: 160.0,
fit: BoxFit.cover,
),
);
}),
],
),
),
Expand All @@ -285,12 +291,16 @@ class _PhotoScreenState extends State<PhotoScreen> {
padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: NormalButton(
title: '다음으로',
bgColor: black,
bgColor: isButtonEnabled ? black : gray400,
txtColor: white,
onTap: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => const FlawScreen(),
));
isButtonEnabled
? {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => const FlawScreen(),
))
}
: null;
},
flag: true,
),
Expand Down

0 comments on commit 12b08fd

Please sign in to comment.