Skip to content

Commit

Permalink
add update version
Browse files Browse the repository at this point in the history
  • Loading branch information
DeckeDeng committed May 16, 2019
2 parents e0890c8 + f559c74 commit c205915
Show file tree
Hide file tree
Showing 28 changed files with 684 additions and 199 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Language: [English](https://github.com/alibaba/flutter-go/blob/master/README-en.

android下载地址:

<img src="https://img.alicdn.com/tfs/TB1jGgfQ7voK1RjSZFNXXcxMVXa-438-426.png" width="200px">
<img src="https://img.alicdn.com/tfs/TB1ylxGTMHqK1RjSZFgXXa7JXXa-436-432.png" width="200px">

iphone下载地址:
暂无
Expand Down
17 changes: 17 additions & 0 deletions android/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>android</name>
<comment>Project android created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
2 changes: 2 additions & 0 deletions android/.settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
connection.project.dir=
eclipse.preferences.version=1
6 changes: 6 additions & 0 deletions android/app/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
23 changes: 23 additions & 0 deletions android/app/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>app</name>
<comment>Project app created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
2 changes: 2 additions & 0 deletions android/app/.settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
connection.project.dir=..
eclipse.preferences.version=1
Binary file modified assets/app.db
Binary file not shown.
Binary file added assets/images/FlutterGo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = Launch2;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 4WLT68XRNA;
Expand All @@ -546,7 +547,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.alibaba.fluttergo;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "FlutterGO-alibaba-develop";
PROVISIONING_PROFILE_SPECIFIER = FlutterGO_alibaba_distribution_app_store;
VERSIONING_SYSTEM = "apple-generic";
};
name = Debug;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildSystemType</key>
<string>Original</string>
</dict>
</plist>
12 changes: 12 additions & 0 deletions lib/api/api.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Api{
// static const String BASE_URL = 'http://127.0.0.1:6001/';
static const String BASE_URL = 'http://flutter-go.alibaba.net/';

static const String DO_LOGIN = BASE_URL+'doLogin';//登陆

static const String CHECK_LOGIN = BASE_URL+'checkLogin';//验证登陆

static const String LOGOUT = BASE_URL+'logout';//退出登陆

static const String VERSION = BASE_URL+'getAppVersion';//检查版本
}
2 changes: 1 addition & 1 deletion lib/components/widget_demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class _WidgetDemoState extends State<WidgetDemo> {
// 插入操作
_collectionControl
.insert(Collection(name: widget.title, router: _router))
.then((result) {
.then((result) {
if (this.mounted) {
setState(() {
_hasCollected = true;
Expand Down
87 changes: 70 additions & 17 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:fluro/fluro.dart';
import 'package:flutter/rendering.dart';
import 'package:url_launcher/url_launcher.dart';
import 'routers/routers.dart';
import 'routers/application.dart';

import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:flutter_go/utils/provider.dart';
import 'package:flutter_go/utils/shared_preferences.dart';
import 'package:flutter_go/views/home.dart';
import 'package:flutter_go/model/search_history.dart';
import 'package:flutter_go/utils/analytics.dart' as Analytics;
import 'package:flutter_go/views/login_page/login_page.dart';
import 'package:flutter_go/utils/data_utils.dart';

//import 'views/welcome_page/index.dart';

const int ThemeColor = 0xFFC91B3A;
SpUtil sp;
var db;

class MyApp extends StatelessWidget {
class MyApp extends StatefulWidget {
MyApp() {
final router = new Router();

Expand All @@ -24,21 +30,68 @@ class MyApp extends StatelessWidget {
Application.router = router;
}

showWelcomePage(context) {
//网络请求查看版本
@override
_MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
bool _hasLogin = false;
bool _isLoading = true;
String localVersion;
String currVersion;

@override
Future initState() {
super.initState();

DataUtils.checkVersion({'name': 'FlutterGo'}).then((bool) {
if (bool) {
_UpdateURL();
}
}).catchError((onError) {
print('获取失败:$onError');
});

DataUtils.checkLogin().then((hasLogin) {
setState(() {
_hasLogin = hasLogin;
_isLoading = false;
});
}).catchError((onError) {
setState(() {
_hasLogin = true;
_isLoading = false;
});
print('身份信息验证失败:$onError');
});
}

showWelcomePage() {
if (_isLoading) {
return Container(
color: const Color(ThemeColor),
child: Center(
child: SpinKitPouringHourglass(color: Colors.white),
),
);
} else {
// 判断是否已经登录
if (_hasLogin) {
return AppPage();
} else {
return LoginPage();
}
}
}

final platform = Theme.of(context).platform;
print("platform:${platform}");
// 暂时关掉欢迎介绍
return AppPage();
// bool showWelcome = sp.getBool(SharedPreferencesKeys.showWelcome);
// if (showWelcome == null || showWelcome == true) {
// return WelcomePage();
// } else {
// return AppPage();
// }
_UpdateURL() async {
const currUrl =
'https://github.com/alibaba/flutter-go/raw/master/FlutterGo.apk';
if (await canLaunch(currUrl)) {
await launch(currUrl);
} else {
throw 'Could not launch $currUrl';
}
}

@override
Expand All @@ -58,9 +111,9 @@ class MyApp extends StatelessWidget {
size: 35.0,
),
),
home: new Scaffold(body: showWelcomePage(context)),
//debug banner
// debugShowCheckedModeBanner: false,
home: new Scaffold(body: showWelcomePage()),
//去掉debug logo
debugShowCheckedModeBanner: false,
onGenerateRoute: Application.router.generator,
navigatorObservers: <NavigatorObserver>[Analytics.observer],
);
Expand Down
24 changes: 24 additions & 0 deletions lib/model/user_info.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class UserInfo {
String username;
int id;
String avatarPic;
String themeColor;
String urlName;

UserInfo({
this.avatarPic,
this.id,
this.themeColor,
this.urlName,
this.username,
});

factory UserInfo.fromJson(Map<String, dynamic> json) {
return UserInfo(
avatarPic: json['avatar_pic'],
id: int.parse(json['id']),
username: json['name'],
themeColor: json['theme_color'],
urlName: json['url_name']);
}
}
64 changes: 64 additions & 0 deletions lib/model/user_info_cache.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/// @Author: 一凨
/// @Date: 2019-01-07 16:24:42
/// @Last Modified by: 一凨
/// @Last Modified time: 2019-01-08 17:37:42
import 'dart:async';

import 'package:flutter_go/utils/sql.dart';

abstract class UserInfoInterface {
String get username;
String get password;
}

class UserInfo implements UserInfoInterface {
String username;
String password;

UserInfo({this.username, this.password});

factory UserInfo.fromJSON(Map json){
return UserInfo(username: json['username'],password: json['password']);
}

Object toMap() {
return {'username': username, 'password': password};
}
}

class UserInfoControlModel {
final String table = 'userInfo';
Sql sql;

UserInfoControlModel() {
sql = Sql.setTable(table);
}

// 获取所有的收藏

// 插入新的缓存
Future insert(UserInfo userInfo) {
var result =
sql.insert({'username': userInfo.username, 'password': userInfo.password});
return result;
}

// 获取用户信息
Future<List<UserInfo>> getAllInfo() async {
List list = await sql.getByCondition();
List<UserInfo> resultList = [];
list.forEach((item){
print(item);
resultList.add(UserInfo.fromJSON(item));
});
return resultList;
}

// 清空表中数据
Future deleteAll() async{
return await sql.deleteAll();
}


}
29 changes: 29 additions & 0 deletions lib/model/version.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class Data {
String version;
String name;

Data.fromJson(Map<String, dynamic> json)
: version = json['version'],
name = json['name'];

@override
String toString() {
return 'name: $name ,version: $version';
}
}

class Version {
Data data;
int status;
bool success;

Version.formJson(Map<String, dynamic> json)
: status = json['status'],
success = json['success'],
data = Data.fromJson(json['data']);

@override
String toString() {
return 'status: $status ,success: $success,date: ${data.toString()}';
}
}
5 changes: 5 additions & 0 deletions lib/routers/router_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import '../widgets/404.dart';
import 'package:flutter_go/components/full_screen_code_dialog.dart';
import 'package:flutter_go/views/web_page/web_view_page.dart';
import 'package:flutter_go/views/home.dart';
import 'package:flutter_go/views/login_page/login_page.dart';

// app的首页
var homeHandler = new Handler(
Expand All @@ -26,6 +27,10 @@ var widgetNotFoundHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
return new WidgetNotFound();
});
var loginPageHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
return LoginPage();
});

var fullScreenCodeDialog = new Handler(
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
Expand Down
2 changes: 2 additions & 0 deletions lib/routers/routers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Routes {
static String widgetDemo = '/widget-demo';
static String codeView = '/code-view';
static String webViewPage = '/web-view-page';
static String loginPage = '/loginpage';

static void configureRoutes(Router router) {
List widgetDemosList = new WidgetDemoList().getDemos();
Expand All @@ -22,6 +23,7 @@ class Routes {

router.define('/category/:type', handler: categoryHandler);
router.define('/category/error/404', handler: widgetNotFoundHandler);
router.define(loginPage, handler: loginPageHandler);
router.define(codeView,handler:fullScreenCodeDialog);
router.define(webViewPage,handler:webViewPageHand);
widgetDemosList.forEach((demo) {
Expand Down
Loading

0 comments on commit c205915

Please sign in to comment.