Commit 5ea62c1a authored by 林生雨's avatar 林生雨

commit

No related merge requests found
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
sdk.dir=/Users/apple/Library/Android/sdk
flutter.sdk=/Users/apple/Downloads/flutter
flutter.buildMode=release
flutter.buildMode=debug
flutter.versionName=1.0.0
flutter.versionCode=1
\ No newline at end of file
Flutter crash report; please file at https://github.com/flutter/flutter/issues.
## command
flutter --no-color run --machine --track-widget-creation --device-id=AKC0218316000622 lib/main.dart
## exception
SocketException: SocketException: Write failed (OS Error: Broken pipe, errno = 32), port = 0
```
null```
## flutter doctor
```
[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Mac OS X 10.14.6 18G95, locale zh-Hans-CN)
• Flutter version 1.7.8+hotfix.4 at /Users/apple/Downloads/flutter
• Framework revision 20e59316b8 (3 months ago), 2019-07-18 20:04:33 -0700
• Engine revision fee001c93f
• Dart version 2.4.0
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
• Android SDK at /Users/apple/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.1
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.2.1, Build version 10E1001
• CocoaPods version 1.7.4
[✓] iOS tools - develop for iOS devices
• ios-deploy 1.9.4
[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 39.0.3
• Dart plugin version 191.8423
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[!] IntelliJ IDEA Ultimate Edition (version 2019.1.3)
• IntelliJ at /Applications/IntelliJ IDEA.app
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• For information about installing plugins, see
https://flutter.dev/intellij-setup/#installing-the-plugins
[✓] Connected device (2 available)
• CLT AL01 • AKC0218316000622 • android-arm64 • Android 9 (API 28)
• sy的 iPhone • 4d2409304573b5f7f07fdb9b09250634d6eb9f11 • ios • iOS 12.4.1
! Doctor found issues in 1 category.
```
<svg width="120" height="120" viewBox="0 0 120 120" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="60" cy="60" r="60" fill="#C4C4C4"/>
<rect x="31.25" y="26.25" width="57.5" height="67.6408" rx="28.75" stroke="white" stroke-width="2.5"/>
<path d="M49.4365 78.2769C52.4132 80.381 56.0601 81.6195 59.9999 81.6195C63.9397 81.6195 67.5866 80.381 70.5633 78.2769" stroke="white" stroke-width="2.5"/>
<path d="M48.1689 54.155V63.0283" stroke="white" stroke-width="3.5"/>
<path d="M71.8311 54.155V63.0283" stroke="white" stroke-width="3.5"/>
<path d="M61.2677 55.4224V68.9435C61.2677 70.3436 60.1327 71.4787 58.7325 71.4787C58.4362 71.4787 58.1518 71.4279 57.8875 71.3344" stroke="white" stroke-width="2.5"/>
</svg>
<svg width="9" height="15" viewBox="0 0 9 15" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1 14L7 7.5L1 1" stroke="#323232" stroke-width="1.5"/>
</svg>
<svg width="34" height="34" viewBox="0 0 34 34" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="17" cy="17" r="17" fill="white"/>
<circle cx="17" cy="18" r="3.25" stroke="#323232" stroke-width="1.5"/>
<path d="M20.3409 10.4167V11.1667H21.0909H26.25V25.25H7.75V11.1667H12.9091H13.6591V10.4167V9.75H20.3409V10.4167Z" stroke="#323232" stroke-width="1.5"/>
</svg>
......@@ -10,13 +10,12 @@ import 'package:gmalpha_flutter/ActivityReportModel/service/remote/entity/Activi
import 'package:flutter/material.dart';
import 'package:gmalpha_flutter/ActivityReportModel/page/ActivityReportModel.dart';
import 'package:gmalpha_flutter/Annotations/RouterCenterRestore.mark.dart';
import 'package:gmalpha_flutter/commonModel/base/BaseComponent.dart';
import 'package:gmalpha_flutter/commonModel/base/BasePage.dart';
import 'package:gmalpha_flutter/commonModel/base/Temp.dart';
import 'package:gmalpha_flutter/commonModel/ui/ALColors.dart';
import 'package:flutter_svg/flutter_svg.dart';
final _goldenColor = Color(0xFFB9A689);
bool stopPage = false;
ActivityReportState state;
class ActivityReportPage extends StatefulWidget {
......@@ -44,30 +43,17 @@ class ActivityReportState extends BasePage<ActivityReportPage> {
@override
Widget build(BuildContext context) {
if (stopPage) {
startTime = DateTime.now().millisecondsSinceEpoch;
stopPage = false;
}
ScreenUtil.instance = ScreenUtil(width: 375, height: 667)..init(context);
return Scaffold(
appBar: AppBar(
title: Text(''),
centerTitle: true,
leading: IMAGE.GestureDetector(
onTap: () {
appBar: baseAppBar(
backClick: () {
RouterCenterImpl()
.findBuriedRouter()
?.onClick(pageName(), "return");
Navigator.pop(context, "");
jumpToNative("search", null);
},
// child: IMAGE.Image.asset("images/nav_back.png"),
child: IMAGE.Center(
child: SvgPicture.asset(
"images/left_arrow.svg",
color: IMAGE.Color(0xff323232),
))),
actions: <Widget>[
action: <Widget>[
GestureDetector(
child: Container(
margin: EdgeInsets.only(right: 30),
......@@ -102,20 +88,20 @@ class ActivityReportState extends BasePage<ActivityReportPage> {
return Container(
color: Color(0xfff5f5f5),
padding: EdgeInsets.only(
left: ScreenUtil().setWidth(16),
right: ScreenUtil().setWidth(16)),
left: ScreenUtil.instance.setWidth(16),
right: ScreenUtil.instance.setWidth(16)),
child: SingleChildScrollView(
child: Column(
children: <Widget>[
TopCard(share: data.data.data.report?.share),
SizedBox(height: ScreenUtil().setHeight(8)),
SizedBox(height: ScreenUtil.instance.setHeight(8)),
PictorialCard(
this,
_model,
pictorialList: data.data.data.report?.cards,
id: _model.id,
),
SizedBox(height: ScreenUtil().setHeight(38))
SizedBox(height: ScreenUtil.instance.setHeight(38))
],
),
),
......@@ -168,7 +154,7 @@ class TopCard extends StatelessWidget {
border: Border(
bottom: BorderSide(color: Color(0xffeeeeee), width: 1.0))),
margin: EdgeInsets.only(left: 18, right: 18),
height: ScreenUtil().setHeight(62),
height: ScreenUtil.instance.setHeight(62),
child: Row(children: <Widget>[
Text('¥',
style: TextStyle(
......@@ -179,7 +165,7 @@ class TopCard extends StatelessWidget {
Text('$val',
style: TextStyle(
color: _goldenColor,
fontSize: ScreenUtil().setSp(45),
fontSize: ScreenUtil.instance.setSp(45),
fontWeight: FontWeight.bold)),
]),
)
......@@ -189,13 +175,13 @@ class TopCard extends StatelessWidget {
_percentageContainer(val) {
return Container(
height: ScreenUtil().setHeight(28),
height: ScreenUtil.instance.setHeight(28),
child: Row(
children: <Widget>[
Text(
'$val%',
style: TextStyle(
fontSize: ScreenUtil().setSp(20),
fontSize: ScreenUtil.instance.setSp(20),
color: _goldenColor,
fontWeight: FontWeight.bold),
),
......@@ -213,14 +199,14 @@ class TopCard extends StatelessWidget {
_rankingContainer(val) {
return Container(
height: ScreenUtil().setHeight(28),
height: ScreenUtil.instance.setHeight(28),
child: Row(
children: <Widget>[
SizedBox(width: 4),
Text(
'$val',
style: TextStyle(
fontSize: ScreenUtil().setSp(20),
fontSize: ScreenUtil.instance.setSp(20),
color: _goldenColor,
fontWeight: FontWeight.bold),
),
......@@ -242,35 +228,35 @@ class TopCard extends StatelessWidget {
}
return Container(
color: Colors.white,
width: ScreenUtil().setWidth(343),
height: ScreenUtil().setHeight(277),
width: ScreenUtil.instance.setWidth(343),
height: ScreenUtil.instance.setHeight(277),
child: Container(
width: ScreenUtil().setWidth(343),
height: ScreenUtil().setHeight(277),
width: ScreenUtil.instance.setWidth(343),
height: ScreenUtil.instance.setHeight(277),
decoration: BoxDecoration(
border: Border.all(
color: ALColors.Color323232,
width: ScreenUtil().setWidth(2))),
width: ScreenUtil.instance.setWidth(2))),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(
height: ScreenUtil().setHeight(8.5),
height: ScreenUtil.instance.setHeight(8.5),
child: Container(
margin: EdgeInsets.only(top: ScreenUtil().setHeight(.5)),
margin: EdgeInsets.only(top: ScreenUtil.instance.setHeight(.5)),
color: ALColors.Color323232,
),
),
Padding(
padding: EdgeInsets.only(
left: ScreenUtil().setWidth(18),
top: ScreenUtil().setHeight(20)),
left: ScreenUtil.instance.setWidth(18),
top: ScreenUtil.instance.setHeight(20)),
child: Text(
'你一年的颜值氪金约为:',
textAlign: TextAlign.left,
style: TextStyle(
color: ALColors.Color323232,
fontSize: ScreenUtil().setSp(12),
fontSize: ScreenUtil.instance.setSp(12),
height: 17 / 12,
fontWeight: FontWeight.bold,
letterSpacing: 1.5,
......@@ -282,50 +268,50 @@ class TopCard extends StatelessWidget {
container: _moneyContainer),
Container(
padding: EdgeInsets.only(
left: ScreenUtil().setWidth(18),
right: ScreenUtil().setWidth(18),
top: ScreenUtil().setHeight(14)),
left: ScreenUtil.instance.setWidth(18),
right: ScreenUtil.instance.setWidth(18),
top: ScreenUtil.instance.setHeight(14)),
child:
AnimationCharacter(targetNmber: share.beat, delay: 1000)),
Container(
padding: EdgeInsets.only(
left: ScreenUtil().setWidth(18),
right: ScreenUtil().setHeight(18),
top: ScreenUtil().setHeight(16)),
left: ScreenUtil.instance.setWidth(18),
right: ScreenUtil.instance.setHeight(18),
top: ScreenUtil.instance.setHeight(16)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
color: Color(0xFFF6F6F6),
width: ScreenUtil().setWidth(140),
height: ScreenUtil().setHeight(55),
width: ScreenUtil.instance.setWidth(140),
height: ScreenUtil.instance.setHeight(55),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
height: ScreenUtil().setHeight(15),
height: ScreenUtil.instance.setHeight(15),
margin: EdgeInsets.only(
left: ScreenUtil().setWidth(8),
top: ScreenUtil().setHeight(4)),
left: ScreenUtil.instance.setWidth(8),
top: ScreenUtil.instance.setHeight(4)),
child: Text('你的氪金量超过了',
style: TextStyle(
fontSize: ScreenUtil().setSp(11),
fontSize: ScreenUtil.instance.setSp(11),
color: ALColors.Color8E8E8E,
fontWeight: FontWeight.bold)),
),
SizedBox(
width: double.maxFinite,
height: ScreenUtil().setHeight(4),
height: ScreenUtil.instance.setHeight(4),
),
Stack(
children: <Widget>[
Container(
width: double.maxFinite,
height: ScreenUtil().setHeight(28),
height: ScreenUtil.instance.setHeight(28),
),
Positioned(
right: ScreenUtil().setWidth(4),
right: ScreenUtil.instance.setWidth(4),
child: AnimationNumber(
targetNmber: share.beat.toDouble(),
delay: 1000,
......@@ -337,34 +323,34 @@ class TopCard extends StatelessWidget {
),
Container(
color: Color(0xFFF6F6F6),
width: ScreenUtil().setWidth(140),
height: ScreenUtil().setHeight(55),
width: ScreenUtil.instance.setWidth(140),
height: ScreenUtil.instance.setHeight(55),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
height: ScreenUtil().setHeight(15),
height: ScreenUtil.instance.setHeight(15),
margin: EdgeInsets.only(
top: ScreenUtil().setHeight(4),
left: ScreenUtil().setWidth(8)),
top: ScreenUtil.instance.setHeight(4),
left: ScreenUtil.instance.setWidth(8)),
child: Text('你的氪金排名为全国',
style: TextStyle(
fontSize: ScreenUtil().setSp(11),
fontSize: ScreenUtil.instance.setSp(11),
color: Color(0xFF8E8E8E),
fontWeight: FontWeight.bold))),
SizedBox(
width: double.maxFinite,
height: ScreenUtil().setHeight(4),
height: ScreenUtil.instance.setHeight(4),
),
Stack(
children: <Widget>[
Container(
width: double.maxFinite,
height: ScreenUtil().setHeight(28),
height: ScreenUtil.instance.setHeight(28),
),
Positioned(
right: ScreenUtil().setWidth(6),
right: ScreenUtil.instance.setWidth(6),
child: AnimationNumber(
targetNmber: share.rank.toDouble(),
delay: 1000,
......@@ -394,12 +380,12 @@ class PictorialCard extends StatelessWidget {
Widget _gridViewItemUI(BuildContext context, item) {
return Container(
width: ScreenUtil().setWidth(110),
height: ScreenUtil().setWidth(110),
margin: EdgeInsets.only(bottom: ScreenUtil().setHeight(3)),
width: ScreenUtil.instance.setWidth(110),
height: ScreenUtil.instance.setWidth(110),
margin: EdgeInsets.only(bottom: ScreenUtil.instance.setHeight(3)),
child: CachedNetworkImage(
imageUrl: '${item.image}',
width: ScreenUtil().setWidth(110),
width: ScreenUtil.instance.setWidth(110),
fit: BoxFit.cover,
));
}
......@@ -411,14 +397,13 @@ class PictorialCard extends StatelessWidget {
list.add(_gridViewItemUI(context, item));
});
return Container(
margin: EdgeInsets.only(top: ScreenUtil().setHeight(32)),
margin: EdgeInsets.only(top: ScreenUtil.instance.setHeight(32)),
child: GestureDetector(
onTap: () {
RouterCenterImpl()
.findBuriedRouter()
?.onClick("brand_report", "recommand_${indexOf + 1}");
state.pageStop();
stopPage = true;
jumpToNative("pictorial",
{"url": '${item.protocol}&survey_record_id=$id'});
},
......@@ -426,13 +411,13 @@ class PictorialCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
width: ScreenUtil().setWidth(343),
width: ScreenUtil.instance.setWidth(343),
padding:
EdgeInsets.only(bottom: ScreenUtil().setHeight(11.0)),
EdgeInsets.only(bottom: ScreenUtil.instance.setHeight(11.0)),
child: Wrap(spacing: 6, children: list),
),
Container(
width: ScreenUtil().setWidth(343),
width: ScreenUtil.instance.setWidth(343),
height: 53,
color: Colors.white,
child: Column(
......@@ -443,23 +428,23 @@ class PictorialCard extends StatelessWidget {
children: <Widget>[
Container(
padding: EdgeInsets.only(
right: ScreenUtil().setWidth(12)),
right: ScreenUtil.instance.setWidth(12)),
child: Text(
'${item.guide}',
style: TextStyle(
color: Color(0xFF323232),
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(14)),
fontSize: ScreenUtil.instance.setSp(14)),
),
),
Positioned(
width: ScreenUtil().setWidth(10),
height: ScreenUtil().setHeight(20),
top: ScreenUtil().setHeight(-2),
width: ScreenUtil.instance.setWidth(10),
height: ScreenUtil.instance.setHeight(20),
top: ScreenUtil.instance.setHeight(-2),
right: 0,
child: IMAGE.Image.asset('images/right_icon.png',
width: ScreenUtil().setWidth(10),
height: ScreenUtil().setHeight(20)),
width: ScreenUtil.instance.setWidth(10),
height: ScreenUtil.instance.setHeight(20)),
)
],
)
......@@ -589,7 +574,7 @@ class AnimationCharacterState extends State<AnimationCharacter>
if (percent < frist) {
double tempPercent = percent / frist;
nowValue = (target * tempPercent).ceil();
margin = ScreenUtil().setWidth(10.0 + (25.8 * nowValue).ceil());
margin = ScreenUtil.instance.setWidth(10.0 + (25.8 * nowValue).ceil());
if (index != nowValue) {
item['url'] = 'images/dark_grey_person.png';
} else {
......@@ -617,11 +602,11 @@ class AnimationCharacterState extends State<AnimationCharacter>
var index = peopleList.indexOf(item);
return Container(
margin: index != 0
? EdgeInsets.only(left: ScreenUtil().setWidth(12))
? EdgeInsets.only(left: ScreenUtil.instance.setWidth(12))
: EdgeInsets.all(0),
child: IMAGE.Image.asset(item['url'],
width: ScreenUtil().setWidth(item['width']),
height: ScreenUtil().setHeight(item['height'])));
width: ScreenUtil.instance.setWidth(item['width']),
height: ScreenUtil.instance.setHeight(item['height'])));
}
@override
......@@ -646,14 +631,14 @@ class AnimationCharacterState extends State<AnimationCharacter>
child: Stack(children: <Widget>[
Container(
width: double.maxFinite,
height: ScreenUtil().setHeight(19),
margin: EdgeInsets.only(bottom: ScreenUtil().setHeight(4)),
height: ScreenUtil.instance.setHeight(19),
margin: EdgeInsets.only(bottom: ScreenUtil.instance.setHeight(4)),
),
Positioned(
child: Container(
margin: EdgeInsets.only(left: margin),
width: ScreenUtil().setWidth(32),
height: ScreenUtil().setHeight(19),
width: ScreenUtil.instance.setWidth(32),
height: ScreenUtil.instance.setHeight(19),
child: IMAGE.Image.asset('images/you_icon.png'),
))
]));
......
......@@ -8,8 +8,9 @@ import 'package:gmalpha_flutter/AlbumModel/AlbumRouterImpl.dart';
import 'package:gmalpha_flutter/Annotations/RouterBaser.dart';
import 'package:gmalpha_flutter/Annotations/anno/Router.dart';
@Router("albumModel", AlbumRouterImpl,true)
@Router("albumModel", AlbumRouterImpl, true)
abstract class AlbumRouter implements RouterBaser {
Widget getAlbumPage(String provider,
bool showCamera, int bigSelectImage, List<String> selectedImages);
Widget getAlbumPage(String provider, bool showCamera, int bigSelectImage,
List<String> selectedImages);
}
......@@ -19,7 +19,6 @@ class UserGenerator extends GeneratorForAnnotation<UserCenter> {
@override
generateForAnnotatedElement(
Element element, ConstantReader annotation, BuildStep buildStep) {
StringBuffer buffer = new StringBuffer();
for (var fieldData in (element as ClassElement).fields) {
for (var annometadata in fieldData.metadata) {
......@@ -41,7 +40,7 @@ class UserGenerator extends GeneratorForAnnotation<UserCenter> {
buffer.write("""
String _${fieldData.name};
Observable<bool> save${fieldData.name}(String ${fieldData.name}){
return Observable.fromFuture(mmKvUtil.saveStringKv("${key}",${fieldData.name}))
return Observable.fromFuture(spUtil.saveStringKv("${key}",${fieldData.name}))
.map((value){
if(value){
this._${fieldData.name}=${fieldData.name};
......@@ -53,14 +52,14 @@ class UserGenerator extends GeneratorForAnnotation<UserCenter> {
if(_${fieldData.name}!=null){
return Observable.fromFuture(Future.value(_${fieldData.name}));
}
return Observable.fromFuture(mmKvUtil.getStringKv("${key}"));
return Observable.fromFuture(spUtil.getStringKv("${key}"));
}
""");
} else if (type == "int") {
buffer.write("""
int _${fieldData.name};
Observable<bool> save${fieldData.name}(int ${fieldData.name}){
return Observable.fromFuture(mmKvUtil.saveIntKv("${key}",${fieldData.name}))
return Observable.fromFuture(spUtil.saveIntKv("${key}",${fieldData.name}))
.map((value){
if(value){
this._${fieldData.name}=${fieldData.name};
......@@ -72,14 +71,14 @@ class UserGenerator extends GeneratorForAnnotation<UserCenter> {
if(_${fieldData.name}!=null){
return Observable.fromFuture(Future.value(_${fieldData.name}));
}
return Observable.fromFuture(mmKvUtil.getIntKv("${key}"));
return Observable.fromFuture(spUtil.getIntKv("${key}"));
}
""");
} else if (type == "double") {
buffer.write("""
double _${fieldData.name};
Observable<bool> save${fieldData.name}(double ${fieldData.name}){
return Observable.fromFuture(mmKvUtil.saveDoubleKv("${key}",${fieldData.name}))
return Observable.fromFuture(spUtil.saveDoubleKv("${key}",${fieldData.name}))
.map((value){
if(value){
this._${fieldData.name}=${fieldData.name};
......@@ -91,14 +90,14 @@ class UserGenerator extends GeneratorForAnnotation<UserCenter> {
if(_${fieldData.name}!=null){
return Observable.fromFuture(Future.value(_${fieldData.name}));
}
return Observable.fromFuture(mmKvUtil.getDoubleKv("${key}"));
return Observable.fromFuture(spUtil.getDoubleKv("${key}"));
}
""");
} else if (type == "bool") {
buffer.write("""
bool _${fieldData.name};
Observable<bool> save${fieldData.name}(bool ${fieldData.name}){
return Observable.fromFuture(mmKvUtil.saveBoolKv("${key}",${fieldData.name}))
return Observable.fromFuture(spUtil.saveBoolKv("${key}",${fieldData.name}))
.map((value){
if(value){
this._${fieldData.name}=${fieldData.name};
......@@ -110,7 +109,7 @@ class UserGenerator extends GeneratorForAnnotation<UserCenter> {
if(_${fieldData.name}!=null){
return Observable.fromFuture(Future.value(_${fieldData.name}));
}
return Observable.fromFuture(mmKvUtil.getBoolKv("${key}"));
return Observable.fromFuture(spUtil.getBoolKv("${key}"));
}
""");
}
......@@ -120,7 +119,8 @@ class UserGenerator extends GeneratorForAnnotation<UserCenter> {
return """
import 'package:rxdart/rxdart.dart';
import 'package:${buildStep.inputId.package}/commonModel/app_module.dart';
import 'package:gmalpha_flutter/commonModel/sp/SpUtil.dart';
class ${element.displayName}Impl{
......@@ -138,6 +138,8 @@ class UserGenerator extends GeneratorForAnnotation<UserCenter> {
return _instance;
}
SpUtil spUtil=SpUtil.getInstance();
${buffer.toString()}
}
""";
......
......@@ -60,7 +60,7 @@ class ReputationsState extends BasePage<ReputationsPage> {
RouterCenterImpl()
.findBuriedRouter()
?.onClick(pageName(), "return");
FlutterBoost.singleton.closePageForContext(context);
Navigator.pop(context,"");
},
// child: Image.asset("images/nav_back.png"),
child: Center(
......
/*
* @author lsy
* @date 2019-10-13
**/
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:gmalpha_flutter/Annotations/RouterCenterRestore.mark.dart';
import 'package:gmalpha_flutter/commonModel/base/BaseComponent.dart';
import 'package:gmalpha_flutter/commonModel/net/Api.dart';
class TestPage extends StatelessWidget {
TestPage() {
Api.getInstance().setDioCookie({
'Cookie':
'sessionid=iro2ke6i7rc9qselm7yogjf5xvgwzn1p; _gtid=203c91f8ebd811e981aa525400e82fab6765; _gm_token=2927681570850359'
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: baseAppBar(title: "flutter测试", centerTitle: true),
body: Container(
child: ListView(
children: <Widget>[
testReportPage(context),
presigePage(context),
albumPage(context),
userSettingPage(context),
],
),
));
}
base(BuildContext context, Widget page, String itemName) {
return Container(
margin: EdgeInsets.fromLTRB(16, 16, 16, 0),
child: OutlineButton(
onPressed: () {
Navigator.push(
context,
new MaterialPageRoute(
builder: (context) => page,
));
},
child: Text(itemName),
),
);
}
testReportPage(BuildContext context) {
return base(
context,
RouterCenterImpl()
.findActivityReportRouter()
?.getActivityReportPage(2, 1, ''),
"报告页面");
}
presigePage(BuildContext context) {
return base(
context,
RouterCenterImpl()
.findPrestigeRouter()
?.getReputationsPage(1, "ww", "ww"),
"专家声望页面");
}
albumPage(BuildContext context) {
return base(
context,
RouterCenterImpl().findAlbumRouter()?.getAlbumPage(
"com.example.gengmei_flutter_plugin_example", true, 1, null),
"相册页面");
}
userSettingPage(BuildContext context) {
return base(
context,
RouterCenterImpl()
.findUserRouter()
?.getUserSettingPage("241765327", "NULL"),
"设置页面");
}
}
import 'package:gmalpha_flutter/commonModel/base/Temp.dart';
import 'package:gmalpha_flutter/commonModel/mmkv/MmkvUtil.dart';
import 'package:gmalpha_flutter/commonModel/sp/SpUtil.dart';
MmKvUtil mmKvUtil;
SpUtil spUtil=SpUtil.getInstance() as SpUtil;
applicationInit() async {
mmKvUtil = await MmKvUtil.getInstance();
}
/*
* @author lsy
* @date 2019-10-13
**/
import 'package:gmalpha_flutter/Annotations/RouterCenterRestore.mark.dart';
void clickEvent(String pageName, String buttonName) {
RouterCenterImpl().findBuriedRouter()?.onClick(pageName, buttonName);
}
/*
* @author lsy
* @date 2019-10-13
**/
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
AppBar baseAppBar(
{String title, List<Widget> action, bool centerTitle, VoidCallback backClick}) {
return AppBar(
title: title == null ? Container() : baseText(title, 16, 0xff323232),
centerTitle: centerTitle,
leading: GestureDetector(
onTap: backClick,
child: Center(
child: SvgPicture.asset(
"images/left_arrow.svg",
color: Color(0xff323232),
)),
),
actions: action == null ? List<Widget>() : action,
);
}
Text baseText(String text, double fontSize, int color) {
return Text(
text,
style: TextStyle(fontSize: fontSize, color: Color(color)),
);
}
......@@ -2,66 +2,54 @@
* @author lsy
* @date 2019-09-04
**/
//import 'package:mmkv_flutter/mmkv_flutter.dart';
//TODO
//import 'package:shared_preferences/shared_preferences.dart';
class MmKvUtil {
import 'package:gengmei_flutter_plugin/gengmei_flutter_plugin.dart';
// static MmkvFlutter _mmkv;
static MmKvUtil mmKvUtil;
// static SharedPreferences _mmkv;
var _mmkv;
class SpUtil {
static SpUtil _spUtil;
//MmkvFlutter mmkv
MmKvUtil._(mmkv) {
_mmkv = mmkv;
}
SpUtil._() {}
static Future<MmKvUtil> getInstance() async {
if (mmKvUtil == null) {
var _mmkv;
// final SharedPreferences _mmkv = await SharedPreferences.getInstance();
// final MmkvFlutter _mmkv = await MmkvFlutter.getInstance();
// _mmkv
mmKvUtil = new MmKvUtil._(_mmkv);
static SpUtil getInstance() {
if (_spUtil == null) {
_spUtil = new SpUtil._();
}
return mmKvUtil;
return _spUtil;
}
Future saveBoolKv(String key, bool value) async {
return await _mmkv.setBool(key, value);
return await GengmeiFlutterPlugin.saveBool(key, value);
}
Future saveStringKv(String key, String value) async {
return await _mmkv.setString(key, value);
return await GengmeiFlutterPlugin.saveString(key, value);
}
Future saveDoubleKv(String key, double value) async {
return await _mmkv.setDouble(key, value);
return await GengmeiFlutterPlugin.saveDouble(key, value);
}
Future<bool> saveIntKv(String key, int value) async {
return await _mmkv.setInt(key, value);
return await GengmeiFlutterPlugin.saveInt(key, value);
}
Future<String> getStringKv(String key) async {
return await _mmkv.getString(key);
return await GengmeiFlutterPlugin.getString(key, null);
}
Future<bool> getBoolKv(String key) async {
return await _mmkv.getBool(key);
return await GengmeiFlutterPlugin.getbool(key, null);
}
Future<int> getIntKv(String key) async {
return await _mmkv.getInt(key);
return await GengmeiFlutterPlugin.getInt(key, null);
}
Future<double> getDoubleKv(String key) async {
return await _mmkv.getDouble(key);
return await GengmeiFlutterPlugin.getDouble(key, null);
}
Future<bool> clearKv() async {
return await _mmkv.clear();
}
// Future<bool> clearKv() async {
// return await GengmeiFlutterPlugin.clear();
// }
}
import 'package:flutter/material.dart';
import 'package:gmalpha_flutter/commonModel/net/Api.dart';
class Toast {
static ToastView preToast;
static debugShow(BuildContext context, String msg) {
if (Api.BUILD_CONFIG != "release") {
show(context, msg);
}
}
static show(BuildContext context, String msg) {
var overlayState = Overlay.of(context);
var controllerShowAnim = new AnimationController(
......
......@@ -2,8 +2,10 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_boost/flutter_boost.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:gmalpha_flutter/Annotations/RouterCenterRestore.mark.dart';
import 'package:gmalpha_flutter/Error_Page.dart';
import 'package:gmalpha_flutter/TestPage.dart';
import 'package:gmalpha_flutter/commonModel/app_module.dart';
import 'package:gmalpha_flutter/commonModel/base/Temp.dart';
import 'package:gmalpha_flutter/commonModel/cache/CacheManager.dart';
......@@ -79,20 +81,11 @@ class _MyAppState extends State<MyApp> {
return MaterialApp(
title: 'Flutter Boost example',
debugShowCheckedModeBanner: false,
// routes: {
// '/': (context) {
// Api.getInstance().setDioCookie({
// 'Cookie': 'sessionid=iro2ke6i7rc9qselm7yogjf5xvgwzn1p; _gtid=203c91f8ebd811e981aa525400e82fab6765; _gm_token=2927681570850359'
// });
// return RouterCenterImpl()
// .findActivityReportRouter()
// ?.getActivityReportPage(279, 1, '');
//// return RouterCenterImpl().findPrestigeRouter()?.getReputationsPage(1, "ww", "ww");
//// return RouterCenterImpl()
//// .findAlbumRouter()
//// .getAlbumPage("com.example.gengmei_flutter_plugin_example",true, 2, null);
// },
// },
routes: {
'/': (context) {
return TestPage();
},
},
builder: FlutterBoost.init(postPush: _onRoutePushed),
theme: new ThemeData(
primaryColor: Colors.white,
......@@ -115,3 +108,5 @@ class _MyAppState extends State<MyApp> {
print("PUSHED $pageName");
}
}
......@@ -8,8 +8,9 @@ import 'package:gmalpha_flutter/Annotations/RouterBaser.dart';
import 'package:gmalpha_flutter/Annotations/anno/Router.dart';
import 'package:gmalpha_flutter/userModel/UserRouterImpl.dart';
@Router("userModel",UserRouterImpl,true)
abstract class UserRouter implements RouterBaser{
@Router("userModel", UserRouterImpl, true)
abstract class UserRouter implements RouterBaser {
Widget getUserPage();
Widget getUserSettingPage(String userID, String refer);
}
......@@ -4,11 +4,15 @@
**/
import 'package:flutter/src/widgets/framework.dart';
import 'package:gmalpha_flutter/userModel/UserRouter.dart';
import 'package:gmalpha_flutter/userModel/page/user/UserPage.dart';
import 'package:gmalpha_flutter/userModel/page/userSetting/UserSettingPage.dart';
class UserRouterImpl implements UserRouter {
@override
Widget getUserPage() {
return UserWidget();
}
@override
Widget getUserSettingPage(String userID, String refer) {
return UserSettingPage(userID,refer);
}
}
/*
* @author lsy
* @date 2019-09-04
**/
import 'package:flutter/material.dart';
import 'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.dart';
import 'package:gmalpha_flutter/userModel/page/user/UserPageModel.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/TestUserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.dart';
class UserWidget extends StatefulWidget {
@override
State<StatefulWidget> createState() => UserState();
}
class UserState extends State<UserWidget> {
UserPageModel _model;
TextEditingController _nameController = new TextEditingController();
TextEditingController _wordController = new TextEditingController();
@override
void initState() {
super.initState();
_model = new UserPageModel();
}
@override
void dispose() {
super.dispose();
_model.dispose();
_wordController.dispose();
_nameController.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
"User",
style: TextStyle(fontSize: 16),
),
centerTitle: true,
),
body: Column(
children: <Widget>[
Expanded(
child: StreamBuilder<SimpleResponce>(
stream: _model.logoutLive.stream,
initialData: _model.logoutLive.data,
builder: (BuildContext context,
AsyncSnapshot<SimpleResponce> snapshot) {
if (snapshot.data == null) {
return Center(child: Text("没有退出"));
} else {
return Center(child: Text("退出接口回掉成功!!"));
}
},
),
),
Container(
margin: EdgeInsets.fromLTRB(16, 10, 16, 20),
child: TextField(
cursorColor: Colors.black,
controller: _nameController,
decoration: InputDecoration(
contentPadding: EdgeInsets.all(10.0),
icon: Icon(Icons.text_fields, color: Colors.black),
labelText: 'name',
labelStyle: TextStyle(color: Colors.black)),
autofocus: false,
),
),
Container(
margin: EdgeInsets.fromLTRB(16, 0, 16, 20),
child: TextField(
cursorColor: Colors.black,
controller: _wordController,
decoration: InputDecoration(
contentPadding: EdgeInsets.all(10.0),
icon: Icon(
Icons.text_fields,
color: Colors.black,
),
labelText: 'word',
labelStyle: TextStyle(color: Colors.black)),
autofocus: false,
),
),
Container(
width: double.maxFinite,
margin: EdgeInsets.fromLTRB(16, 0, 16, 0),
child: OutlineButton(
onPressed: () => _model.resignUser(
context, _nameController.text, _wordController.text),
child: Text("注册"),
shape: BeveledRectangleBorder(
borderRadius: BorderRadius.circular(3),
),
)),
Container(
width: double.maxFinite,
margin: EdgeInsets.fromLTRB(16, 0, 16, 0),
child: OutlineButton(
onPressed: () => _model.logout(context),
child: Text("退出"),
shape: BeveledRectangleBorder(
borderRadius: BorderRadius.circular(3),
),
)),
Expanded(
child: StreamBuilder<TestUserEntity>(
stream: _model.resignLive.stream,
initialData: _model.resignLive.data,
builder: (BuildContext context,
AsyncSnapshot<TestUserEntity> snapshot) {
if (snapshot.data != null) {
return Center(
child: snapshot.data.data == null
? Text("错误 ${snapshot.data.errorMsg}")
: Text("登入回掉 用户id: ${snapshot.data.data.id}"),
);
} else {
return Center(
child: Text("初始化~"),
);
}
},
),
)
],
),
);
}
}
/*
* @author lsy
* @date 2019-09-04
**/
import 'package:flutter/cupertino.dart';
import 'package:gmalpha_flutter/commonModel/live/BaseModel.dart';
import 'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.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/TestUserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.dart';
import '../../../commonModel/live/LiveData.dart';
class UserPageModel extends BaseModel {
LiveData<SimpleResponce> logoutLive = new LiveData();
LiveData<TestUserEntity> resignLive = new LiveData();
// LiveData<String> userTokenLive = new LiveData();
UserPageModel() {}
void logout(BuildContext context) {
UserRepository.getInstance().logout().listen((data) {
logoutLive.notifyView(data);
}).onError((error) {
Toast.show(context, "error ${error}");
print(error);
});
}
void resignUser(BuildContext context, String name, String word) {
UserRepository.getInstance().resignUser(name, word, word).listen((data) {
print("data !! :${data}");
resignLive.notifyView(data);
}).onError((error) {
Toast.show(context, "error :${error}");
print(error);
});
}
@override
void dispose() {
logoutLive.dispost();
resignLive.dispost();
}
}
/*
* @author lsy
* @date 2019-09-04
**/
import 'package:flutter/cupertino.dart';
import 'package:gmalpha_flutter/commonModel/live/BaseModel.dart';
import 'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.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/UserResultBean.dart';
import '../../../commonModel/live/LiveData.dart';
class UserSettingModel extends BaseModel {
LiveData<String> nameLive = new LiveData();
LiveData<String> cityLive = new LiveData();
LiveData<String> headImgLive = new LiveData();
LiveData<bool> saveLive = new LiveData();
final String userid;
final String refere;
UserSettingModel(this.userid, this.refere);
init(BuildContext context) {
if (UserEntityImpl().getuserId() == null ||
UserEntityImpl().getuserId() != userid) {
UserRepository.getInstance().getUserInfo(userid).listen((data) {
print(data);
}).onError((error) {
print(error);
Toast.show(context, "error");
});
} else {
UserEntityImpl().getnickName().listen((data) {
nameLive.notifyView(data);
}).onError((error) {
print(error);
Toast.debugShow(context, error);
});
UserEntityImpl().getcountryInfoName().listen((data) {
cityLive.notifyView(data);
}).onError((error) {
print(error);
Toast.debugShow(context, error);
});
UserEntityImpl().getprofilePic().listen((value) {
headImgLive.notifyView(value);
}).onError((error) {
print(error);
Toast.debugShow(context, error);
});
}
}
@override
void dispose() {
nameLive.dispost();
headImgLive.dispost();
cityLive.dispost();
saveLive.dispost();
}
void gotoCommentPage(BuildContext context) {}
}
/*
* @author lsy
* @date 2019-09-04
**/
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/flutter_svg.dart';
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/userModel/page/userSetting/UserSettingModel.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/TestUserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.dart';
class UserSettingPage extends StatefulWidget {
UserSettingModel _model;
UserSettingPage(String userid, String refer) {
_model = new UserSettingModel(userid, refer);
}
@override
State<StatefulWidget> createState() => UserState(_model);
}
class UserState extends BasePage<UserSettingPage> {
final UserSettingModel _model;
UserState(this._model);
@override
void initState() {
super.initState();
_model.init(context);
}
@override
void dispose() {
super.dispose();
_model.dispose();
}
@override
Widget build(BuildContext context) {
ScreenUtil.instance = ScreenUtil(width: 375, height: 667)..init(context);
return Scaffold(
appBar: baseAppBar(
backClick: () {
clickEvent(pageName(), "return");
Navigator.pop(context);
},
action: <Widget>[
StreamBuilder<bool>(
stream: _model.saveLive.stream,
initialData: _model.saveLive.data,
builder: (context, data) {
if (data.data == null || !data.data) {
return Padding(
padding: EdgeInsets.only(
right: ScreenUtil.instance.setWidth(30)),
child: Center(
child: baseText("保存", 14, 0xffC4C4C4),
),
);
} else {
return GestureDetector(
onTap: () {},
child: Padding(
padding: EdgeInsets.only(
right: ScreenUtil.instance.setWidth(30)),
child: Center(
child: baseText("保存", 14, 0xff323232),
),
));
}
},
)
]),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: EdgeInsets.fromLTRB(ScreenUtil.instance.setWidth(29),
ScreenUtil.instance.setWidth(25), 0, 0),
child: baseText("设置", 30, 0xff323232),
),
Container(
width: ScreenUtil.instance.setWidth(127),
height: ScreenUtil.instance.setHeight(127),
margin: EdgeInsets.fromLTRB(
ScreenUtil.instance.setWidth(26),
ScreenUtil.instance.setWidth(23),
0,
ScreenUtil.instance.setWidth(23)),
child: GestureDetector(
onTap: () {},
child: Stack(
alignment: Alignment.bottomRight,
children: <Widget>[
StreamBuilder<String>(
stream: _model.headImgLive.stream,
initialData: _model.headImgLive.data,
builder: (con, data) {
if (data.data == null || data.data.isEmpty) {
return SvgPicture.asset("images/replace_head.svg");
} else {
return ClipOval(
child: CachedNetworkImage(
imageUrl: data.data,
));
}
},
),
SvgPicture.asset(
"images/small_camera.svg",
)
],
),
)),
Column(
children: <Widget>[
baseItem(
() {},
"昵称",
StreamBuilder<String>(
stream: _model.nameLive.stream,
initialData: _model.nameLive.data,
builder: (con, data) {
return Center(
child: baseText(data.data ?? "", 13, 0xff323232),
);
},
),
false),
divideLine(),
baseItem(
() {},
"国家",
StreamBuilder<String>(
stream: _model.cityLive.stream,
initialData: _model.cityLive.data,
builder: (con, data) {
return Container(
margin: EdgeInsets.only(
right: ScreenUtil.instance.setWidth(19)),
child: baseText(data.data ?? "", 13, 0xff323232),
);
},
),
true),
divideLine(),
baseItem(() {
_model.gotoCommentPage(context);
}, "意见与建议", null, true),
divideLine(),
baseItem(() {}, "隐私声明", null, true),
divideLine(),
],
),
Expanded(
child: Container(),
),
Container(
width: double.maxFinite,
height: ScreenUtil.instance.setHeight(45),
margin: EdgeInsets.only(
bottom: ScreenUtil.instance.setHeight(30),
left: ScreenUtil.instance.setWidth(30),
right: ScreenUtil.instance.setWidth(30)),
child: OutlineButton(
onPressed: () {},
child: baseText("退出登入", 14, 0xff323232),
borderSide:new BorderSide(color: Color(0xff323232)),
),
)
],
),
);
}
divideLine() {
return Container(
height: 1,
margin: EdgeInsets.only(
right: ScreenUtil.instance.setWidth(30),
left: ScreenUtil.instance.setWidth(30)),
child: Container(
color: Color(0xffE4E4E4),
));
}
baseItem(VoidCallback ontap, String left, Widget center, bool needRight) {
return GestureDetector(
onTap: () => ontap,
child: Container(
margin: EdgeInsets.only(
right: ScreenUtil.instance.setWidth(30),
left: ScreenUtil.instance.setWidth(30)),
height: ScreenUtil.instance.setHeight(60),
child: Row(
children: <Widget>[
baseText(left, 13, 0xff323232),
Expanded(
child: Container(),
),
center ?? Container(),
needRight
? SvgPicture.asset("images/right_arrow.svg")
: Container()
],
),
));
}
@override
void reassemble() {
super.reassemble();
_model.dispose();
}
@override
String pageName() {
return "TODO";
}
@override
String referrer() {
return _model.refere;
}
}
......@@ -7,6 +7,8 @@ import 'package:gmalpha_flutter/userModel/service/local/UserLocal.dart';
import 'package:gmalpha_flutter/userModel/service/remote/UserRemote.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/TestUserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.user.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserResultBean.dart';
import 'package:rxdart/rxdart.dart';
class UserRepository {
......@@ -27,31 +29,12 @@ class UserRepository {
return _userRepository;
}
Observable<UserEntity> getUserInfo(String token) {
_remote.getUserInfo(token).map((value) {
Observable<UserResultBean> getUserInfo(String userId) {
return _remote.getUserInfo(userId).map((value) {
if (value != null) {
_local.saveUserInfo(value);
}
return value;
});
}
Observable<TestUserEntity> resignUser(
String name, String word, String reword) {
return _remote.resignUser(name, word, reword).map((value) {
if (value != null) {
_local.saveUser(value);
}
return value;
});
}
Observable<SimpleResponce> logout() {
return _remote.logout().map((value) {
if (value != null) {
_local.logout();
}
return value;
});
}
}
......@@ -4,6 +4,8 @@
**/
import 'package:gmalpha_flutter/userModel/service/remote/entity/TestUserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.user.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserResultBean.dart';
class UserLocal {
static UserLocal _userRemote;
......@@ -17,15 +19,24 @@ class UserLocal {
return _userRemote;
}
void saveUserInfo(UserEntity value) {
//TODO
void saveUserInfo(UserResultBean value) {
if (value != null) {
UserEntityImpl().saveuserId("${value.data.userId}");
UserEntityImpl().savebirth(value.data.birth);
UserEntityImpl().savecityId("${value.data.cityId}");
UserEntityImpl().savecountryId("${value.data.countryInfo.id}");
UserEntityImpl().savecountryInfoId("${value.data.countryInfo.id}");
UserEntityImpl()
.savecountryInfoLanguage("${value.data.countryInfo.language}");
UserEntityImpl().savegender("${value.data.gender}");
UserEntityImpl().savedetailSetted(value.data.detailSetted);
UserEntityImpl().savecountryInfoName(value.data.countryInfo.name);
UserEntityImpl().savehasAnswered(value.data.hasAnswered);
UserEntityImpl().savehasScanFace(value.data.hasScanFace);
UserEntityImpl().saveisBind(value.data.isBind);
UserEntityImpl().savenickName(value.data.nickName);
UserEntityImpl().saveprofilePic(value.data.profilePic);
UserEntityImpl().savequestionUrl(value.data.questionUrl);
}
void saveUser(TestUserEntity value) {
//TODO
}
void logout() {
//TODO
}
}
......@@ -3,9 +3,10 @@
* @date 2019-09-04
**/
import 'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.dart';
import 'package:gmalpha_flutter/userModel/service/remote/api/UserLoginApi.serv.dart';
import 'package:gmalpha_flutter/userModel/service/remote/api/UserApi.serv.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/TestUserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserResultBean.dart';
import 'package:rxdart/rxdart.dart';
class UserRemote {
......@@ -20,16 +21,7 @@ class UserRemote {
return _userRemote;
}
Observable<UserEntity> getUserInfo(String token) {
return UserLoginApiImpl().getUserInfo(token);
}
Observable<TestUserEntity> resignUser(
String name, String word, String reWord) {
return UserLoginApiImpl().resign(name, word, reWord);
}
Observable<SimpleResponce> logout() {
return UserLoginApiImpl().logout();
Observable<UserResultBean> getUserInfo(String userID) {
return UserApiImpl().getUserInfo(userID);
}
}
......@@ -9,16 +9,10 @@ import 'package:gmalpha_flutter/Annotations/anno/ServiceCenter.dart';
import 'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/TestUserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserResultBean.dart';
@ServiceCenter()
abstract class UserLoginApi {
@Post("user/register")
TestUserEntity resign(@Query("username") String name,
@Query("password") String word, @Query("repassword") String repassword);
@Get("user/info")
UserEntity getUserInfo(@Query("token") String token);
@Get("user/logout/json")
SimpleResponce logout();
abstract class UserApi {
@Get("api/account/user_profile")
UserResultBean getUserInfo(@Query("user_id") String userID);
}
......@@ -10,56 +10,30 @@ import 'dart:io';
import 'package:rxdart/rxdart.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/TestUserEntity.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserEntity.dart';
import 'package:gmalpha_flutter/commonModel/net/Responce/SimpleResponce.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/UserResultBean.dart';
import 'package:gmalpha_flutter/commonModel/net/DioUtil.dart';
class UserLoginApiImpl {
factory UserLoginApiImpl() => _sharedInstance();
class UserApiImpl {
factory UserApiImpl() => _sharedInstance();
static UserLoginApiImpl _instance;
static UserApiImpl _instance;
UserLoginApiImpl._() {}
UserApiImpl._() {}
static UserLoginApiImpl _sharedInstance() {
static UserApiImpl _sharedInstance() {
if (_instance == null) {
_instance = UserLoginApiImpl._();
_instance = UserApiImpl._();
}
return _instance;
}
Observable<TestUserEntity> resign(
String name, String word, String repassword) {
return Observable.fromFuture(DioUtil().post('user/register', data: {
'username': name,
'password': word,
'repassword': repassword
})).map((value) {
Observable<UserResultBean> getUserInfo(String userID) {
return Observable.fromFuture(DioUtil().get('api/account/user_profile',
data: {'user_id': userID})).map((value) {
if (value != null && value.statusCode == 200) {
Map map = json.decode(value.toString());
return TestUserEntity.fromJson(map);
}
});
}
Observable<UserEntity> getUserInfo(String token) {
return Observable.fromFuture(
DioUtil().get('user/info', data: {'token': token})).map((value) {
if (value != null && value.statusCode == 200) {
Map map = json.decode(value.toString());
return UserEntity.fromJson(map);
}
});
}
Observable<SimpleResponce> logout() {
return Observable.fromFuture(DioUtil().get('user/logout/json'))
.map((value) {
if (value != null && value.statusCode == 200) {
Map map = json.decode(value.toString());
return SimpleResponce.fromJson(map);
return UserResultBean.fromJson(map);
}
});
}
......
......@@ -85,8 +85,6 @@ class UserEntity {
String insBindId;
String registerTime;
UserEntity(
{this.userId,
this.nickName,
......
......@@ -5,7 +5,7 @@
// **************************************************************************
import 'package:rxdart/rxdart.dart';
import 'package:gmalpha_flutter/commonModel/app_module.dart';
import 'package:gmalpha_flutter/commonModel/sp/SpUtil.dart';
class UserEntityImpl {
factory UserEntityImpl() => _sharedInstance();
......@@ -21,9 +21,10 @@ class UserEntityImpl {
return _instance;
}
SpUtil spUtil = SpUtil.getInstance();
String _userId;
Observable<bool> saveuserId(String userId) {
return Observable.fromFuture(mmKvUtil.saveStringKv("user_uid", userId))
return Observable.fromFuture(spUtil.saveStringKv("user_uid", userId))
.map((value) {
if (value) {
this._userId = userId;
......@@ -36,12 +37,12 @@ class UserEntityImpl {
if (_userId != null) {
return Observable.fromFuture(Future.value(_userId));
}
return Observable.fromFuture(mmKvUtil.getStringKv("user_uid"));
return Observable.fromFuture(spUtil.getStringKv("user_uid"));
}
String _nickName;
Observable<bool> savenickName(String nickName) {
return Observable.fromFuture(mmKvUtil.saveStringKv("username", nickName))
return Observable.fromFuture(spUtil.saveStringKv("username", nickName))
.map((value) {
if (value) {
this._nickName = nickName;
......@@ -54,12 +55,12 @@ class UserEntityImpl {
if (_nickName != null) {
return Observable.fromFuture(Future.value(_nickName));
}
return Observable.fromFuture(mmKvUtil.getStringKv("username"));
return Observable.fromFuture(spUtil.getStringKv("username"));
}
String _profilePic;
Observable<bool> saveprofilePic(String profilePic) {
return Observable.fromFuture(mmKvUtil.saveStringKv("potrait", profilePic))
return Observable.fromFuture(spUtil.saveStringKv("potrait", profilePic))
.map((value) {
if (value) {
this._profilePic = profilePic;
......@@ -72,13 +73,12 @@ class UserEntityImpl {
if (_profilePic != null) {
return Observable.fromFuture(Future.value(_profilePic));
}
return Observable.fromFuture(mmKvUtil.getStringKv("potrait"));
return Observable.fromFuture(spUtil.getStringKv("potrait"));
}
bool _hasAnswered;
Observable<bool> savehasAnswered(bool hasAnswered) {
return Observable.fromFuture(
mmKvUtil.saveBoolKv("personal_qa", hasAnswered))
return Observable.fromFuture(spUtil.saveBoolKv("personal_qa", hasAnswered))
.map((value) {
if (value) {
this._hasAnswered = hasAnswered;
......@@ -91,13 +91,13 @@ class UserEntityImpl {
if (_hasAnswered != null) {
return Observable.fromFuture(Future.value(_hasAnswered));
}
return Observable.fromFuture(mmKvUtil.getBoolKv("personal_qa"));
return Observable.fromFuture(spUtil.getBoolKv("personal_qa"));
}
bool _hasScanFace;
Observable<bool> savehasScanFace(bool hasScanFace) {
return Observable.fromFuture(
mmKvUtil.saveBoolKv("has_scan_face", hasScanFace))
spUtil.saveBoolKv("has_scan_face", hasScanFace))
.map((value) {
if (value) {
this._hasScanFace = hasScanFace;
......@@ -110,12 +110,12 @@ class UserEntityImpl {
if (_hasScanFace != null) {
return Observable.fromFuture(Future.value(_hasScanFace));
}
return Observable.fromFuture(mmKvUtil.getBoolKv("has_scan_face"));
return Observable.fromFuture(spUtil.getBoolKv("has_scan_face"));
}
String _gender;
Observable<bool> savegender(String gender) {
return Observable.fromFuture(mmKvUtil.saveStringKv("gender", gender))
return Observable.fromFuture(spUtil.saveStringKv("gender", gender))
.map((value) {
if (value) {
this._gender = gender;
......@@ -128,13 +128,12 @@ class UserEntityImpl {
if (_gender != null) {
return Observable.fromFuture(Future.value(_gender));
}
return Observable.fromFuture(mmKvUtil.getStringKv("gender"));
return Observable.fromFuture(spUtil.getStringKv("gender"));
}
String _cityId;
Observable<bool> savecityId(String cityId) {
return Observable.fromFuture(
mmKvUtil.saveStringKv("current_city_id", cityId))
return Observable.fromFuture(spUtil.saveStringKv("current_city_id", cityId))
.map((value) {
if (value) {
this._cityId = cityId;
......@@ -147,12 +146,12 @@ class UserEntityImpl {
if (_cityId != null) {
return Observable.fromFuture(Future.value(_cityId));
}
return Observable.fromFuture(mmKvUtil.getStringKv("current_city_id"));
return Observable.fromFuture(spUtil.getStringKv("current_city_id"));
}
int _birth;
Observable<bool> savebirth(int birth) {
return Observable.fromFuture(mmKvUtil.saveIntKv("birthday", birth))
return Observable.fromFuture(spUtil.saveIntKv("birthday", birth))
.map((value) {
if (value) {
this._birth = birth;
......@@ -165,12 +164,12 @@ class UserEntityImpl {
if (_birth != null) {
return Observable.fromFuture(Future.value(_birth));
}
return Observable.fromFuture(mmKvUtil.getIntKv("birthday"));
return Observable.fromFuture(spUtil.getIntKv("birthday"));
}
String _countryId;
Observable<bool> savecountryId(String countryId) {
return Observable.fromFuture(mmKvUtil.saveStringKv("country_id", countryId))
return Observable.fromFuture(spUtil.saveStringKv("country_id", countryId))
.map((value) {
if (value) {
this._countryId = countryId;
......@@ -183,13 +182,13 @@ class UserEntityImpl {
if (_countryId != null) {
return Observable.fromFuture(Future.value(_countryId));
}
return Observable.fromFuture(mmKvUtil.getStringKv("country_id"));
return Observable.fromFuture(spUtil.getStringKv("country_id"));
}
bool _detailSetted;
Observable<bool> savedetailSetted(bool detailSetted) {
return Observable.fromFuture(
mmKvUtil.saveBoolKv("detail_setted", detailSetted))
spUtil.saveBoolKv("detail_setted", detailSetted))
.map((value) {
if (value) {
this._detailSetted = detailSetted;
......@@ -202,13 +201,13 @@ class UserEntityImpl {
if (_detailSetted != null) {
return Observable.fromFuture(Future.value(_detailSetted));
}
return Observable.fromFuture(mmKvUtil.getBoolKv("detail_setted"));
return Observable.fromFuture(spUtil.getBoolKv("detail_setted"));
}
String _questionUrl;
Observable<bool> savequestionUrl(String questionUrl) {
return Observable.fromFuture(
mmKvUtil.saveStringKv("question_url", questionUrl))
spUtil.saveStringKv("question_url", questionUrl))
.map((value) {
if (value) {
this._questionUrl = questionUrl;
......@@ -221,13 +220,12 @@ class UserEntityImpl {
if (_questionUrl != null) {
return Observable.fromFuture(Future.value(_questionUrl));
}
return Observable.fromFuture(mmKvUtil.getStringKv("question_url"));
return Observable.fromFuture(spUtil.getStringKv("question_url"));
}
bool _isBind;
Observable<bool> saveisBind(bool isBind) {
return Observable.fromFuture(
mmKvUtil.saveBoolKv("user_bind_mobile", isBind))
return Observable.fromFuture(spUtil.saveBoolKv("user_bind_mobile", isBind))
.map((value) {
if (value) {
this._isBind = isBind;
......@@ -240,13 +238,13 @@ class UserEntityImpl {
if (_isBind != null) {
return Observable.fromFuture(Future.value(_isBind));
}
return Observable.fromFuture(mmKvUtil.getBoolKv("user_bind_mobile"));
return Observable.fromFuture(spUtil.getBoolKv("user_bind_mobile"));
}
String _countryInfoName;
Observable<bool> savecountryInfoName(String countryInfoName) {
return Observable.fromFuture(
mmKvUtil.saveStringKv("country_name", countryInfoName))
spUtil.saveStringKv("country_name", countryInfoName))
.map((value) {
if (value) {
this._countryInfoName = countryInfoName;
......@@ -259,13 +257,13 @@ class UserEntityImpl {
if (_countryInfoName != null) {
return Observable.fromFuture(Future.value(_countryInfoName));
}
return Observable.fromFuture(mmKvUtil.getStringKv("country_name"));
return Observable.fromFuture(spUtil.getStringKv("country_name"));
}
String _countryInfoId;
Observable<bool> savecountryInfoId(String countryInfoId) {
return Observable.fromFuture(
mmKvUtil.saveStringKv("country_id", countryInfoId))
spUtil.saveStringKv("country_id", countryInfoId))
.map((value) {
if (value) {
this._countryInfoId = countryInfoId;
......@@ -278,13 +276,13 @@ class UserEntityImpl {
if (_countryInfoId != null) {
return Observable.fromFuture(Future.value(_countryInfoId));
}
return Observable.fromFuture(mmKvUtil.getStringKv("country_id"));
return Observable.fromFuture(spUtil.getStringKv("country_id"));
}
String _countryInfoLanguage;
Observable<bool> savecountryInfoLanguage(String countryInfoLanguage) {
return Observable.fromFuture(
mmKvUtil.saveStringKv("country_language", countryInfoLanguage))
spUtil.saveStringKv("country_language", countryInfoLanguage))
.map((value) {
if (value) {
this._countryInfoLanguage = countryInfoLanguage;
......@@ -297,6 +295,6 @@ class UserEntityImpl {
if (_countryInfoLanguage != null) {
return Observable.fromFuture(Future.value(_countryInfoLanguage));
}
return Observable.fromFuture(mmKvUtil.getStringKv("country_language"));
return Observable.fromFuture(spUtil.getStringKv("country_language"));
}
}
/*
* @author lsy
* @date 2019-10-12
**/
class UserResultBean {
int error;
String message;
Null extra;
Data data;
UserType userType;
UserResultBean(
{this.error, this.message, this.extra, this.data, this.userType});
UserResultBean.fromJson(Map<String, dynamic> json) {
error = json['error'];
message = json['message'];
extra = json['extra'];
data = json['data'] != null ? new Data.fromJson(json['data']) : null;
userType = json['user_type'] != null
? new UserType.fromJson(json['user_type'])
: null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['error'] = this.error;
data['message'] = this.message;
data['extra'] = this.extra;
if (this.data != null) {
data['data'] = this.data.toJson();
}
if (this.userType != null) {
data['user_type'] = this.userType.toJson();
}
return data;
}
}
class Data {
int id;
bool isOnline;
int userId;
String nickName;
String profilePic;
int gender;
Null age;
Null cityId;
int birth;
double registerTime;
bool isBind;
bool logined;
bool hasAnswered;
bool hasScanFace;
Null insBindId;
String questionUrl;
bool detailSetted;
CountryInfo countryInfo;
String ageDisplay;
bool tagSetted;
bool hasSkinTexture;
Data(
{this.id,
this.isOnline,
this.userId,
this.nickName,
this.profilePic,
this.gender,
this.age,
this.cityId,
this.birth,
this.registerTime,
this.isBind,
this.logined,
this.hasAnswered,
this.hasScanFace,
this.insBindId,
this.questionUrl,
this.detailSetted,
this.countryInfo,
this.ageDisplay,
this.tagSetted,
this.hasSkinTexture});
Data.fromJson(Map<String, dynamic> json) {
id = json['id'];
isOnline = json['is_online'];
userId = json['user_id'];
nickName = json['nick_name'];
profilePic = json['profile_pic'];
gender = json['gender'];
age = json['age'];
cityId = json['city_id'];
birth = json['birth'];
registerTime = json['register_time'];
isBind = json['is_bind'];
logined = json['logined'];
hasAnswered = json['has_answered'];
hasScanFace = json['has_scan_face'];
insBindId = json['ins_bind_id'];
questionUrl = json['question_url'];
detailSetted = json['detail_setted'];
countryInfo = json['country_info'] != null
? new CountryInfo.fromJson(json['country_info'])
: null;
ageDisplay = json['age_display'];
tagSetted = json['tag_setted'];
hasSkinTexture = json['has_skin_texture'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['is_online'] = this.isOnline;
data['user_id'] = this.userId;
data['nick_name'] = this.nickName;
data['profile_pic'] = this.profilePic;
data['gender'] = this.gender;
data['age'] = this.age;
data['city_id'] = this.cityId;
data['birth'] = this.birth;
data['register_time'] = this.registerTime;
data['is_bind'] = this.isBind;
data['logined'] = this.logined;
data['has_answered'] = this.hasAnswered;
data['has_scan_face'] = this.hasScanFace;
data['ins_bind_id'] = this.insBindId;
data['question_url'] = this.questionUrl;
data['detail_setted'] = this.detailSetted;
if (this.countryInfo != null) {
data['country_info'] = this.countryInfo.toJson();
}
data['age_display'] = this.ageDisplay;
data['tag_setted'] = this.tagSetted;
data['has_skin_texture'] = this.hasSkinTexture;
return data;
}
}
class CountryInfo {
String name;
String id;
String language;
CountryInfo({this.name, this.id, this.language});
CountryInfo.fromJson(Map<String, dynamic> json) {
name = json['name'];
id = json['id'];
language = json['language'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['name'] = this.name;
data['id'] = this.id;
data['language'] = this.language;
return data;
}
}
class UserType {
UserType();
UserType.fromJson(Map<String, dynamic> json) {}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
return data;
}
}
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