diff --git a/unibond/android/app/build.gradle b/unibond/android/app/build.gradle index 8f64fa5..17f4865 100644 --- a/unibond/android/app/build.gradle +++ b/unibond/android/app/build.gradle @@ -8,7 +8,8 @@ if (localPropertiesFile.exists()) { def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") + // throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") + throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") } def flutterVersionCode = localProperties.getProperty('flutter.versionCode') @@ -48,6 +49,7 @@ android { applicationId "com.example.unibond" // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. + // minSdkVersion flutter.minSdkVersion // changed bc of fluttertoast; requires a higher Android SDK version. minSdkVersion 21 targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() diff --git a/unibond/lib/main.dart b/unibond/lib/main.dart index 03b0770..88e5c59 100644 --- a/unibond/lib/main.dart +++ b/unibond/lib/main.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:unibond/view/screens/user/root_tab.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:unibond/view/screens/letter/letter_box_screen.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); diff --git a/unibond/lib/view/screens/letter/letter_box_screen.dart b/unibond/lib/view/screens/letter/letter_box_screen.dart index 4daf113..947fe47 100644 --- a/unibond/lib/view/screens/letter/letter_box_screen.dart +++ b/unibond/lib/view/screens/letter/letter_box_screen.dart @@ -1,17 +1,9 @@ import 'package:flutter/material.dart'; - -@override -Widget build(BuildContext context) { - return MaterialApp( - home: LetterBoxScreen( - fakeEnvelopes: [ - LetterEnvelope(date: '2023-10-15', sender: '지지진'), - LetterEnvelope(date: '2023-10-14', sender: '진지지'), - //추가 편지봉투를 여기에 추가 - ], - ), - ); -} +import 'package:get/get.dart'; +import 'package:unibond/view/screens/home_screen.dart'; +import 'package:unibond/view/screens/letter/letter_list_screen.dart'; +import 'package:unibond/view/screens/user/profile_screen.dart'; +import 'package:unibond/view/widgets/navigator.dart'; class LetterEnvelope { final String date; @@ -20,47 +12,150 @@ class LetterEnvelope { LetterEnvelope({required this.date, required this.sender}); } -class LetterBoxScreen extends StatelessWidget { - final List fakeEnvelopes; - +class LetterBoxScreen extends StatefulWidget { const LetterBoxScreen({Key? key, required this.fakeEnvelopes}) : super(key: key); + final List fakeEnvelopes; + + @override + _LetterBoxScreenState createState() => _LetterBoxScreenState(); +} + +class _LetterBoxScreenState extends State { + int currentIndex = 0; + @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: const Text('편지함'), + title: Row( + children: [ + GestureDetector( + onTap: () { + setState(() { + currentIndex = 0; + }); + }, + child: Text( + '편지함', + style: TextStyle( + fontWeight: currentIndex == 0 + ? FontWeight.bold + : FontWeight.normal), + ), + ), + const SizedBox(width: 16), + GestureDetector( + onTap: () { + setState(() { + currentIndex = 1; + }); + }, + child: Text( + '좋아함', + style: TextStyle( + fontWeight: currentIndex == 1 + ? FontWeight.bold + : FontWeight.normal), + ), + ), + ], + ), automaticallyImplyLeading: false, ), body: ListView.builder( - itemCount: fakeEnvelopes.length, + itemCount: widget.fakeEnvelopes.length, itemBuilder: (context, index) { - final envelope = fakeEnvelopes[index]; - return Card( - elevation: 4, // 그림자 효과 추가 - margin: const EdgeInsets.all(8.0), // 여백 추가 - child: Container( - padding: const EdgeInsets.all(16.0), // 내용 여백 추가 - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text(envelope.date, - style: const TextStyle(fontWeight: FontWeight.bold)), - const Icon(Icons.mail_outline), // 편지 아이콘 - ], + final envelope = widget.fakeEnvelopes[index]; + final List> colorSets = [ + [Color(0xFFD08EFF), Color(0xFFFFACC6)], + [Color(0xFFFF88AC), Color(0xFFFFE9CC)], + [Color(0xFF99B9FF), Color(0xFFCA80FF)], + ]; + + final colorSet = colorSets[index % colorSets.length]; + + return GestureDetector( + onTap: () { + // TODO: 각 편지를 구분하는 id 넘기기 + Get.to( + () => LetterList( + backgroundColor1: colorSet[0], + backgroundColor2: colorSet[1], + sender: envelope.sender, + date: envelope.date, + ), + ); + }, + child: Card( + elevation: 4, // 그림자 효과 추가 + margin: const EdgeInsets.all(20.0), // 여백 추가 + child: Container( + height: 180, + width: 160, + padding: const EdgeInsets.all(16.0), // 내용 여백 추가 + decoration: BoxDecoration( + gradient: LinearGradient( + colors: colorSet, + begin: Alignment.topCenter, + end: Alignment.bottomCenter, ), - const SizedBox(height: 8), // 간격 추가 - Text('보낸 사람: ${envelope.sender}'), - ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text(envelope.date, + style: + const TextStyle(fontWeight: FontWeight.bold)), + ], + ), + const SizedBox(height: 8), // 간격 추가 + Text('보낸 사람: ${envelope.sender}'), + ], + ), ), ), ); }, ), + // 리팩터링 필요함 + bottomNavigationBar: MyBottomNavigationBar( + // 현재 선택된 바텀 바 아이콘 인덱스 + currentIndex: 0, + onTap: (index) { + // 바텀 바 아이콘을 누를 때 화면 전환 + if (index == 0) { + // 홈 화면으로 이동 + Navigator.pushReplacement( + context, + MaterialPageRoute(builder: (context) => const HomeScreen()), + ); + } else if (index == 1) { + //편지함 화면으로 이동 + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (context) => LetterBoxScreen( + fakeEnvelopes: [ + LetterEnvelope(date: '2023-10-15', sender: '지지진'), + LetterEnvelope(date: '2023-10-14', sender: '진지지'), + LetterEnvelope(date: '2023-10-14', sender: '지진지'), + ], + )), + ); + } else if (index == 2) { + // 프로필 화면으로 이동 + Navigator.pushReplacement( + context, + MaterialPageRoute(builder: (context) => const ProfileScreen()), + ); + } + }, + ), ); } } diff --git a/unibond/lib/view/screens/letter/letter_list_screen.dart b/unibond/lib/view/screens/letter/letter_list_screen.dart new file mode 100644 index 0000000..96ef649 --- /dev/null +++ b/unibond/lib/view/screens/letter/letter_list_screen.dart @@ -0,0 +1,106 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:unibond/domain/letter/letter.dart'; +import 'package:unibond/view/screens/letter/letter_read_screen.dart'; + +class LetterList extends StatelessWidget { + final Color backgroundColor1; + final Color backgroundColor2; + final String sender; + final String date; + + const LetterList({ + required this.backgroundColor1, + required this.backgroundColor2, + required this.sender, + required this.date, + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + centerTitle: true, + title: const Text('편지 내용'), + leading: IconButton( + icon: const Icon(Icons.arrow_back_ios), + onPressed: () { + Get.back(); + }, + ), + ), + body: Center( + child: Stack( + alignment: Alignment.center, + children: List.generate( + 10, + (index) { + double topPosition = index * 50.0; + + Color backgroundColor = + index.isEven ? backgroundColor1 : backgroundColor2; + + return Positioned( + top: topPosition, + child: GestureDetector( + onTap: () { + Get.to(LetterReadScreen( + letter: Letter( + id: 1, + receiverId: 2, + title: "저는 오늘 행복한 하루를 보냈어요.", + content: "마음이 잘 통하는 친구를 만난 것 같거든요.", + isliked: true, + ), + )); + }, + child: Card( + elevation: 4.0, // 카드 그림자 깊이 + child: Container( + padding: const EdgeInsets.all(16.0), + width: 300, + height: 200, + decoration: BoxDecoration( + color: backgroundColor, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "2023-11-27", + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + ), + ), + Center( + child: Text( + "저는 오늘 행복한 하루를 보냈어요", + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + ), + Align( + alignment: Alignment.bottomRight, + child: Text( + "From. $sender", + style: TextStyle(fontSize: 12), + ), + ), + ], + ), + ), + ), + ), + ); + }, + ), + ), + ), + ); + } +} diff --git a/unibond/lib/view/screens/letter/letter_read_screen.dart b/unibond/lib/view/screens/letter/letter_read_screen.dart index c86425c..c3bbbc8 100644 --- a/unibond/lib/view/screens/letter/letter_read_screen.dart +++ b/unibond/lib/view/screens/letter/letter_read_screen.dart @@ -1,5 +1,8 @@ import 'package:flutter/material.dart'; +import 'package:get/get.dart'; import 'package:unibond/domain/letter/letter.dart'; +import 'package:unibond/view/screens/letter/letter_write_screen.dart'; +import 'package:unibond/view/widgets/custon_elevated_button.dart'; class LetterReadScreen extends StatefulWidget { final Letter letter; @@ -15,11 +18,12 @@ class _LetterReadScreenState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: const Text("받은 편지"), + centerTitle: true, + title: const Text('받은 편지'), leading: IconButton( - icon: const Icon(Icons.arrow_back), + icon: const Icon(Icons.arrow_back_ios), onPressed: () { - Navigator.pop(context); + Get.back(); }, ), actions: [ @@ -41,6 +45,7 @@ class _LetterReadScreenState extends State { child: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Text( widget.letter.title, @@ -56,6 +61,11 @@ class _LetterReadScreenState extends State { fontSize: 18, ), ), + CustomElevatedButton( + text: "답장 쓰기", + screenRoute: () { + Get.to(() => const LetterWriteScreen()); + }) ], ), ), diff --git a/unibond/lib/view/screens/letter/letter_write_screen.dart b/unibond/lib/view/screens/letter/letter_write_screen.dart index 3136c89..c825d4b 100644 --- a/unibond/lib/view/screens/letter/letter_write_screen.dart +++ b/unibond/lib/view/screens/letter/letter_write_screen.dart @@ -1,4 +1,6 @@ import 'package:flutter/material.dart'; +import 'package:fluttertoast/fluttertoast.dart'; +import 'package:get/get.dart'; class LetterWriteScreen extends StatefulWidget { const LetterWriteScreen({super.key}); @@ -22,11 +24,12 @@ class _LetterWriteScreenState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: const Text("편지 작성"), + centerTitle: true, + title: const Text('작성중인 편지'), leading: IconButton( - icon: const Icon(Icons.arrow_back), + icon: const Icon(Icons.arrow_back_ios), onPressed: () { - Navigator.pop(context); + Get.back(); }, ), actions: [ @@ -34,6 +37,8 @@ class _LetterWriteScreenState extends State { icon: const Icon(Icons.send), onPressed: () { // 편지 전송하는 코드 추가 + showToastMessage(); + Get.back(); // 이전 화면 이동 }, ) ], @@ -67,3 +72,15 @@ class _LetterWriteScreenState extends State { ); } } + +void showToastMessage() { + Fluttertoast.showToast( + msg: "전송이 완료되었습니다", + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.BOTTOM, + timeInSecForIosWeb: 2, + backgroundColor: Colors.grey, + textColor: Colors.white, + fontSize: 16.0, + ); +} diff --git a/unibond/pubspec.lock b/unibond/pubspec.lock index 5a7ef1e..ccb6254 100644 --- a/unibond/pubspec.lock +++ b/unibond/pubspec.lock @@ -397,6 +397,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.2.0" + fluttertoast: + dependency: "direct main" + description: + name: fluttertoast + sha256: dfdde255317af381bfc1c486ed968d5a43a2ded9c931e87cbecd88767d6a71c1 + url: "https://pub.dev" + source: hosted + version: "8.2.4" get: dependency: "direct main" description: @@ -549,6 +557,31 @@ packages: url: "https://pub.dev" source: hosted version: "6.7.1" + version: "0.18.1" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: e45c31f458d01fd9ef4a214feb2e153b72d5b1907435f4332b1637a2f348c021 + url: "https://pub.dev" + source: hosted + version: "9.0.18" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "54808cfcfa87dbc0d74c61ac063d624adf1bd5c0407301f32b06c783c60dc4ca" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "7e71be3c161472f6c9158ac8875dd8de575060d60b5d159ebca3600ea32c9116" + url: "https://pub.dev" + source: hosted + version: "1.0.6" lints: dependency: transitive description: @@ -569,47 +602,31 @@ packages: dependency: transitive description: name: matcher - sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.15" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.8.0" meta: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 url: "https://pub.dev" source: hosted - version: "1.9.1" - mime: - dependency: transitive - description: - name: mime - sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e - url: "https://pub.dev" - source: hosted - version: "1.0.4" - package_config: - dependency: transitive - description: - name: package_config - sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" - url: "https://pub.dev" - source: hosted - version: "2.1.0" + version: "1.11.0" path: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted version: "1.8.3" @@ -820,7 +837,7 @@ packages: sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" url: "https://pub.dev" source: hosted - version: "1.0.4" + version: "1.9.0" sky_engine: dependency: transitive description: flutter @@ -1021,3 +1038,14 @@ packages: sdks: dart: ">=3.0.6 <4.0.0" flutter: ">=3.10.0" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + url: "https://pub.dev" + source: hosted + version: "13.0.0" +sdks: + dart: ">=3.2.0-0 <4.0.0" + flutter: ">=1.10.0" diff --git a/unibond/pubspec.yaml b/unibond/pubspec.yaml index fe8663a..eb32d52 100644 --- a/unibond/pubspec.yaml +++ b/unibond/pubspec.yaml @@ -45,6 +45,8 @@ dependencies: permission_handler: ^10.4.3 flutter_local_notifications: ^15.1.0+1 flutter_localization: ^0.1.13 + intl: ^0.18.1 + fluttertoast: ^8.2.4 dev_dependencies: flutter_test: