Commit 4462e533 authored by 艾娇平's avatar 艾娇平

跳转意见与建议路由

parent 30f859a9
import 'package:flutter/material.dart';
import 'package:hybrid_stack_manager/hybrid_stack_manager_plugin.dart';
import 'opinion.dart';
class ALRoute {
ALRoute._();
static const String Flutter_Hybrid = 'hrd://';
static const String Opinion = 'opinion';
}
String fullRouteUrl(route) {
return ALRoute.Flutter_Hybrid + route;
}
class AppConfig {
static final AppConfig _singleton = new AppConfig._internal();
static final GlobalKey gHomeItemPageWidgetKey =
new GlobalKey(debugLabel: "[KWLM]");
static AppConfig sharedInstance() {
Router.sharedInstance().globalKeyForRouter = gHomeItemPageWidgetKey;
Router.sharedInstance().routerWidgetHandler =
({RouterOption routeOption, Key key}) {
print('Route----${fullRouteUrl(ALRoute.Opinion)}');
// 意见与反馈
if (routeOption.url == fullRouteUrl(ALRoute.Opinion)) {
return new Opinion(routeOption, key: key);
}
return null;
};
return _singleton;
}
AppConfig._internal() {}
}
import 'package:flutter/material.dart';
import 'battery.dart';
import 'dart:ui';
import 'opinion.dart';
import 'package:flutter/rendering.dart';
void main() {
debugPaintSizeEnabled = false; //打开视觉调试开关
return runApp(
_widgetForRoute(window.defaultRouteName)
);
// return runApp(MaterialApp(
// home: '/',
// routes: {
import 'package:hybrid_stack_manager/router.dart';
import 'package:hybrid_stack_manager/hybrid_stack_manager.dart';
import 'package:hybrid_stack_manager/router_option.dart';
import 'app_config.dart';
import 'my_app.dart';
//void main() {
// debugPaintSizeEnabled = false; //打开视觉调试开关
// return runApp(_widgetForRoute(window.defaultRouteName));
//
// },
// ))
}
class ALRoute {
ALRoute._();
static const String Opinion = 'opinion';
}
// 设置Native 跳转入口
Widget _widgetForRoute(String route) {
switch (route) {
case 'myApp':
return new MyApp();
case ALRoute.Opinion:
return new Opinion();
default:
return Center(
child: Text('Unknown route: $route', textDirection: TextDirection.ltr),
);
//}
void main() async {
AppConfig.sharedInstance();
HybridStackManagerPlugin plugin =
HybridStackManagerPlugin.hybridStackManagerPlugin;
Map args = await plugin.getMainEntryParams();
runApp(new MyApp());
if (args != null && args["url"] != null) {
RouterOption routeOption = new RouterOption(
url: args["url"], query: args["query"], params: args["params"]);
Router.sharedInstance().pushPageWithOptionsFromFlutter(
routeOption: routeOption, animated: false);
}
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData.light(),
home: MyHomePage(title: 'Flutter Demo Home Page'),
routes: {
"/channeltest": batteryChannelPage,
},
);
}
Widget batteryChannelPage(BuildContext context) {
return PlatformChannel();
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
}
@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.display1,
),
FlatButton(
child: Text('channel test'),
color: Colors.green,
onPressed: (){Navigator.pushNamed(context, "/channeltest");},
)
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
import 'package:flutter/material.dart';
import 'app_config.dart';
class MyApp extends StatefulWidget {
MyApp();
State<StatefulWidget> createState() {
return new MyAppState();
}
}
class MyAppState extends State<MyApp> {
@override
void initState() {
// TODO: implement initState
super.initState();
}
@override
Widget build(BuildContext context) {
ThemeData themeData = new ThemeData(
primarySwatch: Colors.blue,
);
return new MaterialApp(
debugShowCheckedModeBanner: false,
title: '混合栈Demo',
theme: themeData,
home: new MyHomeWidget(key: AppConfig.gHomeItemPageWidgetKey),
);
}
}
class MyHomeWidget extends StatefulWidget {
MyHomeWidget({Key key}) : super(key: key);
@override
State<StatefulWidget> createState() {
return new MyHomeWidgetState();
}
}
class MyHomeWidgetState extends State<MyHomeWidget> {
@override
Widget build(BuildContext context) {
return new Container(
color: Colors.white,
);
}
}
......@@ -10,16 +10,22 @@ import 'package:flutter/material.dart';
import 'macros/ALColors.dart';
import 'macros/ALDevice.dart';
import 'macros/ALCommon.dart';
import 'package:hybrid_stack_manager/hybrid_stack_manager_plugin.dart';
//ALColors.ColorFFFFFF
class Opinion extends StatelessWidget {
// This widget is the root of your application.
@override
RouterOption routeOption;
Opinion(RouterOption option, {Key key}) : super(key: key) {
routeOption = option;
}
Widget build(BuildContext context) {
// Map m = Utils.parseUniquePageName(routeOption.userInfo);
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
color: ALColors.ColorFFFFFF,
title: '意见与建议',
color: ALColors.Color323232,
theme: ThemeData(
splashColor: Colors.white10
,//水波纹的颜色
......@@ -45,24 +51,21 @@ class _OpinionPageState extends State<OpinionPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
// appBar: AppBar(
// title: Text('Home'),
// ),
appBar: PreferredSize(
child: Container(
alignment: Alignment.center,
child: Text(
'${widget.title}',
style: TextStyle(color: ALColors.Color323232, fontSize: 18),
),
),
preferredSize: Size(320, 64)),
appBar: AppBar(
// backgroundColor: ALColors.ColorFFFFFF,
backgroundColor: Colors.white10,
leading: new GestureDetector(
child: new Icon(Icons.keyboard_backspace),
onTap: () {
HybridStackManagerPlugin.hybridStackManagerPlugin.popCurPage();
}),
title: new Text("意见与建议",style: TextStyle(color: ALColors.Color323232,fontSize: 16,fontWeight: FontWeight.bold),),
),
body: Container(
height: ALDevice.height,
width: ALDevice.width,
child: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
......@@ -76,7 +79,7 @@ class _OpinionPageState extends State<OpinionPage> {
border: Border.all(color: ALColors.ColorC4C4C4, width: 1),
),
child: TextField(
// maxLines: 10,
maxLines: 10,
controller: opinionCtrl,
decoration: InputDecoration(
border: InputBorder.none,
......@@ -115,11 +118,6 @@ class _OpinionPageState extends State<OpinionPage> {
),
),
),
// Container(
// height: 1,
// margin: EdgeInsets.only(left: 30,right: 30,top: 5),
// child: Divider(height: 1,color: ALColors.ColorC4C4C4,),
// ),
Container(
decoration: BoxDecoration(
border:
......@@ -130,9 +128,6 @@ class _OpinionPageState extends State<OpinionPage> {
BoxConstraints(minWidth: ALDevice.width, minHeight: 45),
alignment: Alignment.center,
child: FlatButton(
onHighlightChanged:(bool b){
},
onPressed: confirmClick,
child: Text(
'提交',
......@@ -149,9 +144,10 @@ class _OpinionPageState extends State<OpinionPage> {
}
void confirmClick() {
// 提交信息 && 回到上一级页面
HybridStackManagerPlugin.hybridStackManagerPlugin.popCurPage();
print('confirmClick');
}
//
//class MyNarBar extends PreferredSizeWidget {
// @override
//}
//
// ALNetClient
//
// gm_alpha_flutter
// Created by lxrent on 2019/1/31.
// Copyright © 2019 Gengmei. All rights reserved.
//
import 'dart:convert';
import 'dart:async';
import 'ALServers.dart';
import 'package:dio/dio.dart';
import 'dart:io';
import 'package:shared_preferences/shared_preferences.dart';
class ALResponse {
const ALResponse(
{this.isSuccess,
this.data,
this.error,
this.errorCode,
this.message});
final bool isSuccess;
final dynamic data;
final int error;
final String errorCode;
final String message;
factory ALResponse.fromResponse(Response response) {
if(response.statusCode == 403) return null;
var data = jsonDecode(response.toString());
print('${response.request.path}\n${data}\n${response.request.cookies}');
return new ALResponse(
isSuccess: data['error'] == 0?true:false,
data: data,
error: data['error'],
errorCode: data['errorCode'],
message: data['message'],
);
}
}
// 通用参数
String urlCommonParameters() {
return 'platform=iPhone&os_version=12.1.2&version=1.3.0&model=iPhone%20XS%20Max&release=0&idfa=EE10F836-B882-4AB8-9AB1-8E116BD48DEE&idfv=178AB378-66BF-46B3-BD12-C10FAA35C74C&device_id=EE10F836-B882-4AB8-9AB1-8E116BD48DEE&channel=(null)&app_name=gengmeiios&current_city_id=worldwide&lat=0&lng=0&is_WiFi=(null)&phone_id=iPhone11,6&count=10&page=1&type=1';
}
// 全链接
String fullAPI(api) {
return apiHost() + api + '?' + urlCommonParameters();
}
// request请求
Options requestOptions(type) {
Options options = new Options(
baseUrl: '',
contentType: new ContentType('application', 'x-www-form-urlencoded',charset: 'utf-8'),
headers: {'User-Agent':'Mozilla/5.0 (iPhone; CPU iPhone OS 10_10_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12B411 GMAlpha/1.2.1'},
connectTimeout: ALServers.ConnetTimeOut,
receiveTimeout: ALServers.ReceiveTimeOut,
method: type,
);
return options;
}
Future<ALResponse> excuteGet(url, params) async {
Dio dio = new Dio();
SharedPreferences pre = await SharedPreferences.getInstance();
Options options = requestOptions('GET');
options.cookies = createGMTokenCookie(pre.get(apiHost()));
var response = await dio
.request(fullAPI(url), data: params, options: options);
return await ALResponse.fromResponse(response);
}
List<Cookie> createGMTokenCookie(List<String> cookieString) {
List<Cookie> cookieList = List();
for(String value in cookieString) {
Cookie cookie = Cookie.fromSetCookieValue(value);
cookieList.add(cookie);
}
Cookie gm_token = Cookie.fromSetCookieValue('_gm_token=decf991549869501');
cookieList.add(gm_token);
return cookieList;
}
Future<ALResponse> excutePost(url, params) async {
Dio dio = new Dio();
SharedPreferences pre = await SharedPreferences.getInstance();
Options options = requestOptions('POST');
options.cookies = createGMTokenCookie(pre.get(apiHost()));
var response = await dio
.request(fullAPI(url), data: params, options: options);
if(response.headers['Set-Cookie'] != null) {
// 保存cookie
List cookie = response.headers[HttpHeaders.setCookieHeader];
pre.setStringList(apiHost(), cookie);
}
return await ALResponse.fromResponse(response);
}
//
// ALServers
//
// gm_alpha_flutter
// Created by Mikasa on 2019/1/30.
// Copyright © 2019 Gengmei. All rights reserved.
//
import '../macros/ALDevice.dart';
// API
class ALServers {
ALServers._();
static const int ConnetTimeOut = 5000; // 连接超时
static const int ReceiveTimeOut = 3000; // 接收超时
static const String API_SETTING_COUNTRYLIST = '/api/v1/countries';//国家列表
static const String API_LOGOUT = '/api/account/logout'; // 注销
static const String API_ACCOUNT_LOGIN_PWD ='/api/account/login_pwd';// 账号密码登录
static const String API_V1_INDEX = '/api/v1/index'; // 首页
static const String API_ACCOUNT_REGISTER = '/api/account/register';// 用户注册
static const String API_ACCOUNT_GETVFC = '/api/account/get_vfc';// 获取验证码
static const String API_ACCOUNT_THIRDPART = '/api/account/thirdparty_login'; // 三方账户登录
// HOST
}
// HOST
String apiHost() {
if (ALDevice.debug) {
return 'http://earth.alpha.newdev';
} else {
return 'https://earth.iyanzhi.com';
}
}
# Generated by pub
# See https://www.dartlang.org/tools/pub/glossary#lockfile
packages:
archive:
dependency: transitive
description:
name: archive
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.8"
args:
dependency: transitive
description:
name: args
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.5.1"
async:
dependency: transitive
description:
......@@ -29,6 +43,27 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.14.11"
convert:
dependency: transitive
description:
name: convert
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.1"
cookie_jar:
dependency: transitive
description:
name: cookie_jar
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.0"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.6"
cupertino_icons:
dependency: "direct main"
description:
......@@ -36,6 +71,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.2"
dio:
dependency: "direct main"
description:
name: dio
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.10"
flutter:
dependency: "direct main"
description: flutter
......@@ -46,6 +88,27 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
hybrid_stack_manager:
dependency: "direct main"
description:
name: hybrid_stack_manager
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.1"
image:
dependency: transitive
description:
name: image
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.7"
json_annotation:
dependency: "direct main"
description:
name: json_annotation
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.0"
matcher:
dependency: transitive
description:
......@@ -67,6 +130,20 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.6.2"
path_provider:
dependency: transitive
description:
name: path_provider
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.4.1"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.1"
quiver:
dependency: transitive
description:
......@@ -74,6 +151,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.1"
shared_preferences:
dependency: "direct main"
description:
name: shared_preferences
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.4.3"
sky_engine:
dependency: transitive
description: flutter
......@@ -135,5 +219,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.8"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.3.1"
sdks:
dart: ">=2.0.0 <3.0.0"
flutter: ">=0.3.1 <2.0.0"
......@@ -23,6 +23,12 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
hybrid_stack_manager: 0.1.1
json_annotation: ^2.0.0
# 网络
dio: ^2.0.0
# 数据存储
shared_preferences: ^0.4.2
dev_dependencies:
flutter_test:
......
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:my_flutter/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment