From 0191a254b94cb3ca5d7a83d8f706c50c9c33d3c1 Mon Sep 17 00:00:00 2001 From: yohom <382146139@qq.com> Date: Thu, 1 Apr 2021 11:14:03 +0800 Subject: [PATCH 1/8] =?UTF-8?q?enhance:=20=E5=A2=9E=E5=8A=A0background?= =?UTF-8?q?=E5=8F=82=E6=95=B0;=20=E4=BC=98=E5=8C=96=E5=BE=AA=E7=8E=AF?= =?UTF-8?q?=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bg/weather_bg.dart | 75 +++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 44 deletions(-) diff --git a/lib/bg/weather_bg.dart b/lib/bg/weather_bg.dart index 02f454b..22969ca 100644 --- a/lib/bg/weather_bg.dart +++ b/lib/bg/weather_bg.dart @@ -13,10 +13,15 @@ class WeatherBg extends StatefulWidget { final WeatherType weatherType; final double width; final double height; + final Widget background; - WeatherBg( - {Key key, this.weatherType, @required this.width, @required this.height}) - : super(key: key); + WeatherBg({ + Key key, + this.weatherType, + @required this.width, + @required this.height, + this.background, + }) : super(key: key); @override _WeatherBgState createState() => _WeatherBgState(); @@ -46,12 +51,14 @@ class _WeatherBgState extends State weatherType: _oldWeatherType, width: widget.width, height: widget.height, + background: widget.background, ); } var currentBgWidget = WeatherItemBg( weatherType: widget.weatherType, width: widget.width, height: widget.height, + background: widget.background, ); if (oldBgWidget == null) { oldBgWidget = currentBgWidget; @@ -86,41 +93,15 @@ class WeatherItemBg extends StatelessWidget { final WeatherType weatherType; final width; final height; + final Widget background; - WeatherItemBg({Key key, this.weatherType, this.width, this.height}) - : super(key: key); - - /// 构建晴晚背景效果 - Widget _buildNightStarBg() { - if (weatherType == WeatherType.sunnyNight) { - return WeatherNightStarBg( - weatherType: weatherType, - ); - } - return Container(); - } - - /// 构建雷暴效果 - Widget _buildThunderBg() { - if (weatherType == WeatherType.thunder) { - return WeatherThunderBg( - weatherType: weatherType, - ); - } - return Container(); - } - - /// 构建雨雪背景效果 - Widget _buildRainSnowBg() { - if (WeatherUtil.isSnowRain(weatherType)) { - return WeatherRainSnowBg( - weatherType: weatherType, - viewWidth: width, - viewHeight: height, - ); - } - return Container(); - } + WeatherItemBg({ + Key key, + this.weatherType, + this.width, + this.height, + this.background, + }) : super(key: key); @override Widget build(BuildContext context) { @@ -130,13 +111,19 @@ class WeatherItemBg extends StatelessWidget { child: ClipRect( child: Stack( children: [ - WeatherColorBg(weatherType: weatherType), - WeatherCloudBg( - weatherType: weatherType, - ), - _buildRainSnowBg(), - _buildThunderBg(), - _buildNightStarBg(), + background ?? WeatherColorBg(weatherType: weatherType), + WeatherCloudBg(weatherType: weatherType), + if (WeatherUtil.isSnowRain(weatherType)) + WeatherRainSnowBg( + weatherType: weatherType, + viewWidth: width, + viewHeight: height, + ), + if (weatherType == WeatherType.thunder) + WeatherThunderBg(weatherType: weatherType), + // 构建晴晚背景效果 + if (weatherType == WeatherType.sunnyNight) + WeatherNightStarBg(weatherType: weatherType), ], ), ), From 1960cfbc85d85d4b7a13d895bf988c6f0bdfb2ea Mon Sep 17 00:00:00 2001 From: yohom <382146139@qq.com> Date: Fri, 2 Apr 2021 10:47:03 +0800 Subject: [PATCH 2/8] =?UTF-8?q?enhance:=20=E8=B0=83=E6=95=B4=E4=BA=91?= =?UTF-8?q?=E5=B1=82=E6=AF=94=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/libraries/Dart_SDK.xml | 32 +++++++++++++++++++---------- example/pubspec.lock | 40 ++++++++++++++++++------------------ lib/bg/weather_cloud_bg.dart | 12 +++++------ pubspec.lock | 38 +++++++++++++++++----------------- 4 files changed, 66 insertions(+), 56 deletions(-) diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml index be5ced7..0cdc362 100644 --- a/.idea/libraries/Dart_SDK.xml +++ b/.idea/libraries/Dart_SDK.xml @@ -1,17 +1,27 @@ - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/example/pubspec.lock b/example/pubspec.lock index 5451a0c..3bbb273 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,42 +7,42 @@ packages: name: async url: "https://pub.flutter-io.cn" source: hosted - version: "2.4.2" + version: "2.5.0-nullsafety.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.flutter-io.cn" source: hosted - version: "2.0.0" + version: "2.1.0-nullsafety.1" characters: dependency: transitive description: name: characters url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.0" + version: "1.1.0-nullsafety.3" charcode: dependency: transitive description: name: charcode url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.3" + version: "1.2.0-nullsafety.1" clock: dependency: transitive description: name: clock url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.1" + version: "1.1.0-nullsafety.1" collection: dependency: transitive description: name: collection url: "https://pub.flutter-io.cn" source: hosted - version: "1.14.13" + version: "1.15.0-nullsafety.3" cupertino_icons: dependency: "direct main" description: @@ -56,7 +56,7 @@ packages: name: fake_async url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.0" + version: "1.2.0-nullsafety.1" flutter: dependency: "direct main" description: flutter @@ -73,28 +73,28 @@ packages: path: ".." relative: true source: path - version: "2.8.0" + version: "2.8.2" matcher: dependency: transitive description: name: matcher url: "https://pub.flutter-io.cn" source: hosted - version: "0.12.8" + version: "0.12.10-nullsafety.1" meta: dependency: transitive description: name: meta url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.8" + version: "1.3.0-nullsafety.3" path: dependency: transitive description: name: path url: "https://pub.flutter-io.cn" source: hosted - version: "1.7.0" + version: "1.8.0-nullsafety.1" sky_engine: dependency: transitive description: flutter @@ -106,56 +106,56 @@ packages: name: source_span url: "https://pub.flutter-io.cn" source: hosted - version: "1.7.0" + version: "1.8.0-nullsafety.2" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.flutter-io.cn" source: hosted - version: "1.9.5" + version: "1.10.0-nullsafety.1" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.flutter-io.cn" source: hosted - version: "2.0.0" + version: "2.1.0-nullsafety.1" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.5" + version: "1.1.0-nullsafety.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.0" + version: "1.2.0-nullsafety.1" test_api: dependency: transitive description: name: test_api url: "https://pub.flutter-io.cn" source: hosted - version: "0.2.17" + version: "0.2.19-nullsafety.2" typed_data: dependency: transitive description: name: typed_data url: "https://pub.flutter-io.cn" source: hosted - version: "1.2.0" + version: "1.3.0-nullsafety.3" vector_math: dependency: transitive description: name: vector_math url: "https://pub.flutter-io.cn" source: hosted - version: "2.0.8" + version: "2.1.0-nullsafety.3" sdks: - dart: ">=2.9.0-14.0.dev <3.0.0" + dart: ">=2.10.0-110 <2.11.0" flutter: ">=1.20.0 <2.0.0" diff --git a/lib/bg/weather_cloud_bg.dart b/lib/bg/weather_cloud_bg.dart index 9a5ff8b..fb94f6c 100644 --- a/lib/bg/weather_cloud_bg.dart +++ b/lib/bg/weather_cloud_bg.dart @@ -1,7 +1,7 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_weather_bg/bg/weather_bg.dart'; import 'dart:ui' as ui; +import 'package:flutter/material.dart'; +import 'package:flutter_weather_bg/bg/weather_bg.dart'; import 'package:flutter_weather_bg/utils/image_utils.dart'; import 'package:flutter_weather_bg/utils/print_utils.dart'; import 'package:flutter_weather_bg/utils/weather_type.dart'; @@ -129,7 +129,7 @@ class BgPainter extends CustomPainter { canvas.restore(); canvas.save(); - final scale = 0.6 * widthRatio; + final scale = 0.3 * widthRatio; ui.Offset offset1 = ui.Offset(-100, -100); canvas.scale(scale); canvas.drawImage(image, offset1, _paint); @@ -162,7 +162,7 @@ class BgPainter extends CustomPainter { 0, ]); _paint.colorFilter = identity; - final scale = 0.8 * widthRatio; + final scale = 0.3 * widthRatio; ui.Offset offset1 = ui.Offset(0, -200); ui.Offset offset2 = ui.Offset(-image.width / 2, -130); ui.Offset offset3 = ui.Offset(100, 0); @@ -200,7 +200,7 @@ class BgPainter extends CustomPainter { 0, ]); _paint.colorFilter = identity; - final scale = 0.8 * widthRatio; + final scale = 0.3 * widthRatio; ui.Offset offset1 = ui.Offset(0, -200); ui.Offset offset2 = ui.Offset(-image.width / 2, -130); ui.Offset offset3 = ui.Offset(100, 0); @@ -238,7 +238,7 @@ class BgPainter extends CustomPainter { 0, ]); _paint.colorFilter = identity; - final scale = 0.8 * widthRatio; + final scale = 0.3 * widthRatio; ui.Offset offset1 = ui.Offset(0, -200); ui.Offset offset2 = ui.Offset(-image.width / 2, -130); ui.Offset offset3 = ui.Offset(100, 0); diff --git a/pubspec.lock b/pubspec.lock index 307a0ea..c6dec39 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,49 +7,49 @@ packages: name: async url: "https://pub.flutter-io.cn" source: hosted - version: "2.4.2" + version: "2.5.0-nullsafety.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.flutter-io.cn" source: hosted - version: "2.0.0" + version: "2.1.0-nullsafety.1" characters: dependency: transitive description: name: characters url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.0" + version: "1.1.0-nullsafety.3" charcode: dependency: transitive description: name: charcode url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.3" + version: "1.2.0-nullsafety.1" clock: dependency: transitive description: name: clock url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.1" + version: "1.1.0-nullsafety.1" collection: dependency: transitive description: name: collection url: "https://pub.flutter-io.cn" source: hosted - version: "1.14.13" + version: "1.15.0-nullsafety.3" fake_async: dependency: transitive description: name: fake_async url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.0" + version: "1.2.0-nullsafety.1" flutter: dependency: "direct main" description: flutter @@ -66,21 +66,21 @@ packages: name: matcher url: "https://pub.flutter-io.cn" source: hosted - version: "0.12.8" + version: "0.12.10-nullsafety.1" meta: dependency: transitive description: name: meta url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.8" + version: "1.3.0-nullsafety.3" path: dependency: transitive description: name: path url: "https://pub.flutter-io.cn" source: hosted - version: "1.7.0" + version: "1.8.0-nullsafety.1" sky_engine: dependency: transitive description: flutter @@ -92,56 +92,56 @@ packages: name: source_span url: "https://pub.flutter-io.cn" source: hosted - version: "1.7.0" + version: "1.8.0-nullsafety.2" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.flutter-io.cn" source: hosted - version: "1.9.5" + version: "1.10.0-nullsafety.1" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.flutter-io.cn" source: hosted - version: "2.0.0" + version: "2.1.0-nullsafety.1" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.5" + version: "1.1.0-nullsafety.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.0" + version: "1.2.0-nullsafety.1" test_api: dependency: transitive description: name: test_api url: "https://pub.flutter-io.cn" source: hosted - version: "0.2.17" + version: "0.2.19-nullsafety.2" typed_data: dependency: transitive description: name: typed_data url: "https://pub.flutter-io.cn" source: hosted - version: "1.2.0" + version: "1.3.0-nullsafety.3" vector_math: dependency: transitive description: name: vector_math url: "https://pub.flutter-io.cn" source: hosted - version: "2.0.8" + version: "2.1.0-nullsafety.3" sdks: - dart: ">=2.9.0-14.0.dev <3.0.0" + dart: ">=2.10.0-110 <2.11.0" flutter: ">=1.20.0 <2.0.0" From 1e84becc0bfe5e53587b1a554fb3173617674a00 Mon Sep 17 00:00:00 2001 From: yohom <382146139@qq.com> Date: Fri, 2 Apr 2021 23:07:10 +0800 Subject: [PATCH 3/8] =?UTF-8?q?enhance:=20=E8=B0=83=E6=95=B4=E4=BA=91?= =?UTF-8?q?=E5=B1=82=E6=AF=94=E4=BE=8B=20+1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bg/weather_cloud_bg.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/bg/weather_cloud_bg.dart b/lib/bg/weather_cloud_bg.dart index fb94f6c..99bcfbd 100644 --- a/lib/bg/weather_cloud_bg.dart +++ b/lib/bg/weather_cloud_bg.dart @@ -276,7 +276,7 @@ class BgPainter extends CustomPainter { 0, ]); _paint.colorFilter = identity; - final scale = 0.8 * widthRatio; + final scale = 0.4 * widthRatio; ui.Offset offset1 = ui.Offset(-380, -150); ui.Offset offset2 = ui.Offset(0, -60); ui.Offset offset3 = ui.Offset(0, 60); @@ -416,7 +416,7 @@ class BgPainter extends CustomPainter { 0, ]); _paint.colorFilter = identity; - final scale = 0.8 * widthRatio; + final scale = 0.3 * widthRatio; ui.Offset offset1 = ui.Offset(-380, -150); ui.Offset offset2 = ui.Offset(0, -60); ui.Offset offset3 = ui.Offset(0, 60); @@ -454,7 +454,7 @@ class BgPainter extends CustomPainter { 0, ]); _paint.colorFilter = identity; - final scale = 0.8 * widthRatio; + final scale = 0.4 * widthRatio; ui.Offset offset1 = ui.Offset(-380, -150); ui.Offset offset2 = ui.Offset(0, -60); ui.Offset offset3 = ui.Offset(0, 60); @@ -492,7 +492,7 @@ class BgPainter extends CustomPainter { 0, ]); _paint.colorFilter = identity; - final scale = 0.8 * widthRatio; + final scale = 0.4 * widthRatio; ui.Offset offset1 = ui.Offset(-380, -100); ui.Offset offset2 = ui.Offset(0, -170); canvas.scale(scale, scale); @@ -528,7 +528,7 @@ class BgPainter extends CustomPainter { 0, ]); _paint.colorFilter = identity; - final scale = 0.8 * widthRatio; + final scale = 0.4 * widthRatio; ui.Offset offset1 = ui.Offset(-380, -100); ui.Offset offset2 = ui.Offset(0, -170); canvas.scale(scale, scale); @@ -564,7 +564,7 @@ class BgPainter extends CustomPainter { 0, ]); _paint.colorFilter = identity; - final scale = 0.8 * widthRatio; + final scale = 0.4 * widthRatio; ui.Offset offset1 = ui.Offset(-380, -100); ui.Offset offset2 = ui.Offset(0, -170); canvas.scale(scale, scale); From 52e78efedd1a7b013a14272d3b83f13cb044f9f8 Mon Sep 17 00:00:00 2001 From: yohom <382146139@qq.com> Date: Sat, 3 Apr 2021 17:41:57 +0800 Subject: [PATCH 4/8] =?UTF-8?q?enhance:=20=E6=99=B4=E6=99=9A=E8=83=8C?= =?UTF-8?q?=E6=99=AF=20=E5=8E=BB=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/misc.xml | 3 +++ lib/bg/weather_bg.dart | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 95dddce..1c987d3 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,5 +1,8 @@ + + +