Skip to content
Merged

Dev #449

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if (flutterVersionName == null) {

android {
namespace "com.peeroreum.peeroreum_client"
compileSdkVersion flutter.compileSdkVersion
compileSdk 36
ndkVersion "27.0.12077973"

compileOptions {
Expand Down
8 changes: 8 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.peeroreum.peeroreum_client" >
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
Expand Down Expand Up @@ -102,6 +106,10 @@
<data android:scheme="kakaoa17f729816582e161afaae9395c1f1b5" android:host="kakaolink" />
</intent-filter>
</activity>
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
Expand Down
10 changes: 9 additions & 1 deletion lib/screens/detail_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,28 @@ class _ImageDetailState extends State<ImageDetail> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: PeeroreumColor.black,
body: Stack(
alignment: Alignment.topCenter,
children: [
CarouselSlider(
items: imageList.map((i) {
var imageUrl = i.toString();
return Container(
color: PeeroreumColor.black,
child: PhotoView(
backgroundDecoration: BoxDecoration(
color: PeeroreumColor.black
color: PeeroreumColor.black,
),
minScale: PhotoViewComputedScale.contained,
filterQuality: FilterQuality.high,
imageProvider: NetworkImage(imageUrl),
loadingBuilder: (context, event) => Center(
child: CircularProgressIndicator(
color: PeeroreumColor.white,
strokeWidth: 2,
),
),
)
);
// 여기에 이미지 위젯 생성 코드 추가
Expand Down
26 changes: 14 additions & 12 deletions lib/screens/iedu/iedu_create.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:flutter_svg/svg.dart';
import 'package:peeroreum_client/api/ApiClient.dart';
import 'package:peeroreum_client/designs/PeeroreumToast.dart';
import 'package:image_picker/image_picker.dart';
import 'package:peeroreum_client/widgets/custom_image_picker.dart';
import 'package:peeroreum_client/data/Subject.dart';
import 'package:peeroreum_client/designs/PeeroreumColor.dart';
import 'package:peeroreum_client/designs/PeeroreumTypo.dart';
Expand Down Expand Up @@ -40,7 +41,6 @@ class _CreateIeduState extends State<CreateIedu> {
int detailSubject = 0;
late Future initFuture;

final ImagePicker picker = ImagePicker();
final List<XFile> _images = [];

FocusNode ContentFocusNode = FocusNode();
Expand Down Expand Up @@ -821,17 +821,19 @@ class _CreateIeduState extends State<CreateIedu> {
}

void takeFromGallery() async {
final List<XFile> selectedImages = await picker.pickMultiImage();

if (selectedImages.isNotEmpty) {
setState(() {
if (selectedImages.length + _images.length < 6) {
_images.addAll(selectedImages);
} else {
PeeroreumToast.show(context, '사진 첨부는 5장까지 가능해요.');
}
});
}
final selected = await showCustomImagePicker(
context,
multiple: true,
maxCount: 5 - _images.length,
);
if (selected == null || selected.isEmpty) return;
setState(() {
if (selected.length + _images.length <= 5) {
_images.addAll(selected);
} else {
PeeroreumToast.show(context, '사진 첨부는 5장까지 가능해요.');
}
});
}

Future<void> postIedu() async {
Expand Down
112 changes: 5 additions & 107 deletions lib/screens/iedu/iedu_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:peeroreum_client/designs/PeeroreumTypo.dart';
import 'package:peeroreum_client/screens/detail_image.dart';
import 'package:dio/dio.dart' as dio;
import 'package:image_picker/image_picker.dart';
import 'package:peeroreum_client/widgets/custom_image_picker.dart';
import 'package:peeroreum_client/api/ApiClient.dart';
import 'package:peeroreum_client/screens/iedu/iedu_whiteboard.dart';
import 'package:peeroreum_client/screens/mypage/mypage_profile.dart';
Expand Down Expand Up @@ -63,7 +64,6 @@ class _DetailIeduState extends State<DetailIedu> {
String comment = "";
bool isSubmittable = false;

final ImagePicker picker = ImagePicker();
XFile? _image;
//----------------
List<dynamic> commentData = [];
Expand Down Expand Up @@ -915,118 +915,16 @@ class _DetailIeduState extends State<DetailIedu> {
);
}

void takeFromCamera() async {
final XFile? image = await picker.pickImage(source: ImageSource.camera);
if (image != null) {
void showImagePickerSheet() async {
final selected = await showCustomImagePicker(context, multiple: false);
if (selected != null && selected.isNotEmpty) {
setState(() {
_image = image;
_image = selected.first;
isSubmittable = true;
});
} else {
// 이미지 선택이 취소되었을 때
print('Image selection cancelled');
}
}

void takeFromGallery() async {
final XFile? image = await picker.pickImage(source: ImageSource.gallery);

if (image != null) {
setState(() {
print("리스트에 이미지 저장");
_image = image;
isSubmittable = true;
});
}
}

void showImagePickerSheet() {
showModalBottomSheet(
backgroundColor: Colors.transparent,
context: context,
builder: (context) {
return Container(
decoration: const BoxDecoration(
color: PeeroreumColor.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16.0),
topRight: Radius.circular(16.0),
),
),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
padding: const EdgeInsets.all(20),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: TextButton(
onPressed: () {
takeFromCamera();
Get.back();
},
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
PeeroreumColor.primaryPuple[400]),
padding: MaterialStateProperty.all(
EdgeInsets.all(12)),
shape: MaterialStateProperty.all<
RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
))),
child: const Text(
'카메라',
style: TextStyle(
fontFamily: 'Pretendard',
fontSize: 16,
fontWeight: FontWeight.w600,
color: PeeroreumColor.white,
),
),
),
),
const SizedBox(width: 8),
Expanded(
child: TextButton(
onPressed: () {
takeFromGallery();
Get.back();
},
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
PeeroreumColor.primaryPuple[400]),
padding: MaterialStateProperty.all(
const EdgeInsets.all(12)),
shape: MaterialStateProperty.all<
RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
))),
child: const Text(
'갤러리',
style: TextStyle(
fontFamily: 'Pretendard',
fontSize: 16,
fontWeight: FontWeight.w600,
color: PeeroreumColor.white,
),
),
),
),
],
),
),
],
),
);
});
}

