mirror of
https://github.com/alibaba/flutter-go.git
synced 2025-07-18 10:02:31 +08:00
@ -9,6 +9,7 @@
|
|||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
084A20882202E4FD00428FF5 /* flutter go.png in Resources */ = {isa = PBXBuildFile; fileRef = 084A20872202E4FD00428FF5 /* flutter go.png */; };
|
084A20882202E4FD00428FF5 /* flutter go.png in Resources */ = {isa = PBXBuildFile; fileRef = 084A20872202E4FD00428FF5 /* flutter go.png */; };
|
||||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
|
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
|
||||||
|
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
|
||||||
333E5DAE7FC10AC69FEC26C0 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DDA792F029EDD7A11295D192 /* libPods-Runner.a */; };
|
333E5DAE7FC10AC69FEC26C0 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DDA792F029EDD7A11295D192 /* libPods-Runner.a */; };
|
||||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
||||||
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
|
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
|
||||||
@ -42,6 +43,7 @@
|
|||||||
084A20872202E4FD00428FF5 /* flutter go.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "flutter go.png"; sourceTree = "<group>"; };
|
084A20872202E4FD00428FF5 /* flutter go.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "flutter go.png"; sourceTree = "<group>"; };
|
||||||
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
|
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
|
||||||
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
|
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
|
||||||
|
2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
|
||||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
|
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
|
||||||
2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
|
2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
|
||||||
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
|
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
|
||||||
@ -453,7 +455,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"$(PROJECT_DIR)/Flutter",
|
"$(PROJECT_DIR)/Flutter",
|
||||||
);
|
);
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterRookieBook;
|
PRODUCT_BUNDLE_IDENTIFIER = com.ali.flutterRookieBook;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
VERSIONING_SYSTEM = "apple-generic";
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
};
|
};
|
||||||
@ -477,7 +479,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"$(PROJECT_DIR)/Flutter",
|
"$(PROJECT_DIR)/Flutter",
|
||||||
);
|
);
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterRookieBook;
|
PRODUCT_BUNDLE_IDENTIFIER = com.ali.flutterRookieBook;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
VERSIONING_SYSTEM = "apple-generic";
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
};
|
};
|
||||||
|
@ -24,8 +24,10 @@
|
|||||||
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" image="LaunchImage" translatesAutoresizingMaskIntoConstraints="NO" id="YRO-k0-Ey4">
|
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" image="LaunchImage" translatesAutoresizingMaskIntoConstraints="NO" id="YRO-k0-Ey4">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="1080" height="1920"/>
|
<rect key="frame" x="0.0" y="0.0" width="1080" height="1920"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
|
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="1920" id="OLo-sE-hO2"/>
|
||||||
<constraint firstAttribute="height" constant="1920" id="YT6-bb-oIb"/>
|
<constraint firstAttribute="height" constant="1920" id="YT6-bb-oIb"/>
|
||||||
<constraint firstAttribute="width" constant="1080" id="n6M-3x-zje"/>
|
<constraint firstAttribute="width" constant="1080" id="n6M-3x-zje"/>
|
||||||
|
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="1080" id="qQn-AH-FYP"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
</imageView>
|
</imageView>
|
||||||
</subviews>
|
</subviews>
|
||||||
|
@ -4,10 +4,13 @@ import 'package:flutter/rendering.dart';
|
|||||||
import 'routers/routers.dart';
|
import 'routers/routers.dart';
|
||||||
import 'routers/application.dart';
|
import 'routers/application.dart';
|
||||||
import 'package:flutter_go/utils/provider.dart';
|
import 'package:flutter_go/utils/provider.dart';
|
||||||
|
import 'package:flutter_go/utils/shared_preferences.dart';
|
||||||
|
import 'package:flutter_go/views/first_page/home.dart';
|
||||||
import 'views/welcome_page/index.dart';
|
import 'views/welcome_page/index.dart';
|
||||||
|
|
||||||
const int ThemeColor = 0xFFC91B3A;
|
const int ThemeColor = 0xFFC91B3A;
|
||||||
|
SpUtil sp;
|
||||||
|
var db;
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
MyApp() {
|
MyApp() {
|
||||||
@ -15,9 +18,17 @@ class MyApp extends StatelessWidget {
|
|||||||
Routes.configureRoutes(router);
|
Routes.configureRoutes(router);
|
||||||
Application.router = router;
|
Application.router = router;
|
||||||
}
|
}
|
||||||
|
showWelcomePage() {
|
||||||
|
bool showWelcome = sp.getBool(sharedPreferencesKeys.showWelcome);
|
||||||
|
if (showWelcome == null || showWelcome == true) {
|
||||||
|
return WelcomePage();
|
||||||
|
} else {
|
||||||
|
return AppPage();
|
||||||
|
}
|
||||||
|
}
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
showWelcomePage();
|
||||||
return new MaterialApp(
|
return new MaterialApp(
|
||||||
title: 'title',
|
title: 'title',
|
||||||
theme: new ThemeData(
|
theme: new ThemeData(
|
||||||
@ -34,18 +45,18 @@ class MyApp extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
home: new Scaffold(
|
home: new Scaffold(
|
||||||
body: new WelcomePage(),
|
body: showWelcomePage()
|
||||||
),
|
),
|
||||||
onGenerateRoute: Application.router.generator,
|
onGenerateRoute: Application.router.generator,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var db;
|
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
final provider = new Provider();
|
final provider = new Provider();
|
||||||
await provider.init(true);
|
await provider.init(true);
|
||||||
|
sp = await SpUtil.getInstance();
|
||||||
db = Provider.db;
|
db = Provider.db;
|
||||||
runApp(new MyApp());
|
runApp(new MyApp());
|
||||||
}
|
}
|
||||||
|
@ -7,15 +7,24 @@
|
|||||||
* tartget: xxx
|
* tartget: xxx
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
//enum DateType {
|
||||||
|
// Int,
|
||||||
|
// Double,
|
||||||
|
// Bool,
|
||||||
|
// String,
|
||||||
|
// Dynamic
|
||||||
|
//}
|
||||||
|
|
||||||
class Demo extends StatefulWidget {
|
//class spKey {
|
||||||
_Demo createState() => _Demo();
|
// String name;
|
||||||
|
// DateType type;
|
||||||
|
//
|
||||||
|
// spKey({this.name, this.type});
|
||||||
|
//}
|
||||||
|
|
||||||
|
class sharedPreferencesKeys {
|
||||||
|
/// boolean
|
||||||
|
/// 用于欢迎页面. 只有第一次访问才会显示. 或者手动将这个值设为false
|
||||||
|
static String showWelcome = 'loginWelcone';
|
||||||
}
|
}
|
||||||
|
|
||||||
class _Demo extends State<Demo> {
|
|
||||||
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Container();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
import 'package:fluro/fluro.dart';
|
import 'package:fluro/fluro.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_go/utils/shared_preferences.dart';
|
||||||
class Application {
|
class Application {
|
||||||
static Router router;
|
static Router router;
|
||||||
static TabController controller;
|
static TabController controller;
|
||||||
|
static SpUtil sharePeferences;
|
||||||
|
|
||||||
static Map<String, String> github = {
|
static Map<String, String> github = {
|
||||||
'widgetsURL':'https://github.com/alibaba/flutter-go/blob/develop/lib/widgets/',
|
'widgetsURL':'https://github.com/alibaba/flutter-go/blob/develop/lib/widgets/',
|
||||||
//'develop':'https://github.com/alibaba-paimai-frontend/flutter-common-widgets-app/tree/develop/lib/widgets/',
|
//'develop':'https://github.com/alibaba-paimai-frontend/flutter-common-widgets-app/tree/develop/lib/widgets/',
|
||||||
|
@ -0,0 +1,119 @@
|
|||||||
|
|
||||||
|
import 'dart:async';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
export 'package:flutter_go/resources/shared_preferences_keys.dart';
|
||||||
|
///
|
||||||
|
/// 用来做shared_preferences的存储
|
||||||
|
class SpUtil {
|
||||||
|
static SpUtil _instance;
|
||||||
|
static Future<SpUtil> get instance async {
|
||||||
|
return await getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
static SharedPreferences _spf;
|
||||||
|
|
||||||
|
|
||||||
|
SpUtil._();
|
||||||
|
|
||||||
|
Future _init() async {
|
||||||
|
_spf = await SharedPreferences.getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<SpUtil> getInstance() async {
|
||||||
|
print("_instance>>$_instance");
|
||||||
|
if (_instance == null) {
|
||||||
|
_instance = new SpUtil._();
|
||||||
|
await _instance._init();
|
||||||
|
|
||||||
|
}
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool _beforCheck() {
|
||||||
|
if (_spf == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 判断是否存在数据
|
||||||
|
bool hasKey(String key) {
|
||||||
|
Set keys = getKeys();
|
||||||
|
return keys.contains(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<String> getKeys() {
|
||||||
|
if (_beforCheck()) return null;
|
||||||
|
return _spf.getKeys();
|
||||||
|
}
|
||||||
|
|
||||||
|
get(String key) {
|
||||||
|
if (_beforCheck()) return null;
|
||||||
|
return _spf.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
getString(String key) {
|
||||||
|
if (_beforCheck()) return null;
|
||||||
|
return _spf.getString(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> putString(String key, String value) {
|
||||||
|
if (_beforCheck()) return null;
|
||||||
|
return _spf.setString(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool getBool(String key) {
|
||||||
|
if (_beforCheck()) return null;
|
||||||
|
return _spf.getBool(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> putBool(String key, bool value) {
|
||||||
|
if (_beforCheck()) return null;
|
||||||
|
return _spf.setBool(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
int getInt(String key) {
|
||||||
|
if (_beforCheck()) return null;
|
||||||
|
return _spf.getInt(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> putInt(String key, int value) {
|
||||||
|
if (_beforCheck()) return null;
|
||||||
|
return _spf.setInt(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
double getDouble(String key) {
|
||||||
|
if (_beforCheck()) return null;
|
||||||
|
return _spf.getDouble(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> putDouble(String key, double value) {
|
||||||
|
if (_beforCheck()) return null;
|
||||||
|
return _spf.setDouble(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> getStringList(String key) {
|
||||||
|
return _spf.getStringList(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> putStringList(String key, List<String> value) {
|
||||||
|
if (_beforCheck()) return null;
|
||||||
|
return _spf.setStringList(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
dynamic getDynamic(String key) {
|
||||||
|
if (_beforCheck()) return null;
|
||||||
|
return _spf.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Future<bool> remove(String key) {
|
||||||
|
if (_beforCheck()) return null;
|
||||||
|
return _spf.remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> clear() {
|
||||||
|
if (_beforCheck()) return null;
|
||||||
|
return _spf.clear();
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import '../../routers/application.dart';
|
import '../../routers/application.dart';
|
||||||
import '../../routers/routers.dart';
|
import '../../routers/routers.dart';
|
||||||
|
import '../../utils/shared_preferences.dart';
|
||||||
|
|
||||||
final pages = [
|
final pages = [
|
||||||
new PageViewModel(
|
new PageViewModel(
|
||||||
@ -30,7 +31,7 @@ final pages = [
|
|||||||
class Page extends StatelessWidget {
|
class Page extends StatelessWidget {
|
||||||
final PageViewModel viewModel;
|
final PageViewModel viewModel;
|
||||||
final double percentVisible;
|
final double percentVisible;
|
||||||
|
SpUtil sp;
|
||||||
Page({
|
Page({
|
||||||
this.viewModel,
|
this.viewModel,
|
||||||
this.percentVisible = 1.0,
|
this.percentVisible = 1.0,
|
||||||
@ -43,8 +44,10 @@ class Page extends StatelessWidget {
|
|||||||
Widget creatButton(
|
Widget creatButton(
|
||||||
BuildContext context, String txt, IconData iconName, String type) {
|
BuildContext context, String txt, IconData iconName, String type) {
|
||||||
return RaisedButton.icon(
|
return RaisedButton.icon(
|
||||||
onPressed: () {
|
onPressed: () async {
|
||||||
if (type == 'start') {
|
if (type == 'start') {
|
||||||
|
await SpUtil.getInstance()
|
||||||
|
..putBool(sharedPreferencesKeys.showWelcome, false);
|
||||||
_goHomePage(context);
|
_goHomePage(context);
|
||||||
} else if (type == 'goGithub') {
|
} else if (type == 'goGithub') {
|
||||||
Application.router.navigateTo(context,
|
Application.router.navigateTo(context,
|
||||||
|
Reference in New Issue
Block a user