Created at : 2025-01-15 04:06
Auther: Soo.Y
๐๋ฉ๋ชจ
ํด๋ก ์ฝ๋ฉ
์๋ ์ด๋ฏธ์ง์ ๋์ผํ๊ฒ ํด๋ก ์ฝ๋ฉํ๊ธฐ
[TA ํํธ]
- Flutter๋ก ํ๋ฉด์ ๊ตฌ์ฑํ๋ ์ฒซ ๊ณผ์ ์ ๋๋ค. ํ๋ฉด๊ณผ ๋๊ฐ์ด ๊ตฌ์ฑํ๋ ๊ฒ๋ ์ข์ง๋ง ์ต๋ํ ์์ ๋จ์์ Widget ์ผ๋ก ๋ถ๋ฆฌํด์ ๊ฐ๋ฐํ๋ ๊ฒ์ ๋ชฉํ๋ก ํด ๋ณด์์.
- TODAY ์ฐ์ธก ์ ์ ํ ๋ ์ง๋ค์ ์ซ์๊ฐ ๋ฐ์ฏค ๊ฐ๋ ค์ง ๊ฒ์ผ๋ก ๋ณด์ ์ํ์ผ๋ก ์คํฌ๋กค ํ ์ ์์ด์ผ ํ๋ ๊ฒ์ผ๋ก ๋ณด์ ๋๋ค.
- ๋ง์ฐฌ๊ฐ์ง๋ก ๊ฐ์ฅ ์๋์ชฝ์ย
WEEKLY PLANNING
๋ ์๋๊ฐ ์ด์ง ๊ฐ๋ ค์ ธ ์๋ ๊ฒ์ผ๋ก ๋ณด์ ์์ง์ผ๋ก ์คํฌ๋กค ๊ฐ๋ฅํด์ผ ํ๋ค๋ ๊ฒ์ ์ ์ ์์ต๋๋ค. - SingleChildScrollViewย ๋ฅผ ์ฌ์ฉํ๋ฉด ์์ ฏ๋ค์ ์ํ ํน์ ์์ง์ผ๋ก ์คํฌ๋กค ๊ฐ๋ฅํ ๋ทฐ๋ฅผ ๋ง๋ค ์ ์์ต๋๋ค.
- Collection forย ๋ฅผ ์ฌ์ฉํ์ฌ ๋ฐ๋ณต๋ ์ฝ๋๋ฅผ ์ค์ผ ์ ์์ต๋๋ค.
๋ด๊ฐ ๋ง๋ ์ฝ๋
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData.dark(), // ๋๋ต์ ์ธ ๋คํฌ ํ
๋ง ์ ์ฉ
home: const HomeScreen(),
debugShowCheckedModeBanner: false,
);
}
}
class HomeScreen extends StatelessWidget {
const HomeScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
// ๋ฐฐ๊ฒฝ์์ ๊ฒ์ ์์ผ๋ก ํํ
backgroundColor: Colors.black,
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(16.0),
// ์ธ๋ก ๋ฐฉํฅ์ผ๋ก ์๋ Column
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 1) ์๋จ ํ๋กํ๊ณผ + ๋ฒํผ, ๋ ์ง ํ์
_buildHeader(),
const SizedBox(height: 20),
// 2) ์ผ์ ์นด๋๋ค์ ์คํฌ๋กคํ ์ ์๋๋ก (์: ListView)
Expanded(
child: SingleChildScrollView(
child: Column(
children: [
_buildScheduleCard(
title: 'DESIGN MEETING',
timeRange: '11:30\n12:20',
backgroundColor: Colors.yellow,
participants: 'ALEX HELENA NANA',
),
const SizedBox(height: 16),
_buildScheduleCard(
title: 'DAILY PROJECT',
timeRange: '12:35\n14:10',
backgroundColor: Colors.purple,
participants: 'ME RICHARD CIRY +4',
),
const SizedBox(height: 16),
_buildScheduleCard(
title: 'WEEKLY PLANNING',
timeRange: '15:00\n16:30',
backgroundColor: Colors.lightGreen,
participants: 'DEN NANA MARK',
),
],
),
),
),
],
),
),
),
);
}
// ์๋จ ํค๋ ๋ถ๋ถ์ ๋ฐ๋ก ๋ฝ์์ ๋ง๋ฆ
Widget _buildHeader() {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
// ์ผ์ชฝ: ํ๋กํ ์ฌ์ง + ๋ ์ง ํ๊ธฐ
Row(
children: [
// ๊ฐ๋จํ ํ๋กํ
CircleAvatar(
radius: 20,
backgroundColor: Colors.grey,
child: Icon(Icons.person, color: Colors.black),
),
const SizedBox(width: 10),
// ๋ ์ง, ์์๋ก "MONDAY 16" ํ์
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
Text(
'MONDAY 16',
style: TextStyle(color: Colors.white70, fontSize: 12),
),
// TODAY ์ ์๊ฐ๋ค ํ์
Text(
'TODAY ยท 17 18 19 20',
style: TextStyle(color: Colors.white, fontSize: 14),
),
],
),
],
),
// ์ค๋ฅธ์ชฝ: + ๋ฒํผ
IconButton(
onPressed: () {},
icon: const Icon(Icons.add, color: Colors.white, size: 28),
),
],
);
}
// ์ผ์ ์นด๋ ๋ถ๋ถ์ ๋ฐ๋ก ๋ฝ์์ ๋ง๋๋ ๋ฉ์๋
Widget _buildScheduleCard({
required String title,
required String timeRange,
required Color backgroundColor,
required String participants,
}) {
return Container(
width: double.infinity,
// ์นด๋ ๋ชจ์์ ์ฃผ๊ธฐ ์ํด ์กฐ๊ธ ๋ฅ๊ธ๊ฒ
decoration: BoxDecoration(
color: backgroundColor,
borderRadius: BorderRadius.circular(12),
),
padding: const EdgeInsets.all(16.0),
child: Row(
children: [
// ์ผ์ชฝ ์๊ฐ ํ์
SizedBox(
width: 40,
child: Text(
timeRange,
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: Colors.black87,
),
textAlign: TextAlign.right,
),
),
const SizedBox(width: 16),
// ์ค๋ฅธ์ชฝ ์ผ์ ๋ด์ฉ
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// ์ผ์ ์ ๋ชฉ
Text(
title,
style: const TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
const SizedBox(height: 8),
// ์ฐธ์ฌ์ ํ์
Text(
participants,
style: const TextStyle(
fontSize: 14,
color: Colors.black87,
),
),
],
),
),
],
),
);
}
}
ChatGPT ๋์
์๋จ์ ๋ ์ง๋ฅผ ์ค๋์ ์ผ์๋ก ๋ณ๊ฒฝํ๊ธฐ
DateTime now = DateTime.now();
List<String> weekDays = [
'MONDAY', 'TUESDAY', 'WEDNESDAY',
'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY'
];
// now.weekday๋ 1~7 ๋ฒ์์ด๋ฏ๋ก, ์ธ๋ฑ์ค๊ฐ 0~6์ธ ์ฐ๋ฆฌ ๋ฆฌ์คํธ์ ๋ง์ถ๋ ค๋ฉด -1 ํด์ค์ผ ํด์.
String dayString = weekDays[now.weekday - 1]; // 'MONDAY' ๊ฐ์ ๊ฐ์ด ๋จ
int dateNumber = now.day; // ์ค๋์ด ๋ช ์ผ์ธ์ง: 16, 17, 18 ๋ฑ
String todayText = '$dayString $dateNumber';
// ( ์๋ต ...)
_buildHeader
๋ด์ฉ๋ง ์์ ํ๋ฉด ๋๋ค.
// Header๋ฅผ ๋ง๋๋ ์ฝ๋ (๋ฐ์ท)
Widget _buildHeader() {
// ์ค๋ ๋ ์ง ๊ตฌํ๊ธฐ
DateTime now = DateTime.now();
List<String> weekDays = [
'MONDAY', 'TUESDAY', 'WEDNESDAY',
'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY'
];
String dayString = weekDays[now.weekday - 1];
int dateNumber = now.day;
String todayText = '$dayString $dateNumber'; // ์: "MONDAY 16"
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
// ์ผ์ชฝ: ํ๋กํ ์ฌ์ง + ๋ ์ง ํ๊ธฐ
Row(
children: [
CircleAvatar(
radius: 20,
backgroundColor: Colors.grey,
child: Icon(Icons.person, color: Colors.black),
),
const SizedBox(width: 10),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 1) ์์์ ๋ง๋ todayText๋ฅผ ํ์
Text(
todayText,
style: const TextStyle(color: Colors.white70, fontSize: 12),
),
// 2) TODAY์ ์๊ฐ์ ํ์ํ๋ ๋ถ๋ถ์ ํ์์ ๋ฐ๋ผ ์์
const Text(
'TODAY ยท 17 18 19 20',
style: TextStyle(color: Colors.white, fontSize: 14),
),
],
),
],
),
IconButton(
onPressed: () {},
icon: const Icon(Icons.add, color: Colors.white, size: 28),
),
],
);
}