generated from jwson-automation/blueberry_template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
453 additions
and
477 deletions.
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,53 @@ | ||
import 'package:blueberry_flutter_template/feature/camera/widget/CameraButtonWidget.dart'; | ||
import 'package:blueberry_flutter_template/feature/camera/widget/CameraPreviewWidget.dart'; | ||
import 'package:blueberry_flutter_template/feature/camera/service/CameraService.dart'; | ||
import 'package:blueberry_flutter_template/utils/AppStrings.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class CameraScreen extends StatefulWidget { | ||
static const String name = 'CameraScreen'; | ||
const CameraScreen({super.key}); | ||
|
||
@override | ||
State<CameraScreen> createState() => _ProfileCameraPageState(); | ||
} | ||
|
||
class _ProfileCameraPageState extends State<CameraScreen> { | ||
final CameraService cameraService = CameraService(); | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
cameraService.initializeCameras(); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
cameraService.dispose(); | ||
super.dispose(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final size = MediaQuery.of(context).size; | ||
|
||
return Scaffold( | ||
appBar: AppBar( | ||
title: const Text(AppStrings.takeProfilePhoto), | ||
), | ||
body: Column( | ||
children: [ | ||
CameraPreviewWidget( | ||
cameraService: cameraService, | ||
size: size, | ||
), | ||
Expanded( | ||
child: CameraButtonWidget( | ||
onTap: () => cameraService.attemptTakePhoto(context), | ||
), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,60 @@ | ||
import 'dart:io'; | ||
import 'package:blueberry_flutter_template/feature/camera/provider/fireStorageServiceProvider.dart'; | ||
import 'package:blueberry_flutter_template/feature/camera/widget/CircularProfileImagePreviewWidget.dart'; | ||
import 'package:blueberry_flutter_template/feature/mypage/MyPageScreen.dart'; | ||
import 'package:blueberry_flutter_template/utils/AppStrings.dart'; | ||
import 'package:blueberry_flutter_template/utils/Talker.dart'; | ||
import 'package:firebase_auth/firebase_auth.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:go_router/go_router.dart'; | ||
import '../../services/FirebaseStoreServiceProvider.dart'; | ||
|
||
class ProfilePreviewScreen extends ConsumerWidget { | ||
final File imageFile; | ||
|
||
const ProfilePreviewScreen(this.imageFile, {super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final storage = ref.read(fireStorageServiceProvider); | ||
final fireStorage = ref.read(firebaseStoreServiceProvider); | ||
final userId = FirebaseAuth.instance.currentUser!.uid; | ||
|
||
return Scaffold( | ||
appBar: AppBar( | ||
title: const Text(AppStrings.previewProfilePhoto), | ||
), | ||
body: Center( | ||
child: Column( | ||
children: [ | ||
CircularProfileImagePreviewWidget(imageFile: imageFile), | ||
makeProfileImageBtn(storage, userId, fireStorage, context), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
|
||
TextButton makeProfileImageBtn(FirebaseStorageService storage, String userId, | ||
FirestoreService fireStorage, BuildContext context) { | ||
return TextButton( | ||
onPressed: () async { | ||
try { | ||
final imageUrl = await storage.uploadImageFromApp( | ||
imageFile, ImageType.profileimage, | ||
fixedFileName: userId); | ||
|
||
// 프로필 이미지 생성 | ||
fireStorage.createProfileIamge(userId, imageUrl); | ||
|
||
// 페이지 이동 | ||
context.goNamed(MyPageScreen.name); | ||
} catch (e) { | ||
talker.error('이미지 저장에 실패했습니다. 다시 시도해주세요.'); | ||
} | ||
}, | ||
child: const Text(AppStrings.savePhoto), | ||
); | ||
} | ||
} |
Oops, something went wrong.