From 48e9b5fc251a6fb95b7444554edb406800807c12 Mon Sep 17 00:00:00 2001 From: Shawn Date: Thu, 19 Oct 2023 16:25:02 -0600 Subject: [PATCH] Remove wallpaperPhoto view and related logic (saved in `feature/wallpaper-sharing` branch if needed in the future) --- lib/logic/wallpaper_logic.dart | 59 ------ lib/main.dart | 2 - lib/router.dart | 4 - .../wallpaper_photo_screen.dart | 176 ------------------ macos/Flutter/GeneratedPluginRegistrant.swift | 2 - pubspec.lock | 40 ---- pubspec.yaml | 1 - .../flutter/generated_plugin_registrant.cc | 3 - windows/flutter/generated_plugins.cmake | 1 - 9 files changed, 288 deletions(-) delete mode 100644 lib/logic/wallpaper_logic.dart delete mode 100644 lib/ui/screens/wallpaper_photo/wallpaper_photo_screen.dart diff --git a/lib/logic/wallpaper_logic.dart b/lib/logic/wallpaper_logic.dart deleted file mode 100644 index 558eb07c..00000000 --- a/lib/logic/wallpaper_logic.dart +++ /dev/null @@ -1,59 +0,0 @@ -import 'dart:async'; -import 'dart:io'; -import 'dart:ui' as ui; - -import 'package:flutter/rendering.dart'; -import 'package:image_gallery_saver/image_gallery_saver.dart'; -import 'package:path_provider/path_provider.dart'; -import 'package:share_plus/share_plus.dart'; -import 'package:wonders/common_libs.dart'; -import 'package:wonders/logic/common/platform_info.dart'; -import 'package:wonders/ui/common/modals/app_modals.dart'; - -class WallPaperLogic { - /// Walks user through flow to save a Wonder Poster to their gallery - Future save(State state, RenderRepaintBoundary boundary, {required String name}) async { - // Time to create an image! - Uint8List? pngBytes = await _getPngFromBoundary(boundary); - final context = state.context, mounted = state.mounted; - if (pngBytes != null && mounted) { - bool? result = await showModal(context, - child: OkCancelModal( - msg: $strings.wallpaperModalSave, - )); - if (result == true && mounted) { - showModal(context, child: LoadingModal(msg: $strings.wallpaperModalSaving)); - if (PlatformInfo.isMobile) { - await ImageGallerySaver.saveImage(pngBytes, quality: 95, name: name); - } else { - await Future.delayed(500.ms); - } - if (state.mounted) { - Navigator.pop(context); - showModal(context, child: OkModal(msg: $strings.wallpaperModalSaveComplete)); - } - } - } - } - - Future share(BuildContext context, RenderRepaintBoundary boundary, - {required String name, String wonderName = 'Wonderous'}) async { - Uint8List? pngBytes = await _getPngFromBoundary(boundary); - if (pngBytes != null) { - final directory = (await getApplicationDocumentsDirectory()).path; - File imgFile = File('$directory/$name.png'); - await imgFile.writeAsBytes(pngBytes); - Share.shareXFiles([XFile(imgFile.path)], - subject: '$wonderName Wallpaper', text: 'Check out this $wonderName wallpaper from the Wonderous app!'); - } - } -} - -Future _getPngFromBoundary(RenderRepaintBoundary boundary) async { - ui.Image uiImage = await boundary.toImage(); - ByteData? byteData = await uiImage.toByteData(format: ui.ImageByteFormat.png); - if (byteData != null) { - return byteData.buffer.asUint8List(); - } - return null; -} diff --git a/lib/main.dart b/lib/main.dart index fcdb3f77..3ba7fa3d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -8,7 +8,6 @@ import 'package:wonders/logic/artifact_api_logic.dart'; import 'package:wonders/logic/artifact_api_service.dart'; import 'package:wonders/logic/timeline_logic.dart'; import 'package:wonders/logic/unsplash_logic.dart'; -import 'package:wonders/logic/wallpaper_logic.dart'; import 'package:wonders/logic/wonders_logic.dart'; void main() async { @@ -79,7 +78,6 @@ SettingsLogic get settingsLogic => GetIt.I.get(); UnsplashLogic get unsplashLogic => GetIt.I.get(); ArtifactAPILogic get metAPILogic => GetIt.I.get(); CollectiblesLogic get collectiblesLogic => GetIt.I.get(); -WallPaperLogic get wallpaperLogic => GetIt.I.get(); LocaleLogic get localeLogic => GetIt.I.get(); /// Global helpers for readability diff --git a/lib/router.dart b/lib/router.dart index f5e4f07c..35ee0d67 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -9,7 +9,6 @@ import 'package:wonders/ui/screens/collection/collection_screen.dart'; import 'package:wonders/ui/screens/home/wonders_home_screen.dart'; import 'package:wonders/ui/screens/intro/intro_screen.dart'; import 'package:wonders/ui/screens/timeline/timeline_screen.dart'; -import 'package:wonders/ui/screens/wallpaper_photo/wallpaper_photo_screen.dart'; import 'package:wonders/ui/screens/wonder_details/wonders_details_screen.dart'; /// Shared paths / urls used across the app @@ -69,9 +68,6 @@ final appRouter = GoRouter( AppRoute('/maps/:type', (s) { return FullscreenMapsViewer(type: _parseWonderType(s.params['type'])); }), - AppRoute('/wallpaperPhoto/:type', (s) { - return WallpaperPhotoScreen(type: _parseWonderType(s.params['type'])); - }), ]), ], ); diff --git a/lib/ui/screens/wallpaper_photo/wallpaper_photo_screen.dart b/lib/ui/screens/wallpaper_photo/wallpaper_photo_screen.dart deleted file mode 100644 index 4a8fae95..00000000 --- a/lib/ui/screens/wallpaper_photo/wallpaper_photo_screen.dart +++ /dev/null @@ -1,176 +0,0 @@ -import 'dart:async'; - -import 'package:flutter/rendering.dart'; -import 'package:wonders/common_libs.dart'; -import 'package:wonders/logic/common/platform_info.dart'; -import 'package:wonders/logic/data/wonder_data.dart'; -import 'package:wonders/ui/common/app_icons.dart'; -import 'package:wonders/ui/common/controls/checkbox.dart'; -import 'package:wonders/ui/wonder_illustrations/common/animated_clouds.dart'; -import 'package:wonders/ui/wonder_illustrations/common/wonder_illustration.dart'; -import 'package:wonders/ui/wonder_illustrations/common/wonder_illustration_config.dart'; -import 'package:wonders/ui/wonder_illustrations/common/wonder_title_text.dart'; - -class WallpaperPhotoScreen extends StatefulWidget { - const WallpaperPhotoScreen({Key? key, required this.type}) : super(key: key); - final WonderType type; - - @override - State createState() => _WallpaperPhotoScreenState(); -} - -class _WallpaperPhotoScreenState extends State { - final GlobalKey _containerKey = GlobalKey(); - Widget? _illustration; - - bool _showTitleText = true; - Timer? _photoRetryTimer; - - @override - void dispose() { - _photoRetryTimer?.cancel(); - super.dispose(); - } - - void _handleTakePhoto(BuildContext context, String wonderName) async { - final boundary = _containerKey.currentContext?.findRenderObject() as RenderRepaintBoundary?; - if (boundary != null) { - wallpaperLogic.save(this, boundary, name: '${wonderName}_wallpaper'); - } - } - - void _handleSharePhoto(BuildContext context, String wonderName) async { - final boundary = _containerKey.currentContext!.findRenderObject() as RenderRepaintBoundary; - wallpaperLogic.share(context, boundary, name: '${wonderName}_wallpaper', wonderName: wonderName); - } - - void _handleTextToggle(bool? isActive) { - setState(() => _showTitleText = isActive ?? !_showTitleText); - } - - @override - Widget build(BuildContext context) { - WonderData wonderData = wondersLogic.getData(widget.type); - WonderIllustrationConfig bgConfig = WonderIllustrationConfig.bg( - enableAnims: false, - enableHero: false, - ); - WonderIllustrationConfig fgConfig = WonderIllustrationConfig( - enableAnims: false, - enableHero: false, - enableBg: false, - ); - Color fgColor = wonderData.type.bgColor; //.withOpacity(.5); - - _illustration = RepaintBoundary( - key: _containerKey, - child: ClipRect( - child: Stack( - children: [ - // Background - apply additional filter to make moon brighter - WonderIllustration( - widget.type, - config: bgConfig, - ), - - // Clouds - FractionallySizedBox( - widthFactor: 1, - heightFactor: .5, - child: AnimatedClouds( - wonderType: wonderData.type, - opacity: 1, - enableAnimations: false, - ), - ), - - // Wonder illustration - WonderIllustration( - widget.type, - config: fgConfig, - ), - - // Foreground gradient - Container( - decoration: BoxDecoration( - gradient: LinearGradient( - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - colors: [ - fgColor.withOpacity(0), - fgColor.withOpacity(fgColor.opacity * .75), - ], - stops: const [0, 1], - ), - ), - ), - - // Title text - if (_showTitleText) - BottomCenter( - child: Transform.translate( - offset: Offset(0.0, -$styles.insets.xl * 2), - child: WonderTitleText(wonderData, enableShadows: true), - ), - ), - ], - ), - ), - ); - - return Stack(children: [ - Container( - decoration: BoxDecoration(backgroundBlendMode: BlendMode.color, color: Colors.blue), - child: _illustration ?? Container(), - ), - TopCenter( - child: SafeArea( - child: Padding( - padding: EdgeInsets.all($styles.insets.md), - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.symmetric(vertical: 10.0), - child: BackBtn.close( - bgColor: $styles.colors.offWhite, - iconColor: $styles.colors.black, - ), - ), - Expanded(child: Container()), - Padding( - padding: const EdgeInsets.only(top: 10.0, bottom: 10.0, right: 16.0), - child: CircleIconBtn( - icon: PlatformInfo.isIOS ? AppIcons.share_ios : AppIcons.share_android, - bgColor: $styles.colors.offWhite, - color: $styles.colors.black, - onPressed: () => _handleSharePhoto(context, wonderData.title), - semanticLabel: $strings.wallpaperSemanticSharePhoto, - size: 44, - ), - ), - CircleIconBtn( - icon: AppIcons.download, - onPressed: () => _handleTakePhoto(context, wonderData.title), - semanticLabel: $strings.wallpaperSemanticTakePhoto, - size: 64, - ), - ], - ), - ), - ), - ), - BottomCenter( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - SimpleCheckbox( - active: _showTitleText, label: $strings.wallpaperCheckboxShowTitle, onToggled: _handleTextToggle), - Gap($styles.insets.xl), - ], - ), - ), - ]); - } -} diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 25ce8448..884b3cc9 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -8,7 +8,6 @@ import Foundation import desktop_window import package_info_plus import path_provider_foundation -import share_plus import shared_preferences_foundation import url_launcher_macos @@ -16,7 +15,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { DesktopWindowPlugin.register(with: registry.registrar(forPlugin: "DesktopWindowPlugin")) FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) - SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index a8699082..15752177 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -73,14 +73,6 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.1" - cross_file: - dependency: transitive - description: - name: cross_file - sha256: fd832b5384d0d6da4f6df60b854d33accaaeb63aa9e10e736a87381f08dee2cb - url: "https://pub.dev" - source: hosted - version: "0.3.3+5" crypto: dependency: transitive description: @@ -480,14 +472,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.1" - mime: - dependency: transitive - description: - name: mime - sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e - url: "https://pub.dev" - source: hosted - version: "1.0.4" nested: dependency: transitive description: @@ -672,22 +656,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.0" - share_plus: - dependency: "direct main" - description: - name: share_plus - sha256: f86c5acc512b20e074137075824fc29e29b2cf395dcbfcc371e96e3e6290cce1 - url: "https://pub.dev" - source: hosted - version: "8.0.0" - share_plus_platform_interface: - dependency: transitive - description: - name: share_plus_platform_interface - sha256: "357412af4178d8e11d14f41723f80f12caea54cf0d5cd29af9dcdab85d58aea7" - url: "https://pub.dev" - source: hosted - version: "3.3.0" shared_preferences: dependency: "direct main" description: @@ -893,14 +861,6 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.8" - uuid: - dependency: transitive - description: - name: uuid - sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313" - url: "https://pub.dev" - source: hosted - version: "3.0.7" vector_graphics: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 6b465de8..3ca6f44e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -43,7 +43,6 @@ dependencies: pointer_interceptor: ^0.9.3+6 provider: ^6.0.5 rnd: ^0.2.0 - share_plus: ^8.0.0 shared_preferences: ^2.0.17 sized_context: ^1.0.0+1 smooth_page_indicator: ^1.0.1 diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index dcda11a9..33bc361e 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -7,14 +7,11 @@ #include "generated_plugin_registrant.h" #include -#include #include void RegisterPlugins(flutter::PluginRegistry* registry) { DesktopWindowPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("DesktopWindowPlugin")); - SharePlusWindowsPluginCApiRegisterWithRegistrar( - registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi")); UrlLauncherWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("UrlLauncherWindows")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index ad701266..d3bb5785 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -4,7 +4,6 @@ list(APPEND FLUTTER_PLUGIN_LIST desktop_window - share_plus url_launcher_windows )