Refine schedule/todo UI and integrate Google Photos API

This commit is contained in:
kihong.kim
2026-02-01 00:30:32 +09:00
parent 7ddd29dfed
commit c614c883d4
15 changed files with 2124 additions and 565 deletions

View File

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