diff --git a/unibond/lib/main.dart b/unibond/lib/main.dart index e4fe24d..3f5b165 100644 --- a/unibond/lib/main.dart +++ b/unibond/lib/main.dart @@ -15,13 +15,10 @@ class MyApp extends StatelessWidget { Widget build(BuildContext context) { return GetMaterialApp( title: 'Flutter Demo', - theme: ThemeData( - colorScheme: ColorScheme.fromSeed(seedColor: Colors.blueAccent), - useMaterial3: true, - ), home: LetterBoxScreen(fakeEnvelopes: [ LetterEnvelope(date: '2023-10-15', sender: '지지진'), LetterEnvelope(date: '2023-10-14', sender: '진지지'), + LetterEnvelope(date: '2023-10-14', sender: '지진지'), //추가 편지봉투를 여기에 추가 ]) // home: DetailScreen( diff --git a/unibond/lib/view/screens/letter/letter_box_screen.dart b/unibond/lib/view/screens/letter/letter_box_screen.dart index a8c6b55..947fe47 100644 --- a/unibond/lib/view/screens/letter/letter_box_screen.dart +++ b/unibond/lib/view/screens/letter/letter_box_screen.dart @@ -5,19 +5,6 @@ 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'; -// @override -// Widget build(BuildContext context) { -// return MaterialApp( -// home: LetterBoxScreen( -// fakeEnvelopes: [ -// LetterEnvelope(date: '2023-10-15', sender: '지지진'), -// LetterEnvelope(date: '2023-10-14', sender: '진지지'), -// //추가 편지봉투를 여기에 추가 -// ], -// ), -// ); -// } - class LetterEnvelope { final String date; final String sender; @@ -25,33 +12,96 @@ 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]; + 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(() => const LetterList()); + Get.to( + () => LetterList( + backgroundColor1: colorSet[0], + backgroundColor2: colorSet[1], + sender: envelope.sender, + date: envelope.date, + ), + ); }, child: Card( elevation: 4, // 그림자 효과 추가 - margin: const EdgeInsets.all(8.0), // 여백 추가 + 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, + ), + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -61,7 +111,6 @@ class LetterBoxScreen extends StatelessWidget { Text(envelope.date, style: const TextStyle(fontWeight: FontWeight.bold)), - const Icon(Icons.mail_outline), // 편지 아이콘 ], ), const SizedBox(height: 8), // 간격 추가 @@ -94,6 +143,7 @@ class LetterBoxScreen extends StatelessWidget { fakeEnvelopes: [ LetterEnvelope(date: '2023-10-15', sender: '지지진'), LetterEnvelope(date: '2023-10-14', sender: '진지지'), + LetterEnvelope(date: '2023-10-14', sender: '지진지'), ], )), ); diff --git a/unibond/lib/view/screens/letter/letter_list_screen.dart b/unibond/lib/view/screens/letter/letter_list_screen.dart index 8300326..96ef649 100644 --- a/unibond/lib/view/screens/letter/letter_list_screen.dart +++ b/unibond/lib/view/screens/letter/letter_list_screen.dart @@ -4,7 +4,18 @@ import 'package:unibond/domain/letter/letter.dart'; import 'package:unibond/view/screens/letter/letter_read_screen.dart'; class LetterList extends StatelessWidget { - const LetterList({super.key}); + 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) { @@ -19,64 +30,76 @@ class LetterList extends StatelessWidget { }, ), ), - body: Column( - children: [ - Expanded( - child: ListView.builder( - itemCount: 10, // 예제를 위한 임시 데이터 수 - itemBuilder: (context, index) { - return Padding( - padding: const EdgeInsets.all(16.0), - 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, - child: const Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "From. 오지지", - style: TextStyle( - fontSize: 14, fontWeight: FontWeight.bold), + 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), + ), + Center( + child: Text( + "저는 오늘 행복한 하루를 보냈어요", + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, ), ), - Align( - alignment: Alignment.bottomRight, - child: Text( - "2023-11-27", - style: TextStyle(fontSize: 12), - ), + ), + Align( + alignment: Alignment.bottomRight, + child: Text( + "From. $sender", + style: TextStyle(fontSize: 12), ), - ], - ), + ), + ], ), ), ), - ); - }, - ), + ), + ); + }, ), - ], + ), ), ); } diff --git a/unibond/pubspec.lock b/unibond/pubspec.lock index d41b02d..6573afa 100644 --- a/unibond/pubspec.lock +++ b/unibond/pubspec.lock @@ -37,10 +37,10 @@ packages: dependency: transitive description: name: collection - sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.17.1" + version: "1.18.0" cupertino_icons: dependency: "direct main" description: @@ -104,14 +104,30 @@ packages: url: "https://pub.dev" source: hosted version: "0.18.1" - js: + leak_tracker: dependency: transitive description: - name: js - sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + name: leak_tracker + sha256: e45c31f458d01fd9ef4a214feb2e153b72d5b1907435f4332b1637a2f348c021 url: "https://pub.dev" source: hosted - version: "0.6.7" + 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: @@ -124,34 +140,34 @@ 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" + version: "1.11.0" path: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.9.0" sky_engine: dependency: transitive description: flutter @@ -161,26 +177,26 @@ packages: dependency: transitive description: name: source_span - sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" string_scanner: dependency: transitive description: @@ -201,10 +217,10 @@ packages: dependency: transitive description: name: test_api - sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" url: "https://pub.dev" source: hosted - version: "0.5.1" + version: "0.6.1" validators: dependency: "direct main" description: @@ -221,6 +237,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + url: "https://pub.dev" + source: hosted + version: "13.0.0" sdks: - dart: ">=3.0.6 <4.0.0" + dart: ">=3.2.0-0 <4.0.0" flutter: ">=1.10.0"