deleteQuestionBottomSheet(writerName) {
var isMyQuestion = writerName == nickname;
return Container(
Expand Down
92 changes: 73 additions & 19 deletions lib/screens/mypage/mypage_profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:flutter_svg/svg.dart';
import 'package:peeroreum_client/designs/PeeroreumToast.dart';
import 'package:get/get.dart';
import 'package:image_picker/image_picker.dart';
import 'package:peeroreum_client/widgets/custom_image_picker.dart';
import 'package:kakao_flutter_sdk/kakao_flutter_sdk_share.dart';
import 'package:share_plus/share_plus.dart';
import 'package:peeroreum_client/api/ApiClient.dart';
Expand Down Expand Up @@ -132,6 +133,31 @@ class _MyPageProfileState extends State<MyPageProfile> {
}
}

deleteProfileImageAPI() async {
try {
var result = await ApiClient().put('/member/delete/profileImage');
if (result.statusCode == 200) {
setState(() { profileImage = null; });
await storage.delete(key: 'profileImage');
PeeroreumToast.show(context, "프로필 이미지가 삭제되었어요.");
}
} catch (e) {
print('Unexpected error: $e');
}
}

deleteBackgroundImageAPI() async {
try {
var result = await ApiClient().put('/member/delete/backgroundImage');
if (result.statusCode == 200) {
setState(() { backgroundImage = null; });
PeeroreumToast.show(context, "배경 이미지가 삭제되었어요.");
}
} catch (e) {
print('Unexpected error: $e');
}
}

backgroundImageAPI(var _image1) async {
var image1 = await dio.MultipartFile.fromFile(_image1!.path);
var imageMap1 = <String, dynamic>{'profileImage': image1};
Expand Down Expand Up @@ -420,6 +446,24 @@ class _MyPageProfileState extends State<MyPageProfile> {
),
),
),
if (profileImage != null)
InkWell(
splashColor: Colors.transparent,
highlightColor: PeeroreumColor.gray[100],
onTap: () async {
Get.back();
await deleteProfileImageAPI();
},
child: SizedBox(
height: 56,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
B3_18px_R(text: '프로필 삭제', color: PeeroreumColor.error),
],
),
),
),
InkWell(
splashColor: Colors.transparent,
highlightColor: PeeroreumColor.gray[100],
Expand All @@ -442,20 +486,12 @@ class _MyPageProfileState extends State<MyPageProfile> {
splashColor: Colors.transparent,
highlightColor: PeeroreumColor.gray[100],
onTap: () async {
XFile? image1;
final ImagePicker picker1 = ImagePicker();
final XFile? pickedFile1 =
await picker1.pickImage(source: ImageSource.gallery);
if (pickedFile1 != null) {
setState(() {
image1 = XFile(pickedFile1.path);
if (image1 != null) {
setState(() {
backgroundImageAPI(image1);
Get.back();
});
}
});
final selected = await showCustomImagePicker(context, multiple: false);
if (selected == null || selected.isEmpty) return;
final cropped = await cropImage(context, selected.first);
if (cropped != null) {
backgroundImageAPI(cropped);
Get.back();
}
},
child: const SizedBox(
Expand All @@ -468,6 +504,24 @@ class _MyPageProfileState extends State<MyPageProfile> {
),
),
),
if (backgroundImage != null)
InkWell(
splashColor: Colors.transparent,
highlightColor: PeeroreumColor.gray[100],
onTap: () async {
Get.back();
await deleteBackgroundImageAPI();
},
child: SizedBox(
height: 56,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
B3_18px_R(text: '배경 삭제', color: PeeroreumColor.error),
],
),
),
),
],
),
),
Expand Down Expand Up @@ -509,12 +563,12 @@ class _MyPageProfileState extends State<MyPageProfile> {
),
GestureDetector(
onTap: () async {
final ImagePicker picker = ImagePicker();
final XFile? pickedFile =
await picker.pickImage(source: ImageSource.gallery);
if (pickedFile != null) {
final selected = await showCustomImagePicker(context, multiple: false);
if (selected == null || selected.isEmpty) return;
final cropped = await cropImage(context, selected.first);
if (cropped != null) {
setState(() {
image = XFile(pickedFile.path);
image = cropped;
});
}
},
Expand Down
Loading
Loading