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),
      ),
    ],
  );
}

๐Ÿ“œ์ถœ์ฒ˜(์ฐธ๊ณ  ๋ฌธํ—Œ)


๐Ÿ”—์—ฐ๊ฒฐ ๋ฌธ์„œ