Skip to content

Commit

Permalink
Merge branch 'feature/#14-letterBox' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
codeJiwon authored Jan 1, 2024
2 parents 389cade + 73c6004 commit d1267ac
Show file tree
Hide file tree
Showing 8 changed files with 329 additions and 68 deletions.
4 changes: 3 additions & 1 deletion unibond/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions unibond/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
169 changes: 132 additions & 37 deletions unibond/lib/view/screens/letter/letter_box_screen.dart
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -20,47 +12,150 @@ class LetterEnvelope {
LetterEnvelope({required this.date, required this.sender});
}

class LetterBoxScreen extends StatelessWidget {
final List<LetterEnvelope> fakeEnvelopes;

class LetterBoxScreen extends StatefulWidget {
const LetterBoxScreen({Key? key, required this.fakeEnvelopes})
: super(key: key);

final List<LetterEnvelope> fakeEnvelopes;

@override
_LetterBoxScreenState createState() => _LetterBoxScreenState();
}

class _LetterBoxScreenState extends State<LetterBoxScreen> {
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<List<Color>> 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()),
);
}
},
),
);
}
}
106 changes: 106 additions & 0 deletions unibond/lib/view/screens/letter/letter_list_screen.dart
Original file line number Diff line number Diff line change
@@ -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),
),
),
],
),
),
),
),
);
},
),
),
),
);
}
}
16 changes: 13 additions & 3 deletions unibond/lib/view/screens/letter/letter_read_screen.dart
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -15,11 +18,12 @@ class _LetterReadScreenState extends State<LetterReadScreen> {
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: [
Expand All @@ -41,6 +45,7 @@ class _LetterReadScreenState extends State<LetterReadScreen> {
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(
widget.letter.title,
Expand All @@ -56,6 +61,11 @@ class _LetterReadScreenState extends State<LetterReadScreen> {
fontSize: 18,
),
),
CustomElevatedButton(
text: "답장 쓰기",
screenRoute: () {
Get.to(() => const LetterWriteScreen());
})
],
),
),
Expand Down
Loading

0 comments on commit d1267ac

Please sign in to comment.