-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feature/#12 send letter
- Loading branch information
Showing
15 changed files
with
265 additions
and
51 deletions.
There are no files selected for viewing
Binary file not shown.
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,17 @@ | ||
class LetterReqDto { | ||
String receiverId; | ||
String content; | ||
String title; | ||
|
||
LetterReqDto({ | ||
required this.receiverId, | ||
required this.title, | ||
required this.content, | ||
}); | ||
|
||
Map<String, dynamic> toJson() => { | ||
'receiverId': receiverId, | ||
'title': title, | ||
'content': content, | ||
}; | ||
} |
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,24 @@ | ||
import 'package:get/get.dart'; | ||
import 'package:unibond/controller/dto/letter_req_dto.dart'; | ||
import 'package:unibond/domain/letter/letter.dart'; | ||
import 'package:unibond/domain/letter/letter_provider.dart'; | ||
import 'package:unibond/domain/letter/letter_repository.dart'; | ||
|
||
class LetterController extends GetxController { | ||
final LetterRepository _letterRepository = LetterRepository(); | ||
|
||
Future<bool> sendLetter( | ||
String receiverId, | ||
String title, | ||
String content, | ||
) async { | ||
try { | ||
bool isSuccess = | ||
await _letterRepository.sendLetter(receiverId, title, content); | ||
return isSuccess; | ||
} catch (error) { | ||
print('sendLetter error: $error'); | ||
rethrow; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1 +1,13 @@ | ||
import 'package:get/get.dart'; | ||
import 'package:unibond/controller/dto/letter_req_dto.dart'; | ||
import 'package:unibond/domain/letter/letter_provider.dart'; | ||
import 'package:unibond/util/userIdNum.dart'; | ||
|
||
const host = "http://3.35.110.214"; | ||
|
||
class LetterProvider extends GetConnect { | ||
Future<Response> sendLetter(Map data) => post( | ||
'$host/api/v1/letters', | ||
headers: {"Authorization": "26"}, // 실제 userIdNum을 넣어야함 | ||
data); | ||
} |
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,30 @@ | ||
import 'package:get/get.dart'; | ||
import 'package:unibond/controller/dto/letter_req_dto.dart'; | ||
import 'package:unibond/domain/letter/letter_provider.dart'; | ||
|
||
const host = "http://3.35.110.214"; | ||
|
||
class LetterRepository { | ||
final LetterProvider _letterProvider = LetterProvider(); | ||
|
||
Future<bool> sendLetter( | ||
String receiverId, String title, String content) async { | ||
try { | ||
final LetterReqDto letterReqDto = LetterReqDto( | ||
receiverId: receiverId, | ||
title: title, | ||
content: content, | ||
); | ||
|
||
print(letterReqDto.toJson()); | ||
Response response = | ||
await _letterProvider.sendLetter(letterReqDto.toJson()); | ||
|
||
bool isSuccess = response.body["isSuccess"]; | ||
return isSuccess; | ||
} catch (error) { | ||
print("Failed: $error"); | ||
rethrow; | ||
} | ||
} | ||
} |
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
Empty file.
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,43 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class CustomLetterArea extends StatelessWidget { | ||
final String hint; | ||
final TextEditingController controller; | ||
final funvalidator; | ||
final String? value; | ||
|
||
const CustomLetterArea({ | ||
super.key, | ||
required this.hint, | ||
required this.controller, | ||
required this.funvalidator, | ||
this.value, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Padding( | ||
padding: const EdgeInsets.symmetric(vertical: 5.0), | ||
child: TextFormField( | ||
controller: controller, | ||
maxLines: null, | ||
expands: true, | ||
decoration: InputDecoration( | ||
hintText: "$hint을(를) 입력하세요", | ||
enabledBorder: OutlineInputBorder( | ||
borderRadius: BorderRadius.circular(20), | ||
), | ||
focusedBorder: OutlineInputBorder( | ||
borderRadius: BorderRadius.circular(20), | ||
), | ||
errorBorder: OutlineInputBorder( | ||
borderRadius: BorderRadius.circular(20), | ||
), | ||
focusedErrorBorder: OutlineInputBorder( | ||
borderRadius: BorderRadius.circular(20), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
unibond/lib/view/widgets/custom_letter_elevated_button.dart
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,30 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class CustomLetterElevatedButton extends StatelessWidget { | ||
final String text; | ||
final Future<void> Function() funPageRoute; | ||
|
||
const CustomLetterElevatedButton({ | ||
Key? key, | ||
required this.text, | ||
required this.funPageRoute, | ||
}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ElevatedButton( | ||
style: ElevatedButton.styleFrom( | ||
minimumSize: const Size(double.infinity, 50), | ||
shape: RoundedRectangleBorder( | ||
borderRadius: BorderRadius.circular(20), | ||
), | ||
backgroundColor: Colors.blue, | ||
foregroundColor: Colors.white, | ||
), | ||
onPressed: () async { | ||
await funPageRoute(); | ||
}, | ||
child: Text("$text"), | ||
); | ||
} | ||
} |
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,44 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class CustomLetterFormField extends StatelessWidget { | ||
final String hint; | ||
final TextEditingController controller; | ||
final funvalidator; | ||
final String? value; | ||
|
||
const CustomLetterFormField({ | ||
super.key, | ||
required this.hint, | ||
required this.controller, | ||
required this.funvalidator, | ||
this.value, | ||
required InputDecoration decoration, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Padding( | ||
padding: const EdgeInsets.symmetric(vertical: 5.0), | ||
child: TextFormField( | ||
validator: funvalidator, | ||
controller: controller, | ||
decoration: InputDecoration( | ||
// ignore: unnecessary_string_interpolations | ||
hintText: hint == "이메일" ? "$hint을 입력하세요" : "$hint를 입력하세요", | ||
enabledBorder: OutlineInputBorder( | ||
borderRadius: BorderRadius.circular(20), | ||
), | ||
focusedBorder: OutlineInputBorder( | ||
borderRadius: BorderRadius.circular(20), | ||
), | ||
errorBorder: OutlineInputBorder( | ||
borderRadius: BorderRadius.circular(20), | ||
), | ||
focusedErrorBorder: OutlineInputBorder( | ||
borderRadius: BorderRadius.circular(20), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
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
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 |
---|---|---|
|
@@ -1048,4 +1048,4 @@ sdks: | |
version: "13.0.0" | ||
sdks: | ||
dart: ">=3.2.0-0 <4.0.0" | ||
flutter: ">=1.10.0" | ||
flutter: ">=1.10.0" |
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