diff --git a/lib/pages/sign/sign_in_page.dart b/lib/pages/sign/sign_in_page.dart index f430c50e..cd9cf989 100644 --- a/lib/pages/sign/sign_in_page.dart +++ b/lib/pages/sign/sign_in_page.dart @@ -1,10 +1,16 @@ +import 'dart:async'; +import 'dart:io'; + import 'package:akuCommunity/pages/sign/user_authentication_page.dart'; +import 'package:akuCommunity/routers/page_routers.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:akuCommunity/utils/screenutil.dart'; import 'package:akuCommunity/base/base_style.dart'; import 'package:akuCommunity/base/assets_image.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_screenutil/screenutil.dart'; +import 'package:path_provider/path_provider.dart'; class SignInPage extends StatefulWidget { SignInPage({Key key}) : super(key: key); @@ -17,6 +23,8 @@ class _SignInPageState extends State { TextEditingController _phone = new TextEditingController(); TextEditingController _code = new TextEditingController(); String _verifyStr = '获取验证码'; + String pathPDF = ""; + bool _agreementvalue = false; AppBar _appBar() { return AppBar( @@ -149,15 +157,43 @@ class _SignInPageState extends State { ); } + Future fromAsset(String asset, String filename) async { + // To open from assets, you can copy them to the app storage folder, and the access them "locally" + Completer completer = Completer(); + + try { + var dir = await getApplicationDocumentsDirectory(); + File file = File("${dir.path}/$filename"); + var data = await rootBundle.load(asset); + var bytes = data.buffer.asUint8List(); + await file.writeAsBytes(bytes, flush: true); + completer.complete(file); + } catch (e) { + throw Exception('Error parsing asset file!'); + } + + return completer.future; + } + + @override + void initState() { + super.initState(); + fromAsset('assets/agreement.pdf', 'demo.pdf').then((f) { + setState(() { + pathPDF = f.path; + }); + }); + } + @override Widget build(BuildContext context) { double _statusHeight = MediaQuery.of(context).padding.top; ScreenUtil.init(context, width: 750, height: 1334, allowFontScaling: true); return Scaffold( + backgroundColor: Colors.white, appBar: _appBar(), body: SingleChildScrollView( child: Container( - color: Colors.white, child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { @@ -190,7 +226,20 @@ class _SignInPageState extends State { _containerTextField( AssetsImage.CODELOGO, _code, '请输入验证码', true), SizedBox(height: Screenutil.length(59)), - _inkWellLogin() + _inkWellLogin(), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + FlatButton( + onPressed: () { + Navigator.pushNamed( + context, PageName.agreement_page.toString(), + arguments: Bundle()..putString('path', pathPDF)); + }, + child: SizedBox(child: Text('用户协议和隐私政策')), + ), + ], + ) ], ), ), diff --git a/pubspec.yaml b/pubspec.yaml index baa6f813..cbb6e45c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.0.1+2 +version: 1.0.2+3 environment: sdk: ">=2.7.0 <3.0.0"