-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#346] refactor: UploadPhotoCell 컴포넌트 추가
- Loading branch information
Showing
2 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
], | ||
); | ||
} | ||
} |