From 096ee2f7746dea83e60ade340d95ce6dc6310f2e Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Tue, 8 Aug 2023 19:15:09 +0900 Subject: [PATCH 1/8] Create launch_page, set to home --- lib/main.dart | 6 ++++-- lib/view/launch_page.dart | 10 ++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 lib/view/launch_page.dart diff --git a/lib/main.dart b/lib/main.dart index 2402769..1cda5a9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_training/repository/weather_repository.dart'; +import 'package:flutter_training/view/launch_page.dart'; import 'package:flutter_training/view/weather_view/weather_page.dart'; import 'package:yumemi_weather/yumemi_weather.dart'; @@ -12,8 +13,9 @@ class MainApp extends StatelessWidget { @override Widget build(BuildContext context) { - return MaterialApp( - home: WeatherPage(weather: WeatherRepository(client: YumemiWeather())), + return const MaterialApp( + // home: WeatherPage(weather: WeatherRepository(client: YumemiWeather())), + home: LaunchPage(), ); } } diff --git a/lib/view/launch_page.dart b/lib/view/launch_page.dart new file mode 100644 index 0000000..5c990bb --- /dev/null +++ b/lib/view/launch_page.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; + +class LaunchPage extends StatelessWidget { + const LaunchPage({super.key}); + + @override + Widget build(BuildContext context) { + return Container(color: Colors.green); + } +} From f67fa8d72f9970648471bfa99db827b15d04343c Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Wed, 9 Aug 2023 00:06:06 +0900 Subject: [PATCH 2/8] StatelessWidget -> StatefulWidget --- lib/view/launch_page.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/view/launch_page.dart b/lib/view/launch_page.dart index 5c990bb..ac247cd 100644 --- a/lib/view/launch_page.dart +++ b/lib/view/launch_page.dart @@ -1,8 +1,13 @@ import 'package:flutter/material.dart'; -class LaunchPage extends StatelessWidget { +class LaunchPage extends StatefulWidget { const LaunchPage({super.key}); + @override + State createState() => _LaunchPageState(); +} + +class _LaunchPageState extends State { @override Widget build(BuildContext context) { return Container(color: Colors.green); From 6bd6f4de7723ddd0a6d7610c73c11cae9d2d8a4f Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Wed, 9 Aug 2023 13:39:16 +0900 Subject: [PATCH 3/8] Implement Navigation to WeatherPage --- lib/view/launch_page.dart | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/view/launch_page.dart b/lib/view/launch_page.dart index ac247cd..5109ffa 100644 --- a/lib/view/launch_page.dart +++ b/lib/view/launch_page.dart @@ -1,4 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:flutter_training/repository/weather_repository.dart'; +import 'package:flutter_training/view/weather_view/weather_page.dart'; +import 'package:yumemi_weather/yumemi_weather.dart'; class LaunchPage extends StatefulWidget { const LaunchPage({super.key}); @@ -8,6 +11,27 @@ class LaunchPage extends StatefulWidget { } class _LaunchPageState extends State { + Future _toWeatherPage() async { + await Future.delayed(const Duration(milliseconds: 500)); + if (!mounted) { + return; + } + await Navigator.push( + context, + MaterialPageRoute( + builder: (context) => WeatherPage( + weather: WeatherRepository(client: YumemiWeather()), + ), + ), + ); + } + + @override + void initState() { + super.initState(); + WidgetsBinding.instance.endOfFrame.then((_) => _toWeatherPage()); + } + @override Widget build(BuildContext context) { return Container(color: Colors.green); From 626b8e8b68ee7cb9f5938de2a15cbef65f99000f Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Wed, 9 Aug 2023 13:43:47 +0900 Subject: [PATCH 4/8] Implement pop to LaunchPage --- lib/view/weather_view/weather_page.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/view/weather_view/weather_page.dart b/lib/view/weather_view/weather_page.dart index f318907..b695120 100644 --- a/lib/view/weather_view/weather_page.dart +++ b/lib/view/weather_view/weather_page.dart @@ -34,7 +34,7 @@ class _WeatherPageState extends State { Expanded( child: TextButton( child: const Text('Close'), - onPressed: () {}, + onPressed: () => Navigator.pop(context), ), ), Expanded( From a6c1671ca61da3aaef08fdb0da9836355ce8f561 Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Wed, 9 Aug 2023 14:12:41 +0900 Subject: [PATCH 5/8] Implement Navigation to WeatherPage after returning to LaunchPage --- lib/view/launch_page.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/view/launch_page.dart b/lib/view/launch_page.dart index 5109ffa..fbf25ba 100644 --- a/lib/view/launch_page.dart +++ b/lib/view/launch_page.dart @@ -24,6 +24,8 @@ class _LaunchPageState extends State { ), ), ); + // WeatherPageから帰ってくるのを待つ + await _toWeatherPage(); } @override From 7ddeb4b8014f94b3003f48a500d4dbb1e65a6a55 Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Thu, 17 Aug 2023 20:56:56 +0900 Subject: [PATCH 6/8] Delete unnecessary comment --- lib/main.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/main.dart b/lib/main.dart index 1cda5a9..d89fd94 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -14,7 +14,6 @@ class MainApp extends StatelessWidget { @override Widget build(BuildContext context) { return const MaterialApp( - // home: WeatherPage(weather: WeatherRepository(client: YumemiWeather())), home: LaunchPage(), ); } From 628759f0e9ab2b0991a318476b91c62c49b2be02 Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Wed, 23 Aug 2023 10:03:38 +0900 Subject: [PATCH 7/8] Delete unnecessary imports --- lib/main.dart | 3 --- lib/view/weather_view/component/weather_forecast.dart | 1 - 2 files changed, 4 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index d89fd94..51589ea 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,8 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:flutter_training/repository/weather_repository.dart'; import 'package:flutter_training/view/launch_page.dart'; -import 'package:flutter_training/view/weather_view/weather_page.dart'; -import 'package:yumemi_weather/yumemi_weather.dart'; void main() { runApp(const MainApp()); diff --git a/lib/view/weather_view/component/weather_forecast.dart b/lib/view/weather_view/component/weather_forecast.dart index 78f0f16..b0c080f 100644 --- a/lib/view/weather_view/component/weather_forecast.dart +++ b/lib/view/weather_view/component/weather_forecast.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:flutter_training/model/weather_condition.dart'; - class WeatherForecast extends StatelessWidget { const WeatherForecast({super.key, required this.weatherCondition}); From f95e5d9e3d46e3f9c5e0711998b7c88939f113c8 Mon Sep 17 00:00:00 2001 From: mqkotoo Date: Wed, 23 Aug 2023 11:56:24 +0900 Subject: [PATCH 8/8] Resolve errors caused by merge --- lib/view/launch_page.dart | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/view/launch_page.dart b/lib/view/launch_page.dart index fbf25ba..e906119 100644 --- a/lib/view/launch_page.dart +++ b/lib/view/launch_page.dart @@ -1,7 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:flutter_training/repository/weather_repository.dart'; import 'package:flutter_training/view/weather_view/weather_page.dart'; -import 'package:yumemi_weather/yumemi_weather.dart'; class LaunchPage extends StatefulWidget { const LaunchPage({super.key}); @@ -19,9 +17,7 @@ class _LaunchPageState extends State { await Navigator.push( context, MaterialPageRoute( - builder: (context) => WeatherPage( - weather: WeatherRepository(client: YumemiWeather()), - ), + builder: (context) => const WeatherPage(), ), ); // WeatherPageから帰ってくるのを待つ