Pārlūkot izejas kodu

添加公共跳转webview

tags/0.0.1
Weller pirms 4 gadiem
vecāks
revīzija
948819bada
6 mainītis faili ar 154 papildinājumiem un 6 dzēšanām
  1. +9
    -0
      example/ios/Runner/Info.plist
  2. +4
    -0
      lib/pages/setting_page/models/setting_page_style_item_model.dart
  3. +2
    -0
      lib/pages/setting_page/models/setting_page_style_item_model.g.dart
  4. +33
    -6
      lib/pages/setting_page/setting_page.dart
  5. +103
    -0
      lib/pages/webview/base_webview.dart
  6. +3
    -0
      lib/register.dart

+ 9
- 0
example/ios/Runner/Info.plist Parādīt failu

@@ -55,5 +55,14 @@
<string>获取访问相册权限更换头像</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>获取访问相册权限更换头像</string>
<key>io.flutter.embedded_views_preview</key>
<string>YES</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict>
</plist>

+ 4
- 0
lib/pages/setting_page/models/setting_page_style_item_model.dart Parādīt failu

@@ -19,12 +19,16 @@ class SettingPageStyleItemModel extends Object {
@JsonKey(name: 'skip_identifier')
String skipIdentifier;

@JsonKey(name: 'url')
String url;

SettingPageStyleItemModel(
this.name,
this.nameColor,
this.desc,
this.descColor,
this.skipIdentifier,
this.url,
);

factory SettingPageStyleItemModel.fromJson(Map<String, dynamic> srcJson) =>


+ 2
- 0
lib/pages/setting_page/models/setting_page_style_item_model.g.dart Parādīt failu

@@ -14,6 +14,7 @@ SettingPageStyleItemModel _$SettingPageStyleItemModelFromJson(
json['desc'] as String,
json['desc_color'] as String,
json['skip_identifier'] as String,
json['url'] as String,
);
}

@@ -25,4 +26,5 @@ Map<String, dynamic> _$SettingPageStyleItemModelToJson(
'desc': instance.desc,
'desc_color': instance.descColor,
'skip_identifier': instance.skipIdentifier,
'url': instance.url,
};

+ 33
- 6
lib/pages/setting_page/setting_page.dart Parādīt failu

@@ -115,13 +115,40 @@ class _SettingContainerState extends State<_SettingContainer> {
}

Widget _createItem(SettingPageStyleItemModel item) {
return Container(
width: double.infinity,
height: 50,
color: Colors.white,
child: Row(
children: <Widget>[Text(item.name), Text('aaaaa')],
return GestureDetector(
child: Container(
padding: EdgeInsets.only(left: 12.5, right: 12.5),
width: double.infinity,
height: 50,
color: Colors.white,
child: Row(
children: <Widget>[
Expanded(
child: Text(
item.name,
style: TextStyle(
fontSize: 13,
color: HexColor.fromHex(item.nameColor),
fontWeight: FontWeight.bold,
),
),
),
Expanded(
child: Text(
item.desc,
textAlign: TextAlign.right,
style: TextStyle(
fontSize: 13,
color: HexColor.fromHex(item.descColor),
),
),
),
],
),
),
onTap: () {
RouterUtil.route(item.toJson(), context);
},
);
}
}

+ 103
- 0
lib/pages/webview/base_webview.dart Parādīt failu

@@ -0,0 +1,103 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class BaseWebview extends StatefulWidget {
final Map<String, dynamic> model;

const BaseWebview(
this.model, {
Key key,
}) : super(key: key);

@override
_BaseWebviewState createState() => _BaseWebviewState();
}

class _BaseWebviewState extends State<BaseWebview> {
String _url;
String _title;
WebViewController _webViewController;

@override
void initState() {
_url = widget.model['url'] ?? '';
super.initState();
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: _createNav(),
body: Builder(builder: (BuildContext context) {
return WebView(
initialUrl: _url,
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) {
_webViewController = webViewController;
},
navigationDelegate: (NavigationRequest request) {
return NavigationDecision.navigate;
},
onPageStarted: (String url) {
print('Page started loading: $url');
},
onPageFinished: (String url) {
print('Page finished loading: $url');
_webViewController.getTitle().then((title) {
_title = title;
setState(() {});
});
},
gestureNavigationEnabled: true,
);
}),
);
}

// 导航栏
Widget _createNav() {
return CupertinoNavigationBar(
border: Border(
bottom: BorderSide(
width: 0.0, // One physical pixel.
style: BorderStyle.none,
),
),
backgroundColor: Colors.white,
leading: Navigator.canPop(context)
? GestureDetector(
child: Container(
padding: EdgeInsets.zero,
child: Icon(
Icons.arrow_back_ios,
size: 20,
),
),
onTap: () {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
},
)
: Container(),
middle: Text(
_title ?? '',
style: TextStyle(
fontSize: 15,
color: HexColor.fromHex('333333'),
),
),
trailing: GestureDetector(
child: Icon(
Icons.refresh,
size: 20,
),
onTap: () {
_webViewController.reload();
},
),
);
}
}

+ 3
- 0
lib/register.dart Parādīt failu

@@ -7,6 +7,7 @@ import 'package:zhiying_base_widget/pages/setting_page/setting_page.dart';
import 'package:zhiying_base_widget/pages/sreach_page/sreach_page.dart';
import 'package:zhiying_base_widget/pages/sreach_result_page/sreach_result_page.dart';
import 'package:zhiying_base_widget/pages/wallet_page/wallet_page.dart';
import 'package:zhiying_base_widget/pages/webview/base_webview.dart';
import 'package:zhiying_base_widget/widgets/goods_details/footer/goods_details_footer_widget.dart';
import 'package:zhiying_base_widget/widgets/goods_details/price/goods_details_price_widget.dart';
import 'package:zhiying_base_widget/widgets/goods_details/slide_banner/goods_details_slide_banner_widget.dart';
@@ -62,6 +63,8 @@ class BaseWidgetRegister {
PageFactory.regist('pub.flutter.settings', (model) => SettingPage(model));

PageFactory.regist('pub.flutter.my_orders', (model) => OrdersPage(model));

PageFactory.regist('pub.flutter.url', (model) => BaseWebview(model));
}

// 注册控件


Notiek ielāde…
Atcelt
Saglabāt