Commit bb45d9f5 authored by 林生雨's avatar 林生雨

commit

parent a3c1ac2a
......@@ -70,7 +70,9 @@ class MainActivity : FlutterActivity() {
result.success(map)
} else if (call.method == "UPLOAD_IMG") {
result.success("2019/10/17/1156/44dbb13ac6d9");
} else {
} else if(call.method =="USER_LOGOUT"){
result.success(true)
}else {
result.notImplemented()
}
}
......
......@@ -56,6 +56,7 @@ function android_apk(){
cd /Users/apple/lsy/gmalpha_flutter/build/app/outputs/apk/${suff}/
unzip /Users/apple/lsy/gmalpha_flutter/build/app/outputs/apk/${suff}/app-${suff}.zip
cp -r /Users/apple/lsy/gmalpha_flutter/build/app/outputs/apk/${suff}/lib/armeabi-v7a/libapp.so /Users/apple/lsy/gengmei_alpha/alpha/libs/armeabi-v7a
cp -r /Users/apple/lsy/gmalpha_flutter/build/app/outputs/apk/${suff}/lib/armeabi-v7a/libflutter.so /Users/apple/lsy/gengmei_alpha/alpha/libs/armeabi-v7a
rm -rf /Users/apple/lsy/gengmei_alpha/alpha/src/main/assets/flutter_assets
cp -r /Users/apple/lsy/gmalpha_flutter/build/app/outputs/apk/${suff}/assets/flutter_assets /Users/apple/lsy/gengmei_alpha/alpha/src/main/assets/
......@@ -127,8 +128,8 @@ function upload_android_aar(){
./gradlew clean
./gradlew assembleRelease
./gradlew uploadArchives
cp -r /Users/apple/lsy/MergeTest/app/build/outputs/aar/app.aar /Users/apple/lsy/Test/app/libs/
cp -r /Users/apple/lsy/MergeTest/app/build/outputs/aar/app.aar /Users/apple/lsy/gmalpha_flutter/build/
# cp -r /Users/apple/lsy/MergeTest/app/build/outputs/aar/app.aar /Users/apple/lsy/Test/app/libs/
# cp -r /Users/apple/lsy/MergeTest/app/build/outputs/aar/app.aar /Users/apple/lsy/gmalpha_flutter/build/
cd /Users/apple/lsy/flutter_aar
git add .
......@@ -142,6 +143,7 @@ function upload_android_aar(){
function ios(){
cd ${projectDir}
flutter build ios --release --no-codesign
lipo -remove x86_64 /Users/apple/lsy/gmalpha_flutter/ios/Flutter/Flutter.framework/Flutter -o /Users/apple/lsy/gmalpha_flutter/ios/Flutter/Flutter.framework/Flutter
cp -r /Users/apple/lsy/gmalpha_flutter/ios/Flutter/App.framework /Users/apple/lsy/aar_update/ios${message}/
rm -rf /Users/apple/lsy/GMAlpha/GMAlpha/Classes/APP/flutter_project/App.framework
rm -rf /Users/apple/lsy/GMAlpha/GMAlpha/Classes/APP/flutter_project/Flutter.framework
......@@ -234,11 +236,11 @@ mkdir /Users/apple/lsy/aar_update/androd${message}/
mkdir /Users/apple/lsy/aar_update/ios${message}/
clean
#android_apk
android_apk
#android
#android_publish
#upload_android_aar
ios
#ios
#ios_publish
#notifyDingDing
......
......@@ -52,7 +52,12 @@ class UserGenerator extends GeneratorForAnnotation<UserCenter> {
if(_${fieldData.name}!=null){
return Observable.fromFuture(Future.value(_${fieldData.name}));
}
return Observable.fromFuture(spUtil.getStringKv("${key}"));
return Observable.fromFuture(spUtil.getStringKv("${key}")).map((value){
if(value==""){
return null;
}
return value;
});
}
""");
} else if (type == "int") {
......
......@@ -27,8 +27,8 @@ class BuriedImpl implements BuriedRouter {
}
@override
void onEvent(String type, Map<String, String> params) async{
await BuriedCenter.getInstance().onEvent(type, params);
void onEvent(String type, Map<String, String> params) {
BuriedCenter.getInstance().onEvent(type, params);
print("lsy !! ON EVENT --> ");
}
......
......@@ -9,6 +9,7 @@ import 'package:gmalpha_flutter/Annotations/RouterCenterRestore.mark.dart';
import 'package:gmalpha_flutter/PrestigeModel/page/reputation/ReputationsModel.dart';
import 'package:gmalpha_flutter/PrestigeModel/service/remote/entity/PrestigeEntity.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:gmalpha_flutter/commonModel/base/BaseComponent.dart';
import 'package:gmalpha_flutter/commonModel/base/BasePage.dart';
import 'package:flutter_svg/flutter_svg.dart';
......@@ -41,8 +42,8 @@ class ReputationsState extends BasePage<ReputationsPage> {
screenWidth = MediaQuery.of(context).size.width;
return WillPopScope(
child: Scaffold(
appBar: AppBar(
elevation: 0.0,
appBar:
baseAppBarChangeTitle(
title: StreamBuilder<String>(
stream: _model.titleLive.stream,
initialData: _model.titleLive.data,
......@@ -58,19 +59,10 @@ class ReputationsState extends BasePage<ReputationsPage> {
},
),
centerTitle: true,
leading: GestureDetector(
onTap: () {
backClick: () {
_model.pop(context, pageName());
},
child: Container(
alignment: Alignment.centerLeft,
padding: EdgeInsets.only(left: 22),
width: 30,
height: double.maxFinite,
child: SvgPicture.asset("images/left_arrow.svg",
color: Color(0xff323232)),
),
)),
body: StreamBuilder<PrestigeEntity>(
stream: _model.prestigeLive.stream,
initialData: _model.prestigeLive.data,
......
......@@ -13,7 +13,7 @@ class TestPage extends StatelessWidget {
TestPage() {
Api.getInstance().setDioCookie({
'Cookie':
'sessionid=ptudnleishg9tkizlcf8k1nna4fclncc;_gtid=daf0b158ee3211e9ab2e525400e82fab3575;_gm_token=7600f21571024088'
'sessionid=ley6ne6wdi3w4sapyqgwa5mtjberyaum;_gtid=d7fdc2def3b311e99a80525400e82fab3556;_gm_token=4ab9e41571629122'
});
}
......
......@@ -15,3 +15,5 @@ export 'net/Api.dart';
export 'net/DioUtil.dart';
export 'net/Responce/SimpleResponce.dart';
export 'net/ALNetWork.dart';
export 'picker/loadingPicker.dart';
export 'picker/base/BaseCenterPicker.dart';
......@@ -2,7 +2,10 @@
* @author lsy
* @date 2019-09-24
**/
import 'dart:async';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:gmalpha_flutter/commonModel/cache/CacheManager.dart';
import 'package:gmalpha_flutter/commonModel/net/Api.dart';
......@@ -13,6 +16,7 @@ const BURIED_METHOD = "FLUTTER_BURIED";
const NET_TYPE = "GET_NET_TYPE";
const INIT_PARAMS = "INIT_PARAMS";
const UPLOAD_IMG = "UPLOAD_IMG";
const USER_LOGOUT = "USER_LOGOUT";
const platform = const MethodChannel('flutter_bury_channel');
void jumpToH5(String jumpToName, Map params) {
......@@ -39,8 +43,13 @@ Observable getNetType() {
return Observable.fromFuture(platform.invokeMethod(NET_TYPE, null));
}
Observable<String> uploadImg(String path,String token) {
return Observable.fromFuture(platform.invokeMethod(UPLOAD_IMG, {"path":path,"token":token}));
Observable<String> uploadImg(String path, String token) {
return Observable.fromFuture(
platform.invokeMethod(UPLOAD_IMG, {"path": path, "token": token}));
}
Observable<bool> userLogout() {
return Observable.fromFuture(platform.invokeMethod(USER_LOGOUT));
}
void initParams(VoidCallback callback) {
......@@ -61,11 +70,43 @@ void initBuried(VoidCallback call) {
CacheManager.getInstance().get(MEMORY_CACHE).save(k, v);
});
call();
// catchAllError();
}).catchError((error) {
print(error);
});
}
void catchAllError(VoidCallback call) {
FlutterError.onError = (FlutterErrorDetails details) {
reportErrorAndLog(details);
};
runZoned(
() => call(),
zoneSpecification: ZoneSpecification(
print: (Zone self, ZoneDelegate parent, Zone zone, String line) {
collectLog(line); // 收集日志
},
),
onError: (Object obj, StackTrace stack) {
var details = makeDetails(obj, stack);
reportErrorAndLog(details);
},
);
}
void collectLog(String line) {
//收集日志
}
void reportErrorAndLog(FlutterErrorDetails details) {
//上报错误和日志逻辑
}
FlutterErrorDetails makeDetails(Object obj, StackTrace stack) {
// 构建错误信息
}
String getNowTimeSecond() {
return "${DateTime.now().millisecondsSinceEpoch}";
// String year = "${DateTime.now().year}".length == 4
......
......@@ -13,8 +13,22 @@ AppBar baseAppBar(
List<Widget> action,
bool centerTitle,
VoidCallback backClick}) {
return baseAppBarChangeTitle(
title: title == null
? Container()
: baseText(title, 16, ALColors.Color323232),
action: action,
centerTitle: centerTitle,
backClick: backClick);
}
AppBar baseAppBarChangeTitle(
{Widget title,
List<Widget> action,
bool centerTitle,
VoidCallback backClick}) {
return AppBar(
title: title == null ? Container() : baseText(title, 16, ALColors.Color323232),
title: title,
centerTitle: centerTitle,
elevation: 0.0,
leading: GestureDetector(
......@@ -24,10 +38,12 @@ AppBar baseAppBar(
padding: EdgeInsets.only(left: 22),
width: 30,
height: double.maxFinite,
child: Hero(
tag: "left_arrow",
child: SvgPicture.asset(
"images/left_arrow.svg",
color: Color(0xff323232),
)),
))),
),
actions: action == null ? List<Widget>() : action,
);
......@@ -40,7 +56,10 @@ Text baseText(String text, double fontSize, Color color) {
);
}
Widget baseDivide(double height, int padding, Color color) {
/**
* 基础的liveView分割线
*/
Widget baseDivide(double height, double padding, Color color) {
return Container(
height: height,
margin: EdgeInsets.only(
......
......@@ -2,6 +2,8 @@
* @author lsy
* @date 2019-10-08
**/
import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:gmalpha_flutter/Annotations/RouterCenterRestore.mark.dart';
......@@ -9,6 +11,9 @@ import 'package:gmalpha_flutter/Annotations/RouterCenterRestore.mark.dart';
abstract class BasePage<T extends StatefulWidget> extends State<T> {
var startTime;
double screenWidth = window.physicalSize.width;
double screenHeight = window.physicalSize.height;
String pageName();
String referrer();
......
......@@ -8,8 +8,6 @@ import 'dart:ui';
import 'package:flutter/material.dart';
double screenWidth = window.physicalSize.width;
double screenHeight = window.physicalSize.height;
void jumpToPage(Widget page, BuildContext context) {
Navigator.push(context, MaterialPageRoute(builder: ((context) {
......
......@@ -3,23 +3,47 @@
* @date 2019-09-05
**/
class SimpleResponce {
Null data;
int errorCode;
String errorMsg;
int error;
String message;
Null extra;
Data data;
SimpleResponce({this.data, this.errorCode, this.errorMsg});
SimpleResponce({this.error, this.message, this.extra, this.data});
SimpleResponce.fromJson(Map<String, dynamic> json) {
data = json['data'];
errorCode = json['errorCode'];
errorMsg = json['errorMsg'];
error = json['error'];
message = json['message'];
extra = json['extra'];
data = json['data'] != null ? new Data.fromJson(json['data']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['data'] = this.data;
data['errorCode'] = this.errorCode;
data['errorMsg'] = this.errorMsg;
data['error'] = this.error;
data['message'] = this.message;
data['extra'] = this.extra;
if (this.data != null) {
data['data'] = this.data.toJson();
}
return data;
}
}
class Data {
int error;
String message;
Data({this.error, this.message});
Data.fromJson(Map<String, dynamic> json) {
error = json['error'];
message = json['message'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['error'] = this.error;
data['message'] = this.message;
return data;
}
}
/*
* @author lsy
* @date 2019-10-18
**/
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:gmalpha_flutter/ActivityReportModel/page/ActivityReportPage.dart';
import 'package:gmalpha_flutter/commonModel/picker/base/DialogRouter.dart';
class BaseCenterPicker extends StatefulWidget {
BaseCenterPickerState centerState;
ICenterPicker picker;
bool cancelOutSide = true;
setPicker(ICenterPicker picker) {
this.picker = picker;
centerState?.setState(() {});
}
setCancelOutside(bool cancel) {
this.cancelOutSide = cancel;
centerState?.setState(() {});
}
show(BuildContext context) {
Navigator.push(context, DialogRouter(this));
}
dismiss(BuildContext context) {
Navigator.pop(context);
}
@override
State<StatefulWidget> createState() {
centerState = BaseCenterPickerState();
return centerState;
}
}
class BaseCenterPickerState extends State<BaseCenterPicker> {
@override
Widget build(BuildContext context) {
ScreenUtil.instance = ScreenUtil(width: 375, height: 667)..init(context);
return Container(
color: Colors.black54,
width: double.maxFinite,
height: double.maxFinite,
child: Stack(
children: <Widget>[
GestureDetector(
onTap: () {
if (widget.cancelOutSide) {
widget.dismiss(context);
}
},
),
Center(
child: Material(
color: Colors.transparent,
child: widget.picker.build(context),
))
],
),
);
}
}
abstract class ICenterPicker {
Widget build(BuildContext context);
}
/*
* @author lsy
* @date 2019-10-21
**/
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:gmalpha_flutter/commonModel/GMBase.dart';
class BaseLoadingItem implements ICenterPicker {
final String loadingText;
BaseLoadingItem(this.loadingText);
@override
Widget build(BuildContext context) {
return Center(
///弹框大小
child: new Container(
width: 120.0,
height: 120.0,
child: new Container(
///弹框背景和圆角
decoration: ShapeDecoration(
color: Color(0xffffffff),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(8.0),
),
),
),
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
new CircularProgressIndicator(),
new Padding(
padding: const EdgeInsets.only(
top: 20.0,
),
child: new Text(
loadingText,
style: new TextStyle(fontSize: 16.0),
),
),
],
),
),
),
);
}
}
/*
* @author lsy
* @date 2019-10-18
**/
import 'package:flutter/material.dart';
class DialogRouter extends PageRouteBuilder {
final Widget page;
DialogRouter(this.page)
: super(
opaque: false,
pageBuilder: (context, animation, secondaryAnimation) => page,
transitionsBuilder:
(context, animation, secondaryAnimation, child) {
return child;
});
}
/*
* @author lsy
* @date 2019-10-18
**/
import 'package:flutter/material.dart';
import 'package:gmalpha_flutter/commonModel/picker/base/DialogRouter.dart';
Future popLoadingDialog(
BuildContext context, bool canceledOnTouchOutside, String text) {
return Navigator.push(
context, DialogRouter(LoadingDialog(canceledOnTouchOutside, text)));
}
void dismissLoadingDialog(BuildContext context) {
Navigator.pop(context);
}
class LoadingDialog extends Dialog {
LoadingDialog(this.canceledOnTouchOutside, this.text) : super();
///点击背景是否能够退出
final bool canceledOnTouchOutside;
final String text;
@override
Widget build(BuildContext context) {
return Center(
child: new Material(
///背景透明
color: Colors.black54,
///保证控件居中效果
child: Stack(
children: <Widget>[
GestureDetector(
///点击事件
onTap: () {
if (canceledOnTouchOutside) {
Navigator.pop(context);
}
},
),
_dialog()
],
)),
);
}
Widget _dialog() {
return new Center(
///弹框大小
child: new Container(
width: 120.0,
height: 120.0,
child: new Container(
///弹框背景和圆角
decoration: ShapeDecoration(
color: Color(0xffffffff),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(8.0),
),
),
),
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
new CircularProgressIndicator(),
new Padding(
padding: const EdgeInsets.only(
top: 20.0,
),
child: new Text(
text,
style: new TextStyle(fontSize: 16.0),
),
),
],
),
),
),
);
}
}
import 'dart:async';
import 'dart:convert';
import 'package:flutter/material.dart';
......@@ -14,6 +15,7 @@ import 'commonModel/GMBase.dart';
void main() {
initParams(() => runApp(MyApp()));
}
class MyApp extends StatefulWidget {
......@@ -22,6 +24,13 @@ class MyApp extends StatefulWidget {
}
class _MyAppState extends State<MyApp> {
var buildOnce = FlutterBoost.init(
postPush: (String pageName, String uniqueId, Map params, Route route,
Future _) {
print("FLUTTER PUSHED $pageName");
});
@override
void initState() {
super.initState();
......@@ -92,23 +101,16 @@ class _MyAppState extends State<MyApp> {
FlutterBoost.handleOnStartPage();
}
bool isBuildMain = false;
var buildOnce = FlutterBoost.init();
@override
Widget build(BuildContext context) {
RouterCenterImpl().findBuriedRouter()?.onEvent("Test", null);
RouterCenterImpl().findBuriedRouter()?.onEvent("Test", null);
print("lsy BUILD!!");
return MaterialApp(
title: 'Flutter Boost example',
debugShowCheckedModeBanner: false,
// routes: {
// '/': (context) {
// return TestPage();
// },
// },
routes: {
'/': (context) {
return TestPage();
},
},
builder: buildOnce,
theme: new ThemeData(
primaryColor: Colors.white,
......@@ -125,9 +127,4 @@ class _MyAppState extends State<MyApp> {
),
);
}
void _onRoutePushed(
String pageName, String uniqueId, Map params, Route route, Future _) {
print("PUSHED $pageName");
}
}
......@@ -5,52 +5,63 @@
import 'package:flutter/material.dart';
class CustomRoute extends PageRouteBuilder{
enum RouteWay {
SCARE,
TRAN_RIGHT_TO_LEFT,
ALP,
}
class CustomRoute extends PageRouteBuilder {
final Widget widget;
CustomRoute(this.widget)
:super(
RouteWay routeWay;
CustomRoute(this.widget, {RouteWay routeWay = RouteWay.TRAN_RIGHT_TO_LEFT})
: super(
// 设置过度时间
transitionDuration:Duration(milliseconds: 200),
transitionDuration: Duration(milliseconds: 200),
// 构造器
pageBuilder:(
pageBuilder: (
// 上下文和动画
BuildContext context,
Animation<double> animaton1,
Animation<double> animaton2,
){
) {
return widget;
},
transitionsBuilder:(
transitionsBuilder: (
BuildContext context,
Animation<double> animaton1,
Animation<double> animaton2,
Widget child,
){
// 需要什么效果把注释打开就行了
) {
// 渐变效果
// return FadeTransition(
// // 从0开始到1
// opacity: Tween(begin: 0.0,end: 1.0)
// .animate(CurvedAnimation(
// // 传入设置的动画
// parent: animaton1,
// // 设置效果,快进漫出 这里有很多内置的效果
// curve: Curves.fastOutSlowIn,
// )),
// child: child,
// );
// 缩放动画效果
// return ScaleTransition(
// scale: Tween(begin: 0.0,end: 1.0).animate(CurvedAnimation(
// parent: animaton1,
// curve: Curves.fastOutSlowIn
// )),
// child: child,
// );
if (routeWay.index == 2) {
return FadeTransition(
// 从0开始到1
opacity: Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation(
// 传入设置的动画
parent: animaton1,
// 设置效果,快进漫出 这里有很多内置的效果
curve: Curves.fastOutSlowIn,
)),
child: child,
);
} else if (routeWay.index == 1) {
return SlideTransition(
position: Tween<Offset>(
begin: Offset(1.0, 0.0), end: Offset(0.0, 0.0))
.animate(CurvedAnimation(
parent: animaton1, curve: Curves.fastOutSlowIn)),
child: child,
);
} else {
return ScaleTransition(
scale: Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: animaton1, curve: Curves.fastOutSlowIn)),
child: child,
);
}
// 旋转加缩放动画效果
// return RotationTransition(
// turns: Tween(begin: 0.0,end: 1.0)
......@@ -67,19 +78,5 @@ class CustomRoute extends PageRouteBuilder{
// child: child,
// ),
// );
// 左右滑动动画效果
return SlideTransition(
position: Tween<Offset>(
// 设置滑动的 X , Y 轴
begin: Offset(1.0, 0.0),
end: Offset(0.0,0.0)
).animate(CurvedAnimation(
parent: animaton1,
curve: Curves.fastOutSlowIn
)),
child: child,
);
}
);
});
}
......@@ -23,4 +23,8 @@ class ALColors {
static const Color ColorF4F3F8 = Color(0xFFf4f3f8);
static const Color Color282828 = Color(0xFF282828);
static const Color ColorE5E5E5 = Color(0xFFe5e5e5);
static const Color Color5276F4 = Color(0xFF5276F4);
static const Color Color0093FF = Color(0xFF0093FF);
}
......@@ -94,7 +94,7 @@ class CountryState extends BasePage {
return GestureDetector(
onTap: () {
Navigator.pop(context,
{"countryId": country.name, "countryName": country.name});
{"countryId": country.id, "countryName": country.name});
},
child: Container(
alignment: Alignment.centerLeft,
......
......@@ -3,21 +3,17 @@
* @date 2019-09-04
**/
import 'dart:math';
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:gmalpha_flutter/Annotations/RouterCenterRestore.mark.dart';
import 'package:gmalpha_flutter/commonModel/GMBase.dart';
import 'package:gmalpha_flutter/commonModel/base/BaseUtil.dart';
import 'package:gmalpha_flutter/commonModel/live/BaseModel.dart';
import 'package:gmalpha_flutter/commonModel/net/Api.dart';
import 'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.dart';
import 'package:gmalpha_flutter/commonModel/picker/loadingPicker.dart';
import 'package:gmalpha_flutter/commonModel/toast/toast.dart';
import 'package:gmalpha_flutter/userModel/service/UserRepository.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.user.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.user.dart' as prefix0;
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserResultBean.dart';
import 'package:gmalpha_flutter/userModel/util/JumpUtil.dart';
import '../../../commonModel/live/LiveData.dart';
......@@ -37,7 +33,7 @@ class UserSettingModel extends BaseModel {
init(BuildContext context) {
UserEntityImpl().getuserId().listen((value) {
print("VALUEE $value");
if (value == null || value != userid) {
if (value == null || value != userid || value == "") {
UserRepository.getInstance().getUserInfo(userid).listen((data) {
print(data);
nameLive.notifyView(data?.data?.nickName);
......@@ -49,7 +45,7 @@ class UserSettingModel extends BaseModel {
age = data?.data?.age;
}).onError((error) {
print(error);
Toast.show(context, error);
Toast.show(context, error.toString());
});
} else {
UserEntityImpl().getage().listen((data) {
......@@ -129,21 +125,43 @@ class UserSettingModel extends BaseModel {
void jumpToCTY(BuildContext context, String pageName) {
jumpToCountry(context, pageName).then((value) {
if (value != null) {
print("COUNTRY $value");
cityId = value["countryId"];
cityLive.notifyView(value["countryName"]);
detectUpdate();
}
}).catchError((error) {
Toast.debugShow(context, error);
Toast.debugShow(context, error.toString());
print(error);
});
}
void quit(BuildContext context, String pageName) {
void quit(BuildContext context, String pageName, VoidCallback dismiss) {
clickEvent(pageName, "quit");
UserRepository.getInstance().userLogout(userid).listen((value) {
if (value != null) {
quitNative(context, dismiss);
}
}).onError((error) {
Toast.debugShow(context, error);
print(error);
});
}
void quitNative(BuildContext context, VoidCallback dismiss) {
userLogout().listen((value) {
if (value) {
dismiss();
Navigator.pop(context);
}
}).onError((error) {
Toast.debugShow(context, error);
print(error);
});
}
void save(BuildContext context) {
popLoadingDialog(context, true, "加载中");
if (selectImgPath != null) {
UserRepository.getInstance().getUploadToken(1).listen((data) {
uploadImage(context, data.data?.token);
......@@ -151,8 +169,8 @@ class UserSettingModel extends BaseModel {
Toast.show(context, "网络错误");
print(error);
});
}else{
settingInfo(context,headImgLive.data,nameLive.data,cityId);
} else {
settingInfo(context, headImgLive.data, nameLive.data, cityId);
}
}
......@@ -163,7 +181,8 @@ class UserSettingModel extends BaseModel {
uploadImg(selectImgPath, token).listen((value) {
print("UPLOAD --> $value");
if (value != null) {
settingInfo(context, "http://alpha.iyanzhi.com/${value}-w", nameLive.data, cityId);
settingInfo(context, "http://alpha.iyanzhi.com/${value}-w",
nameLive.data, cityId);
} else {
Toast.show(context, "上传失败");
}
......@@ -174,18 +193,21 @@ class UserSettingModel extends BaseModel {
}
}
void settingInfo(BuildContext context, String head, String name,
String countryId) {
UserRepository.getInstance().settingUserInfo(
countryId, name, head, userid, age
).listen((data) {
void settingInfo(
BuildContext context, String head, String name, String countryId) {
UserRepository.getInstance()
.settingUserInfo(countryId, name, head, userid, age)
.listen((data) {
if (data != null) {
dismissLoadingDialog(context);
UserEntityImpl().saveage(data?.data?.age);
UserEntityImpl().saveprofilePic(head);
UserEntityImpl().savenickName(name);
UserEntityImpl().savecountryInfoId(countryId);
Toast.show(context, "保存成功");
UserEntityImpl().savecountryInfoName(cityLive.data);
Timer(Duration(milliseconds: 390), () {
Navigator.pop(context);
});
} else {
Toast.show(context, "保存失败");
}
......@@ -194,4 +216,11 @@ class UserSettingModel extends BaseModel {
print(e);
});
}
void onNameChange(String text) {
if (text != null && text.isNotEmpty) {
nameLive.data = text;
detectUpdate();
}
}
}
......@@ -3,6 +3,7 @@
* @date 2019-09-04
**/
import 'dart:async';
import 'dart:io';
import 'package:cached_network_image/cached_network_image.dart';
......@@ -14,6 +15,7 @@ import 'package:gmalpha_flutter/commonModel/base/BaseBuried.dart';
import 'package:gmalpha_flutter/commonModel/base/BaseComponent.dart';
import 'package:gmalpha_flutter/commonModel/base/BasePage.dart';
import 'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.dart';
import 'package:gmalpha_flutter/commonModel/picker/base/BasePickerComponent.dart';
import 'package:gmalpha_flutter/res/GMRes.dart';
import 'package:gmalpha_flutter/userModel/page/userSetting/UserSettingModel.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/TestUserEntity.dart';
......@@ -33,6 +35,10 @@ class UserSettingPage extends StatefulWidget {
class UserState extends BasePage<UserSettingPage> {
final UserSettingModel _model;
TextEditingController _controller = new TextEditingController();
BaseCenterPicker logoutPicker;
BaseLoadingItem baseLoadingItem;
UserLogoutPicker userLogoutPicker;
UserState(this._model);
......@@ -40,12 +46,27 @@ class UserState extends BasePage<UserSettingPage> {
void initState() {
super.initState();
_model.init(context);
_controller.addListener(() {
_model.onNameChange(_controller.text);
});
logoutPicker = BaseCenterPicker();
baseLoadingItem = BaseLoadingItem("加载中");
userLogoutPicker = UserLogoutPicker(() {
logoutPicker.setPicker(baseLoadingItem);
_model.quit(context, pageName(), () {
logoutPicker.dismiss(context);
});
}, () {
logoutPicker.dismiss(context);
});
logoutPicker.setPicker(userLogoutPicker);
}
@override
void dispose() {
super.dispose();
_model.dispose();
_controller?.dispose();
}
@override
......@@ -124,8 +145,17 @@ class UserState extends BasePage<UserSettingPage> {
height: ScreenUtil.instance.setWidth(127),
child: ClipOval(
child: _model.selectImgPath == null
? CachedNetworkImage(
? SizedBox(
height: double.maxFinite,
width: double.maxFinite,
child: CachedNetworkImage(
imageUrl: data.data,
fit: BoxFit.cover,
placeholder: (con, str) {
return SvgPicture.asset(
"images/replace_head.svg");
},
),
)
: SizedBox(
height: double.maxFinite,
......@@ -152,9 +182,26 @@ class UserState extends BasePage<UserSettingPage> {
stream: _model.nameLive.stream,
initialData: _model.nameLive.data,
builder: (con, data) {
return Center(
child: baseText(data.data ?? "", 13, ALColors.Color323232),
);
// _controller.text = data.data;
return Container(
width: screenWidth / 4,
height: 60,
alignment: Alignment.center,
child: TextField(
autofocus: false,
textInputAction: TextInputAction.done,
style: TextStyle(
fontSize: 13, color: ALColors.Color323232),
controller: _controller,
textAlign: TextAlign.right,
maxLines: 1,
decoration: InputDecoration(
hintText: data.data,
// hintStyle: TextStyle(
// fontSize: 13, color: ALColors.Color323232),
border: InputBorder.none,
),
));
},
),
false),
......@@ -170,7 +217,8 @@ class UserState extends BasePage<UserSettingPage> {
return Container(
margin: EdgeInsets.only(
right: ScreenUtil.instance.setWidth(19)),
child: baseText(data.data ?? "", 13, ALColors.Color323232),
child:
baseText(data.data ?? "", 13, ALColors.Color323232),
);
},
),
......@@ -196,7 +244,7 @@ class UserState extends BasePage<UserSettingPage> {
right: ScreenUtil.instance.setWidth(30)),
child: OutlineButton(
onPressed: () {
_model.quit(context, pageName());
logoutPicker.show(context);
},
child: baseText("退出登入", 14, ALColors.Color323232),
borderSide: new BorderSide(color: Color(0xff323232)),
......@@ -220,8 +268,11 @@ class UserState extends BasePage<UserSettingPage> {
children: <Widget>[
baseText(left, 13, ALColors.Color323232),
Expanded(
child: SizedBox(
height: double.maxFinite,
child: Text(""),
),
),
center ?? Container(),
needRight
? SvgPicture.asset("images/right_arrow.svg")
......@@ -247,3 +298,54 @@ class UserState extends BasePage<UserSettingPage> {
return _model.refere;
}
}
class UserLogoutPicker implements ICenterPicker {
VoidCallback sure;
VoidCallback cancel;
UserLogoutPicker(this.sure, this.cancel);
@override
Widget build(BuildContext context) {
return Container(
width: ScreenUtil.instance.setWidth(270),
height: ScreenUtil.instance.setHeight(200),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10.0),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
margin: EdgeInsets.only(
top: ScreenUtil.instance.setHeight(20),
bottom: ScreenUtil.instance.setHeight(20)),
child: baseText("提示", 22, ALColors.Color8E8E8E),
),
baseText("确定要退出当前账号", 13, ALColors.Color8E8E8E),
Expanded(
child: Container(),
),
baseDivide(1, 0, ALColors.ColorE4E4E4),
GestureDetector(
onTap: sure,
child: Container(
alignment: Alignment.center,
height: 50,
width: double.maxFinite,
child: baseText("确定", 16, ALColors.Color0093FF),
)),
baseDivide(1, 0, ALColors.ColorE4E4E4),
GestureDetector(
onTap: cancel,
child: Container(
height: 50,
alignment: Alignment.center,
width: double.maxFinite,
child: baseText("取消", 16, ALColors.Color999999),
)),
],
));
}
}
......@@ -54,9 +54,18 @@ class UserRepository {
return _remote.getUploadToken(token_type);
}
Observable<SetUserBean> settingUserInfo(String country_id,
String nick_name, String profile_pic, String user_id, String age) {
Observable<SetUserBean> settingUserInfo(String country_id, String nick_name,
String profile_pic, String user_id, String age) {
return _remote.settingUserInfo(
country_id, nick_name, profile_pic, user_id, age);
}
Observable<SimpleResponce> userLogout(String userID) {
return _remote.userLogout(userID).map((value){
if(value!=null){
_local.clearData();
}
return value;
});
}
}
......@@ -42,4 +42,24 @@ class UserLocal {
UserEntityImpl().savequestionUrl(value.data.questionUrl);
}
}
void clearData() {
UserEntityImpl().saveage("");
UserEntityImpl().saveuserId("");
UserEntityImpl().savebirth(0);
UserEntityImpl().savecityId("");
UserEntityImpl().savecountryId("");
UserEntityImpl().savecountryInfoId("");
UserEntityImpl()
.savecountryInfoLanguage("");
UserEntityImpl().savegender("");
UserEntityImpl().savedetailSetted(false);
UserEntityImpl().savecountryInfoName("");
UserEntityImpl().savehasAnswered(false);
UserEntityImpl().savehasScanFace(false);
UserEntityImpl().saveisBind(false);
UserEntityImpl().savenickName("");
UserEntityImpl().saveprofilePic("");
UserEntityImpl().savequestionUrl("");
}
}
......@@ -42,9 +42,13 @@ class UserRemote {
return UserApiImpl().getUploadToken(token_type);
}
Observable<SetUserBean> settingUserInfo(String country_id,
String nick_name, String profile_pic, String user_id, String age) {
Observable<SetUserBean> settingUserInfo(String country_id, String nick_name,
String profile_pic, String user_id, String age) {
return UserApiImpl()
.settingUserInfo(country_id, nick_name, profile_pic, user_id, age);
}
Observable<SimpleResponce> userLogout(String userId) {
return UserApiImpl().logout(userId);
}
}
......@@ -43,4 +43,7 @@ abstract class UserApi {
@Query("profile_pic") String profile_pic,
@Query("user_id") String user_id,
@Query("age") String age);
@Post("api/account/logout/")
SimpleResponce logout(@Query("user_id") String user_id);
}
......@@ -15,6 +15,7 @@ import 'package:gmalpha_flutter/userModel/service/remote/entity/CommentBean.dart
import 'package:gmalpha_flutter/userModel/service/remote/entity/CountryBean.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UploadTokenBean.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/SetUserBean.dart';
import 'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.dart';
import 'package:gmalpha_flutter/commonModel/net/DioUtil.dart';
......@@ -88,4 +89,15 @@ class UserApiImpl {
}
});
}
Observable<SimpleResponce> logout(String user_id) {
return Observable.fromFuture(
DioUtil().post('api/account/logout/', data: {'user_id': user_id}))
.map((value) {
if (value != null && value.statusCode == 200) {
Map map = json.decode(value.toString());
return SimpleResponce.fromJson(map);
}
});
}
}
......@@ -38,7 +38,12 @@ class UserEntityImpl {
if (_userId != null) {
return Observable.fromFuture(Future.value(_userId));
}
return Observable.fromFuture(spUtil.getStringKv("user_uid"));
return Observable.fromFuture(spUtil.getStringKv("user_uid")).map((value) {
if (value == "") {
return null;
}
return value;
});
}
String _nickName;
......@@ -56,7 +61,12 @@ class UserEntityImpl {
if (_nickName != null) {
return Observable.fromFuture(Future.value(_nickName));
}
return Observable.fromFuture(spUtil.getStringKv("username"));
return Observable.fromFuture(spUtil.getStringKv("username")).map((value) {
if (value == "") {
return null;
}
return value;
});
}
String _profilePic;
......@@ -74,7 +84,12 @@ class UserEntityImpl {
if (_profilePic != null) {
return Observable.fromFuture(Future.value(_profilePic));
}
return Observable.fromFuture(spUtil.getStringKv("potrait"));
return Observable.fromFuture(spUtil.getStringKv("potrait")).map((value) {
if (value == "") {
return null;
}
return value;
});
}
bool _hasAnswered;
......@@ -129,7 +144,12 @@ class UserEntityImpl {
if (_gender != null) {
return Observable.fromFuture(Future.value(_gender));
}
return Observable.fromFuture(spUtil.getStringKv("gender"));
return Observable.fromFuture(spUtil.getStringKv("gender")).map((value) {
if (value == "") {
return null;
}
return value;
});
}
String _cityId;
......@@ -147,7 +167,13 @@ class UserEntityImpl {
if (_cityId != null) {
return Observable.fromFuture(Future.value(_cityId));
}
return Observable.fromFuture(spUtil.getStringKv("current_city_id"));
return Observable.fromFuture(spUtil.getStringKv("current_city_id"))
.map((value) {
if (value == "") {
return null;
}
return value;
});
}
double _birth;
......@@ -183,7 +209,12 @@ class UserEntityImpl {
if (_countryId != null) {
return Observable.fromFuture(Future.value(_countryId));
}
return Observable.fromFuture(spUtil.getStringKv("country_id"));
return Observable.fromFuture(spUtil.getStringKv("country_id")).map((value) {
if (value == "") {
return null;
}
return value;
});
}
bool _detailSetted;
......@@ -221,7 +252,13 @@ class UserEntityImpl {
if (_questionUrl != null) {
return Observable.fromFuture(Future.value(_questionUrl));
}
return Observable.fromFuture(spUtil.getStringKv("question_url"));
return Observable.fromFuture(spUtil.getStringKv("question_url"))
.map((value) {
if (value == "") {
return null;
}
return value;
});
}
bool _isBind;
......@@ -258,7 +295,13 @@ class UserEntityImpl {
if (_countryInfoName != null) {
return Observable.fromFuture(Future.value(_countryInfoName));
}
return Observable.fromFuture(spUtil.getStringKv("country_name"));
return Observable.fromFuture(spUtil.getStringKv("country_name"))
.map((value) {
if (value == "") {
return null;
}
return value;
});
}
String _countryInfoId;
......@@ -277,7 +320,12 @@ class UserEntityImpl {
if (_countryInfoId != null) {
return Observable.fromFuture(Future.value(_countryInfoId));
}
return Observable.fromFuture(spUtil.getStringKv("country_id"));
return Observable.fromFuture(spUtil.getStringKv("country_id")).map((value) {
if (value == "") {
return null;
}
return value;
});
}
String _countryInfoLanguage;
......@@ -296,7 +344,13 @@ class UserEntityImpl {
if (_countryInfoLanguage != null) {
return Observable.fromFuture(Future.value(_countryInfoLanguage));
}
return Observable.fromFuture(spUtil.getStringKv("country_language"));
return Observable.fromFuture(spUtil.getStringKv("country_language"))
.map((value) {
if (value == "") {
return null;
}
return value;
});
}
String _age;
......@@ -314,6 +368,11 @@ class UserEntityImpl {
if (_age != null) {
return Observable.fromFuture(Future.value(_age));
}
return Observable.fromFuture(spUtil.getStringKv("user_age"));
return Observable.fromFuture(spUtil.getStringKv("user_age")).map((value) {
if (value == "") {
return null;
}
return value;
});
}
}
......@@ -44,8 +44,8 @@ class Data {
String nickName;
String profilePic;
int gender;
Null age;
Null cityId;
String age;
String cityId;
double birth;
double registerTime;
bool isBind;
......
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