完成整体功能

This commit is contained in:
bluesea 2024-05-15 18:29:13 +08:00
parent 7750c80673
commit 5688c23d7e
9 changed files with 128 additions and 14 deletions

View File

@ -1,5 +1,8 @@
import 'package:get/get.dart';
import 'package:wallpaper/routes/app_routes.dart';
class MyPageController extends GetxController {
goWebview(String urlStr,String title) {
Get.toNamed(AppRoutes.webviewpage, arguments: {"urlStr":urlStr,"title":title});
}
}

View File

@ -1,7 +1,8 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:wallpaper/pages/mypage/mypage_controller.dart';
class MyPageView extends GetView {
class MyPageView extends GetView <MyPageController> {
const MyPageView({super.key});
@override
@ -19,7 +20,7 @@ class MyPageView extends GetView {
title: const Text('隐私协议'),
trailing: const Icon(Icons.arrow_forward_ios),
onTap: () {
controller.goWebview("http://www.baidu.com",'隐私协议');
},
),
ListTile(
@ -27,16 +28,13 @@ class MyPageView extends GetView {
title: const Text('用户协议'),
trailing: const Icon(Icons.arrow_forward_ios),
onTap: () {
controller.goWebview("http://www.bing.com",'用户协议');
},
),
ListTile(
leading: const Icon(Icons.info),
title: const Text('系统版本'),
trailing: const Text("v1.0",style: TextStyle(fontSize: 14),),
onTap: () {
print(".....ssss");
},
const ListTile(
leading: Icon(Icons.info),
title: Text('系统版本'),
trailing: Text("v1.0",style: TextStyle(fontSize: 14),),
),
],
),

View File

@ -0,0 +1,12 @@
import 'package:get/get.dart';
import 'package:wallpaper/pages/webviewpage/webviewpage_controller.dart';
class WebviewPageBinding extends Bindings {
@override
void dependencies() {
Get.put(WebviewPageController());
}
}

View File

@ -0,0 +1,13 @@
import 'package:get/get.dart';
class WebviewPageController extends GetxController {
var urlStr = RxString("");
var titleStr = RxString("");
@override
void onInit() {
super.onInit();
urlStr.value = Get.arguments["urlStr"];
titleStr.value = Get.arguments["title"];
}
}

View File

@ -0,0 +1,20 @@
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:get/get.dart';
import 'package:wallpaper/pages/webviewpage/webviewpage_controller.dart';
class WebviewPageView extends GetView <WebviewPageController> {
const WebviewPageView({super.key});
@override
Widget build(BuildContext context) {
return Obx(() => Scaffold(
appBar: AppBar(
title: Text(controller.titleStr.value),
),
body: InAppWebView(
initialUrlRequest: URLRequest(url: WebUri.uri(Uri.parse(controller.urlStr.value))),
),
));
}
}

View File

@ -15,12 +15,15 @@ import 'package:wallpaper/pages/downloadpage/downloadpage_binding.dart';
import 'package:wallpaper/pages/mypage/mypage_binding.dart';
import 'package:get/get.dart';
import 'package:wallpaper/pages/webviewpage/webviewpage_binding.dart';
import 'package:wallpaper/pages/webviewpage/webviewpage_view.dart';
class AppRoutes {
AppRoutes._();
static const initialPage = '/tabvc';
static const imgcategorypage = "/ImgCategoryPage";
static const imgscanpage = "/imgscanpage";
static const webviewpage = "/webviewpage";
static final routes= [
GetPage(
@ -38,6 +41,11 @@ class AppRoutes {
page: ()=> ImgScanPageView(),
bindings: [ImgScanPageBinding()],
),
GetPage(
name: webviewpage,
page: ()=> const WebviewPageView(),
bindings: [WebviewPageBinding()],
),
];

View File

@ -5,8 +5,10 @@
import FlutterMacOS
import Foundation
import flutter_inappwebview_macos
import path_provider_foundation
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
InAppWebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "InAppWebViewFlutterPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
}

View File

@ -230,6 +230,62 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.0.5"
flutter_inappwebview:
dependency: "direct main"
description:
name: flutter_inappwebview
sha256: "3e9a443a18ecef966fb930c3a76ca5ab6a7aafc0c7b5e14a4a850cf107b09959"
url: "https://pub.flutter-io.cn"
source: hosted
version: "6.0.0"
flutter_inappwebview_android:
dependency: transitive
description:
name: flutter_inappwebview_android
sha256: d247f6ed417f1f8c364612fa05a2ecba7f775c8d0c044c1d3b9ee33a6515c421
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.13"
flutter_inappwebview_internal_annotations:
dependency: transitive
description:
name: flutter_inappwebview_internal_annotations
sha256: "5f80fd30e208ddded7dbbcd0d569e7995f9f63d45ea3f548d8dd4c0b473fb4c8"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.1"
flutter_inappwebview_ios:
dependency: transitive
description:
name: flutter_inappwebview_ios
sha256: f363577208b97b10b319cd0c428555cd8493e88b468019a8c5635a0e4312bd0f
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.13"
flutter_inappwebview_macos:
dependency: transitive
description:
name: flutter_inappwebview_macos
sha256: b55b9e506c549ce88e26580351d2c71d54f4825901666bd6cfa4be9415bb2636
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.11"
flutter_inappwebview_platform_interface:
dependency: transitive
description:
name: flutter_inappwebview_platform_interface
sha256: "545fd4c25a07d2775f7d5af05a979b2cac4fbf79393b0a7f5d33ba39ba4f6187"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.10"
flutter_inappwebview_web:
dependency: transitive
description:
name: flutter_inappwebview_web
sha256: d8c680abfb6fec71609a700199635d38a744df0febd5544c5a020bd73de8ee07
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.8"
flutter_keyboard_visibility:
dependency: "direct main"
description:
@ -412,10 +468,10 @@ packages:
dependency: transitive
description:
name: js
sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.7.1"
version: "0.6.7"
json_annotation:
dependency: transitive
description:

View File

@ -58,6 +58,8 @@ dependencies:
#android设置壁纸
async_wallpaper: ^2.0.3
#webview网页
flutter_inappwebview: ^6.0.0
#将图片导出到相册
image_gallery_saver: ^2.0.3
permission_handler: ^10.0.0