Refine schedule/todo UI and integrate Google Photos API
This commit is contained in:
@@ -88,7 +88,7 @@ class _AnnouncementWidgetState extends State<AnnouncementWidget> {
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
'Welcome Home! Have a great day.',
|
||||
'우리 집에 오신 것을 환영합니다! 좋은 하루 되세요.',
|
||||
style: TextStyle(color: Colors.white70, fontSize: 18),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -39,7 +39,7 @@ class _BibleVerseWidgetState extends State<BibleVerseWidget> {
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: Colors.white10),
|
||||
),
|
||||
padding: const EdgeInsets.all(24),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 20), // Reduced horizontal padding
|
||||
child: FutureBuilder<BibleVerse>(
|
||||
future: _verseFuture,
|
||||
builder: (context, snapshot) {
|
||||
@@ -65,27 +65,38 @@ class _BibleVerseWidgetState extends State<BibleVerseWidget> {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.format_quote,
|
||||
color: Color(0xFFBB86FC),
|
||||
size: 32,
|
||||
// Quote icon removed as requested
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 600), // Increased width to utilize space
|
||||
child: Text(
|
||||
verse.text.replaceAll('\\n', '\n'), // Just handle line breaks, keep original text
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 36,
|
||||
height: 1.4,
|
||||
fontStyle: FontStyle.italic,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
verse.text,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Colors.white,
|
||||
height: 1.5,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
verse.reference,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
fontWeight: FontWeight.bold,
|
||||
FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Text(
|
||||
verse.reference,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
fontSize: 24, // Reduced from 32
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,9 +1,51 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../models/schedule_item.dart';
|
||||
import '../services/schedule_service.dart';
|
||||
|
||||
class CalendarWidget extends StatelessWidget {
|
||||
class CalendarWidget extends StatefulWidget {
|
||||
const CalendarWidget({super.key});
|
||||
|
||||
@override
|
||||
State<CalendarWidget> createState() => _CalendarWidgetState();
|
||||
}
|
||||
|
||||
class _CalendarWidgetState extends State<CalendarWidget> {
|
||||
List<ScheduleItem> _schedules = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadSchedules();
|
||||
}
|
||||
|
||||
Future<void> _loadSchedules() async {
|
||||
try {
|
||||
final schedules =
|
||||
await Provider.of<ScheduleService>(context, listen: false)
|
||||
.fetchMonthlySchedules();
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_schedules = schedules;
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('Error loading schedules: $e');
|
||||
}
|
||||
}
|
||||
|
||||
bool _hasScheduleOn(DateTime date) {
|
||||
final checkDate = DateTime(date.year, date.month, date.day);
|
||||
return _schedules.any((s) {
|
||||
final start =
|
||||
DateTime(s.startDate.year, s.startDate.month, s.startDate.day);
|
||||
final end = DateTime(s.endDate.year, s.endDate.month, s.endDate.day);
|
||||
return (checkDate.isAtSameMomentAs(start) || checkDate.isAfter(start)) &&
|
||||
(checkDate.isAtSameMomentAs(end) || checkDate.isBefore(end));
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final now = DateTime.now();
|
||||
@@ -12,19 +54,10 @@ class CalendarWidget extends StatelessWidget {
|
||||
final daysInMonth = lastDayOfMonth.day;
|
||||
final startingWeekday = firstDayOfMonth.weekday; // Mon=1, Sun=7
|
||||
|
||||
// Simple calendar logic
|
||||
// We need to pad the beginning with empty slots
|
||||
// If week starts on Sunday, adjust accordingly. Let's assume Mon start for now or use locale.
|
||||
// Let's assume standard Sun-Sat or Mon-Sun. Let's go with Sun-Sat for standard calendar view often seen in KR/US.
|
||||
// DateTime.weekday: Mon=1, Sun=7.
|
||||
// If we want Sun start: Sun=0, Mon=1...
|
||||
// Let's adjust so Sunday is first.
|
||||
|
||||
int offset = startingWeekday %
|
||||
7; // If startingWeekday is 7 (Sun), offset is 0. If 1 (Mon), offset is 1.
|
||||
int offset = startingWeekday % 7;
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).cardTheme.color,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
@@ -32,38 +65,45 @@ class CalendarWidget extends StatelessWidget {
|
||||
child: Column(
|
||||
children: [
|
||||
// Header
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
DateFormat('MMMM yyyy').format(now),
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
const Icon(Icons.calendar_today, color: Colors.white54),
|
||||
],
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
DateFormat('yyyy년 M월').format(now),
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
fontSize: 20,
|
||||
),
|
||||
),
|
||||
const Icon(Icons.calendar_today,
|
||||
color: Colors.white54, size: 20),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const SizedBox(height: 8),
|
||||
// Days Header
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: ['S', 'M', 'T', 'W', 'T', 'F', 'S'].map((day) {
|
||||
children: ['일', '월', '화', '수', '목', '금', '토'].asMap().entries.map((entry) {
|
||||
final isSunday = entry.key == 0;
|
||||
return Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
day,
|
||||
style: const TextStyle(
|
||||
color: Colors.white54,
|
||||
entry.value,
|
||||
style: TextStyle(
|
||||
color: isSunday ? Colors.redAccent : Colors.white54,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const SizedBox(height: 4),
|
||||
// Days Grid
|
||||
Expanded(
|
||||
child: Column(
|
||||
@@ -73,36 +113,60 @@ class CalendarWidget extends StatelessWidget {
|
||||
children: List.generate(7, (col) {
|
||||
final index = row * 7 + col;
|
||||
final dayNumber = index - offset + 1;
|
||||
final isSunday = col == 0;
|
||||
|
||||
if (dayNumber < 1 || dayNumber > daysInMonth) {
|
||||
return const Expanded(child: SizedBox.shrink());
|
||||
}
|
||||
|
||||
final dayDate =
|
||||
DateTime(now.year, now.month, dayNumber);
|
||||
final isToday = dayNumber == now.day;
|
||||
final hasSchedule = _hasScheduleOn(dayDate);
|
||||
|
||||
return Expanded(
|
||||
child: Container(
|
||||
margin: const EdgeInsets.all(2),
|
||||
margin: const EdgeInsets.all(1),
|
||||
decoration: isToday
|
||||
? BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
border: Border.all(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
width: 2,
|
||||
),
|
||||
shape: BoxShape.circle,
|
||||
)
|
||||
: null,
|
||||
child: Center(
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Text(
|
||||
'$dayNumber',
|
||||
style: TextStyle(
|
||||
color: isToday ? Colors.black : Colors.white,
|
||||
fontWeight: isToday
|
||||
? FontWeight.bold
|
||||
: FontWeight.normal,
|
||||
fontSize: 12,
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Center(
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Text(
|
||||
'$dayNumber',
|
||||
style: TextStyle(
|
||||
color: isToday
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: (isSunday ? Colors.redAccent : Colors.white),
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (hasSchedule) // Show indicator even if it's today
|
||||
Positioned(
|
||||
bottom: 2,
|
||||
child: Container(
|
||||
width: 14,
|
||||
height: 4,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.yellowAccent,
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -73,7 +73,7 @@ class _ScheduleListWidgetState extends State<ScheduleListWidget> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Weekly Schedule',
|
||||
'주간 일정',
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -102,17 +102,31 @@ class _ScheduleListWidgetState extends State<ScheduleListWidget> {
|
||||
);
|
||||
}
|
||||
|
||||
if (_schedules.isEmpty) {
|
||||
// Correctly filter for current week (Sunday to Saturday)
|
||||
final now = DateTime.now();
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
// In Dart, weekday is 1 (Mon) to 7 (Sun).
|
||||
// To get Sunday: if Mon(1), subtract 1. if Sun(7), subtract 0.
|
||||
final daysToSubtract = now.weekday % 7;
|
||||
final startOfWeek = today.subtract(Duration(days: daysToSubtract));
|
||||
final endOfWeek = startOfWeek.add(const Duration(days: 6, hours: 23, minutes: 59, seconds: 59));
|
||||
|
||||
final filteredSchedules = _schedules.where((item) {
|
||||
// Overlap check: schedule starts before week ends AND schedule ends after week starts
|
||||
return item.startDate.isBefore(endOfWeek) && item.endDate.isAfter(startOfWeek);
|
||||
}).toList();
|
||||
|
||||
if (filteredSchedules.isEmpty) {
|
||||
return const Center(
|
||||
child: Text(
|
||||
'No schedules this week',
|
||||
'이번 주 일정이 없습니다',
|
||||
style: TextStyle(color: Colors.white54),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Sort by date
|
||||
final sortedSchedules = List<ScheduleItem>.from(_schedules);
|
||||
final sortedSchedules = List<ScheduleItem>.from(filteredSchedules);
|
||||
sortedSchedules.sort((a, b) => a.startDate.compareTo(b.startDate));
|
||||
|
||||
return ListView.separated(
|
||||
@@ -121,41 +135,56 @@ class _ScheduleListWidgetState extends State<ScheduleListWidget> {
|
||||
const Divider(color: Colors.white10),
|
||||
itemBuilder: (context, index) {
|
||||
final item = sortedSchedules[index];
|
||||
final timeStr = item.isAllDay
|
||||
? 'All Day'
|
||||
: DateFormat('HH:mm').format(item.startDate);
|
||||
|
||||
// Multi-day check
|
||||
final isMultiDay = item.startDate.year != item.endDate.year ||
|
||||
item.startDate.month != item.endDate.month ||
|
||||
item.startDate.day != item.endDate.day;
|
||||
|
||||
String? dateRangeStr;
|
||||
if (isMultiDay) {
|
||||
final startStr = DateFormat('MM/dd').format(item.startDate);
|
||||
final endStr = DateFormat('MM/dd').format(item.endDate);
|
||||
dateRangeStr = '$startStr ~ $endStr';
|
||||
}
|
||||
|
||||
return ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 8,
|
||||
horizontal: 10,
|
||||
vertical: 6,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white10,
|
||||
color: isMultiDay ? Colors.blue.withOpacity(0.2) : Colors.white10,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: isMultiDay ? Border.all(color: Colors.blue.withOpacity(0.5)) : null,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
DateFormat('d').format(item.startDate),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18,
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
DateFormat('d').format(item.startDate),
|
||||
style: TextStyle(
|
||||
color: isMultiDay ? Colors.blue : Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18,
|
||||
height: 1.2,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
DateFormat('E').format(item.startDate),
|
||||
style: const TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 12,
|
||||
Text(
|
||||
DateFormat('E').format(item.startDate),
|
||||
style: const TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 12,
|
||||
height: 1.2,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
@@ -165,10 +194,15 @@ class _ScheduleListWidgetState extends State<ScheduleListWidget> {
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
subtitle: Text(
|
||||
timeStr,
|
||||
style: const TextStyle(color: Colors.white54),
|
||||
),
|
||||
subtitle: dateRangeStr != null
|
||||
? Text(
|
||||
dateRangeStr,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
)
|
||||
: null,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../models/todo_item.dart';
|
||||
import '../models/family_member.dart';
|
||||
@@ -85,7 +86,7 @@ class _TodoListWidgetState extends State<TodoListWidget> {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Today's Todos",
|
||||
"오늘의 할 일",
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -128,7 +129,7 @@ class _TodoListWidgetState extends State<TodoListWidget> {
|
||||
Icon(Icons.thumb_up, color: Colors.white24, size: 32),
|
||||
SizedBox(height: 8),
|
||||
Text(
|
||||
'All done for today!',
|
||||
'오늘 할 일을 모두 마쳤습니다!',
|
||||
style: TextStyle(color: Colors.white54),
|
||||
),
|
||||
],
|
||||
@@ -218,6 +219,12 @@ class _TodoListWidgetState extends State<TodoListWidget> {
|
||||
decorationColor: Colors.white54,
|
||||
),
|
||||
),
|
||||
subtitle: todo.dueDate != null && (todo.dueDate!.hour != 0 || todo.dueDate!.minute != 0)
|
||||
? Text(
|
||||
DateFormat('HH:mm').format(todo.dueDate!),
|
||||
style: const TextStyle(color: Colors.white54, fontSize: 12),
|
||||
)
|
||||
: null,
|
||||
trailing: Checkbox(
|
||||
value: todo.completed,
|
||||
onChanged: (val) async {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
@@ -32,65 +33,6 @@ class _WeatherWidgetState extends State<WeatherWidget> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Widget _buildAqiIcon(int aqi) {
|
||||
Color color;
|
||||
IconData icon;
|
||||
String label;
|
||||
|
||||
switch (aqi) {
|
||||
case 1: // Good
|
||||
color = Colors.blue;
|
||||
icon = Icons.sentiment_very_satisfied;
|
||||
label = "좋음";
|
||||
break;
|
||||
case 2: // Fair
|
||||
color = Colors.green;
|
||||
icon = Icons.sentiment_satisfied;
|
||||
label = "보통";
|
||||
break;
|
||||
case 3: // Moderate
|
||||
color = Colors.yellow[700]!;
|
||||
icon = Icons.sentiment_neutral;
|
||||
label = "주의";
|
||||
break;
|
||||
case 4: // Poor
|
||||
color = Colors.orange;
|
||||
icon = Icons.sentiment_dissatisfied;
|
||||
label = "나쁨";
|
||||
break;
|
||||
case 5: // Very Poor
|
||||
color = Colors.red;
|
||||
icon = Icons.sentiment_very_dissatisfied;
|
||||
label = "매우 나쁨";
|
||||
break;
|
||||
default:
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.2),
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(color: color, width: 2),
|
||||
),
|
||||
child: Icon(icon, color: color, size: 20),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
color: color,
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder<WeatherInfo>(
|
||||
@@ -100,116 +42,133 @@ class _WeatherWidgetState extends State<WeatherWidget> {
|
||||
).fetchWeather(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Center(
|
||||
child: SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
),
|
||||
);
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
if (snapshot.hasError) {
|
||||
debugPrint('Weather Error: ${snapshot.error}');
|
||||
return const Text(
|
||||
'Weather Unavailable',
|
||||
style: TextStyle(color: Colors.white54),
|
||||
);
|
||||
}
|
||||
|
||||
if (!snapshot.hasData) {
|
||||
if (snapshot.hasError || !snapshot.hasData) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
final weather = snapshot.data!;
|
||||
// Assuming OpenWeatherMap icon format
|
||||
final iconUrl = (ApiConfig.useMockData || kIsWeb)
|
||||
? null
|
||||
: (weather.icon.isNotEmpty
|
||||
? "https://openweathermap.org/img/wn/${weather.icon}@2x.png"
|
||||
: null);
|
||||
final weatherIcon = _getWeatherIcon(weather.icon);
|
||||
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
// Weather Icon
|
||||
if (iconUrl != null)
|
||||
Image.network(
|
||||
iconUrl,
|
||||
width: 72,
|
||||
height: 72,
|
||||
errorBuilder: (_, __, ___) =>
|
||||
const Icon(Icons.wb_sunny, color: Colors.amber),
|
||||
)
|
||||
else
|
||||
const Icon(Icons.wb_sunny, color: Colors.amber, size: 60),
|
||||
const SizedBox(width: 16),
|
||||
|
||||
// Temperature & City info
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.baseline,
|
||||
textBaseline: TextBaseline.alphabetic,
|
||||
children: [
|
||||
Text(
|
||||
'${weather.temperature.round()}°',
|
||||
style: Theme.of(context).textTheme.displaySmall?.copyWith(
|
||||
fontSize: 42, // Slightly larger to stand out
|
||||
color: Colors.yellowAccent,
|
||||
fontWeight: FontWeight.bold,
|
||||
height: 1.0,
|
||||
),
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withOpacity(0.5),
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
border: Border.all(color: Colors.white24, width: 1.5),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// 1. Weather Icon (Material Icon)
|
||||
Icon(
|
||||
weatherIcon.icon,
|
||||
color: weatherIcon.color,
|
||||
size: 40,
|
||||
),
|
||||
|
||||
const SizedBox(width: 16),
|
||||
|
||||
// 2. Temperatures
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
// Current
|
||||
Text(
|
||||
'${weather.temperature.round()}°',
|
||||
style: const TextStyle(
|
||||
fontSize: 42, // Reduced from 54
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
height: 1.0,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'${weather.city} · ${weather.description}',
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
color: Colors.white70,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 20
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'최고:${weather.tempMax.round()}° 최저:${weather.tempMin.round()}°',
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
color: Colors.white,
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
|
||||
// Max
|
||||
const Text('▲', style: TextStyle(color: Colors.redAccent, fontSize: 16)),
|
||||
Text(
|
||||
'${weather.tempMax.round()}°',
|
||||
style: const TextStyle(
|
||||
fontSize: 26,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white, // Reverted to white
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
|
||||
// Min
|
||||
const Text('▼', style: TextStyle(color: Colors.lightBlueAccent, fontSize: 16)),
|
||||
Text(
|
||||
'${weather.tempMin.round()}°',
|
||||
style: const TextStyle(
|
||||
fontSize: 26,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white, // Reverted to white
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// 3. AQI
|
||||
if (weather.aqi > 0) ...[
|
||||
const SizedBox(width: 24),
|
||||
Container(width: 2, height: 36, color: Colors.white24),
|
||||
const SizedBox(width: 24),
|
||||
_buildAqiBadge(weather.aqi),
|
||||
],
|
||||
),
|
||||
|
||||
// AQI Indicator (Right side)
|
||||
if (weather.aqi > 0) ...[
|
||||
const SizedBox(width: 24),
|
||||
Container(
|
||||
height: 50,
|
||||
width: 2,
|
||||
color: Colors.white24,
|
||||
),
|
||||
const SizedBox(width: 24),
|
||||
// Scaled up AQI
|
||||
Transform.scale(
|
||||
scale: 1.2,
|
||||
child: _buildAqiIcon(weather.aqi),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// Helper to map OWM icon codes to Material Icons
|
||||
({IconData icon, Color color}) _getWeatherIcon(String iconCode) {
|
||||
// Standard OWM codes: https://openweathermap.org/weather-conditions
|
||||
if (iconCode.startsWith('01')) { // Clear sky
|
||||
return (icon: Icons.sunny, color: Colors.amber);
|
||||
} else if (iconCode.startsWith('02') || iconCode.startsWith('03') || iconCode.startsWith('04')) { // Clouds
|
||||
return (icon: Icons.cloud, color: Colors.white70);
|
||||
} else if (iconCode.startsWith('09') || iconCode.startsWith('10')) { // Rain
|
||||
return (icon: Icons.umbrella, color: Colors.blueAccent);
|
||||
} else if (iconCode.startsWith('11')) { // Thunderstorm
|
||||
return (icon: Icons.thunderstorm, color: Colors.yellow);
|
||||
} else if (iconCode.startsWith('13')) { // Snow
|
||||
return (icon: Icons.ac_unit, color: Colors.lightBlueAccent);
|
||||
} else if (iconCode.startsWith('50')) { // Mist/Fog
|
||||
return (icon: Icons.waves, color: Colors.white54);
|
||||
}
|
||||
return (icon: Icons.wb_sunny, color: Colors.amber); // Fallback
|
||||
}
|
||||
|
||||
Widget _buildAqiBadge(int aqi) {
|
||||
Color color;
|
||||
IconData icon;
|
||||
String label;
|
||||
|
||||
switch (aqi) {
|
||||
case 1: color = Colors.blue; icon = Icons.sentiment_very_satisfied; label = "좋음"; break;
|
||||
case 2: color = Colors.green; icon = Icons.sentiment_satisfied; label = "보통"; break;
|
||||
case 3: color = Colors.yellow[700]!; icon = Icons.sentiment_neutral; label = "주의"; break;
|
||||
case 4: color = Colors.orange; icon = Icons.sentiment_dissatisfied; label = "나쁨"; break;
|
||||
case 5: color = Colors.red; icon = Icons.sentiment_very_dissatisfied; label = "매우 나쁨"; break;
|
||||
default: return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(icon, color: color, size: 36),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(color: color, fontSize: 24, fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user