Skip to content

Commit

Permalink
[#346] refactor: UploadPhotoCell 컴포넌트 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
sm-amoled committed Dec 23, 2024
1 parent 6b38d1d commit 223b0f7
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ class UploadPhotoBottomToolbar extends StatelessWidget {
Widget build(BuildContext context) {
return Row(
children: [
const SizedBox(width: 8),
WhIconButton(
onPressed: type == UploadPhotoBottomToolbarType.upload ? onIconPressed : () {},
iconString: iconString,
size: WHIconsize.medium,
color: type == UploadPhotoBottomToolbarType.upload ? CustomColors.whGrey900 : CustomColors.whGrey600,
),
const SizedBox(width: 8),
const SizedBox(width: 16),
Expanded(
child: Text(
type == UploadPhotoBottomToolbarType.upload ? '인증샷은 최대 3장까지 공유할 수 있어요' : '반성글에서는 인증샷을 공유할 수 없어요',
Expand Down
80 changes: 80 additions & 0 deletions lib/presentation/common_components/upload_photo_cell.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:wehavit/common/common.dart';
import 'package:wehavit/presentation/presentation.dart';

enum UploadPhotoCellState {
uploading,
failed,
success;
}

class UploadPhotoCell extends StatelessWidget {
const UploadPhotoCell({
super.key,
required this.imageFile,
required this.state,
required this.onCancel,
required this.onRetry,
});

final File imageFile;
final UploadPhotoCellState state;
final VoidCallback onCancel;
final VoidCallback onRetry;

@override
Widget build(BuildContext context) {
final indicator = switch (state) {
UploadPhotoCellState.uploading => Container(
width: 90,
height: 90,
color: CustomColors.whGrey100.withOpacity(0.4),
alignment: Alignment.center,
child: const SizedBox(
width: 40,
height: 40,
child: CircularProgressIndicator(
color: CustomColors.whYellow500,
),
),
),
UploadPhotoCellState.failed => Container(
width: 90,
height: 90,
color: CustomColors.whGrey100.withOpacity(0.6),
alignment: Alignment.center,
child: WhIconButton(
size: WHIconsize.large,
iconString: WHIcons.retry,
color: CustomColors.whRed500,
onPressed: onRetry,
),
),
UploadPhotoCellState.success => Container(),
};

final cancelButton = WhIconButton(
iconString: WHIcons.xMarkCircle,
size: WHIconsize.small,
onPressed: onCancel,
);

return Stack(
alignment: Alignment.topRight,
children: [
SizedBox(
width: 90,
height: 90,
child: Image.file(
imageFile,
fit: BoxFit.cover,
),
),
indicator,
cancelButton,
],
);
}
}

0 comments on commit 223b0f7

Please sign in to comment.