Commit 026a4810 authored by 林生雨's avatar 林生雨

commit

parent 79a469d6
......@@ -3,6 +3,7 @@
* @date 2019-09-16
**/
import 'package:flutter/material.dart';
import 'package:gmalpha_flutter/Annotations/RouterCenterRestore.mark.dart';
import 'package:gmalpha_flutter/PrestigeModel/service/PrestigeRepository.dart';
import 'package:gmalpha_flutter/PrestigeModel/service/remote/entity/PrestigeEntity.dart';
import 'package:gmalpha_flutter/commonModel/live/BaseModel.dart';
......@@ -20,8 +21,6 @@ class ReputationsModel extends BaseModel {
ReputationsModel(this.userId, this.userName, this.fromPage) {
prestigeLive = new LiveData();
titleLive = new LiveData();
print("lsy -->INIT!!!");
}
init(BuildContext context) {
......@@ -40,6 +39,10 @@ class ReputationsModel extends BaseModel {
void dispose() {
prestigeLive.dispost();
titleLive.dispost();
print("lsy -->DISPOST!!!");
}
void pop(BuildContext context, String pageName) {
RouterCenterImpl().findBuriedRouter()?.onClick(pageName, "return");
Navigator.pop(context);
}
}
......@@ -39,82 +39,84 @@ class ReputationsState extends BasePage<ReputationsPage> {
@override
Widget build(BuildContext context) {
screenWidth = MediaQuery.of(context).size.width;
return Scaffold(
appBar: AppBar(
title: StreamBuilder<String>(
stream: _model.titleLive.stream,
initialData: _model.titleLive.data,
builder: (context, data) {
if (data.data == null) {
return MyText(16, '我的专家声望', 0xff323232);
}
String titleWord = '${data.data}的专家声望';
if (titleWord.length > 10) {
titleWord = titleWord.substring(0, 10) + "...";
}
return MyText(16, titleWord, 0xff323232);
},
),
centerTitle: true,
leading: GestureDetector(
onTap: () {
RouterCenterImpl()
.findBuriedRouter()
?.onClick(pageName(), "return");
Navigator.pop(context, "");
},
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,
builder: (context, data) {
if (data.data == null) {
return loadingItem();
}
if (data.data.error != 0 || data.data.data == null) {
return errorItem(data.data.message);
}
return CustomScrollView(
slivers: <Widget>[
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
if (index == 0) {
return Container(
margin: EdgeInsets.fromLTRB(17, 24, 17, 0),
child: MyText(16.0, data.data.data.introduce[0].question,
0xff323232),
);
return WillPopScope(
child: Scaffold(
appBar: AppBar(
title: StreamBuilder<String>(
stream: _model.titleLive.stream,
initialData: _model.titleLive.data,
builder: (context, data) {
if (data.data == null) {
return MyText(16, '我的专家声望', 0xff323232);
}
if (index == 1) {
return Container(
margin: EdgeInsets.fromLTRB(19, 16, 19, 32),
child: Text(
data.data.data.introduce[0].answer,
style:
TextStyle(fontSize: 13, color: Color(0xff8E8E8E)),
));
String titleWord = '${data.data}的专家声望';
if (titleWord.length > 10) {
titleWord = titleWord.substring(0, 10) + "...";
}
if (index == data.data.data.reputations.length + 2) {
//bottom margin
return Container(
height: 20,
);
}
return listItem(data, index - 2);
}, childCount: data.data.data.reputations.length + 3)),
],
);
},
));
return MyText(16, titleWord, 0xff323232);
},
),
centerTitle: true,
leading: GestureDetector(
onTap: () {
_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,
builder: (context, data) {
if (data.data == null) {
return loadingItem();
}
if (data.data.error != 0 || data.data.data == null) {
return errorItem(data.data.message);
}
return CustomScrollView(
slivers: <Widget>[
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
if (index == 0) {
return Container(
margin: EdgeInsets.fromLTRB(17, 24, 17, 0),
child: MyText(16.0,
data.data.data.introduce[0].question, 0xff323232),
);
}
if (index == 1) {
return Container(
margin: EdgeInsets.fromLTRB(19, 16, 19, 32),
child: Text(
data.data.data.introduce[0].answer,
style: TextStyle(
fontSize: 13, color: Color(0xff8E8E8E)),
));
}
if (index == data.data.data.reputations.length + 2) {
//bottom margin
return Container(
height: 20,
);
}
return listItem(data, index - 2);
}, childCount: data.data.data.reputations.length + 3)),
],
);
},
)),
onWillPop: () {
_model.pop(context, pageName());
},
);
}
Widget listItem(AsyncSnapshot<PrestigeEntity> data, int index) {
......
/*
* @author lsy
* @date 2019-09-16
**/
\ No newline at end of file
......@@ -4,7 +4,9 @@
**/
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:gmalpha_flutter/res/GMRes.dart';
AppBar baseAppBar(
{String title,
......@@ -12,7 +14,7 @@ AppBar baseAppBar(
bool centerTitle,
VoidCallback backClick}) {
return AppBar(
title: title == null ? Container() : baseText(title, 16, 0xff323232),
title: title == null ? Container() : baseText(title, 16, ALColors.Color323232),
centerTitle: centerTitle,
leading: GestureDetector(
onTap: backClick,
......@@ -30,13 +32,24 @@ AppBar baseAppBar(
);
}
Text baseText(String text, double fontSize, int color) {
Text baseText(String text, double fontSize, Color color) {
return Text(
text,
style: TextStyle(fontSize: fontSize, color: Color(color)),
style: TextStyle(fontSize: fontSize, color: color),
);
}
Widget baseDivide(double height, int padding, Color color) {
return Container(
height: height,
margin: EdgeInsets.only(
right: ScreenUtil.instance.setWidth(padding),
left: ScreenUtil.instance.setWidth(padding)),
child: Container(
color: color,
));
}
Widget loadingItem() {
//TODO
return Center(child: CircularProgressIndicator());
......
......@@ -5,13 +5,13 @@ import 'dart:ui' show Color;
import 'package:flutter/painting.dart';
// 关于颜色的定义
// Color(0xFF323232);
// FF 表示透明度 323232 表示RGB颜色值
class ALColors {
ALColors._();
static const Color Color323232 = Color(0xFF323232);
static const Color Color464646 = Color(0xFF464646);
static const Color Color999999 = Color(0xFF999999);
......@@ -23,4 +23,4 @@ class ALColors {
static const Color ColorF4F3F8 = Color(0xFFf4f3f8);
static const Color Color282828 = Color(0xFF282828);
static const Color ColorE5E5E5 = Color(0xFFe5e5e5);
}
\ No newline at end of file
}
/*
* @author lsy
* @date 2019-10-16
**/
const STATIC_COUNTRY_JSON = """
{
"error": 0,
"message": "",
"extra": null,
"data": [
{
"title": "A",
"countries": [
{
"id": "America",
"name": "美国",
"language": "en"
},
{
"id": "Argentina",
"name": "阿根廷",
"language": "en"
},
{
"id": "Australia",
"name": "澳大利亚",
"language": "en"
}
]
},
{
"title": "B",
"countries": [
{
"id": "Belgium",
"name": "比利时",
"language": "en"
},
{
"id": "Brazil",
"name": "巴西",
"language": "en"
},
{
"id": "Brunei",
"name": "文莱",
"language": "en"
}
]
},
{
"title": "C",
"countries": [
{
"id": "Canada",
"name": "加拿大",
"language": "en"
},
{
"id": "china",
"name": "中国",
"language": "zh"
}
]
},
{
"title": "E",
"countries": [
{
"id": "Egypt",
"name": "埃及",
"language": "en"
},
{
"id": "England",
"name": "英国",
"language": "en"
}
]
},
{
"title": "F",
"countries": [
{
"id": "France",
"name": "法国",
"language": "fra"
}
]
},
{
"title": "H",
"countries": [
{
"id": "hanguo",
"name": "韩国",
"language": "kor"
}
]
},
{
"title": "I",
"countries": [
{
"id": "India",
"name": "印度",
"language": "en"
},
{
"id": "Indonesia",
"name": "印度尼西亚",
"language": "en"
},
{
"id": "Ireland",
"name": "爱尔兰",
"language": "en"
}
]
},
{
"title": "J",
"countries": [
{
"id": "Japan",
"name": "日本",
"language": "jp"
}
]
},
{
"title": "L",
"countries": [
{
"id": "Libya",
"name": "利比亚",
"language": "en"
}
]
},
{
"title": "M",
"countries": [
{
"id": "Malaysia",
"name": "马来西亚",
"language": "en"
},
{
"id": "Maldives",
"name": "马尔代夫",
"language": "en"
},
{
"id": "Mexico",
"name": "墨西哥",
"language": "en"
},
{
"id": "Morocco",
"name": "摩洛哥",
"language": "en"
}
]
},
{
"title": "N",
"countries": [
{
"id": "Netherlands",
"name": "荷兰",
"language": "en"
},
{
"id": "NewZealand",
"name": "新西兰",
"language": "en"
}
]
},
{
"title": "P",
"countries": [
{
"id": "Pakistan",
"name": "巴基斯坦",
"language": "en"
},
{
"id": "Paraguay",
"name": "巴拉圭",
"language": "en"
},
{
"id": "Portugal",
"name": "葡萄牙",
"language": "pt"
}
]
},
{
"title": "R",
"countries": [
{
"id": "Russia",
"name": "俄罗斯",
"language": "ru"
}
]
},
{
"title": "S",
"countries": [
{
"id": "singapore",
"name": "新加坡",
"language": "en"
},
{
"id": "Spain",
"name": "西班牙",
"language": "spa"
},
{
"id": "SriLanka",
"name": "斯里兰卡",
"language": "en"
}
]
},
{
"title": "T",
"countries": [
{
"id": "thailand",
"name": "泰国",
"language": "en"
}
]
},
{
"title": "U",
"countries": [
{
"id": "Uruguay",
"name": "乌拉圭",
"language": "en"
}
]
},
{
"title": "V",
"countries": [
{
"id": "Vietnam",
"name": "越南",
"language": "vie"
}
]
}
],
"user_type": {}
}
""";
......@@ -2,9 +2,12 @@
* @author lsy
* @date 2019-10-15
**/
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:gmalpha_flutter/commonModel/GMBase.dart';
import 'package:gmalpha_flutter/commonModel/toast/toast.dart';
import 'package:gmalpha_flutter/userModel/page/country/CountryJson.dart';
import 'package:gmalpha_flutter/userModel/service/UserRepository.dart';
import 'package:gmalpha_flutter/userModel/service/remote/entity/CountryBean.dart';
......@@ -17,6 +20,19 @@ class CountryModel extends BaseModel {
CountryModel(this.refer);
getCountries(BuildContext context) {
getStaticCountry().then((value) {
if (value != null) {
liveData.notifyView(value);
} else {
getCountryFromNet(context);
}
}).catchError((error) {
Toast.debugShow(context, error);
print(error);
});
}
getCountryFromNet(BuildContext context) {
UserRepository.getInstance().getCountries().listen((value) {
liveData.notifyView(value);
}).onError((error) {
......@@ -25,6 +41,10 @@ class CountryModel extends BaseModel {
});
}
Future getStaticCountry() async {
return await CountryBean.fromJson(json.decode(STATIC_COUNTRY_JSON));
}
@override
void dispose() {
liveData.dispost();
......
......@@ -86,7 +86,7 @@ class CountryState extends BasePage {
padding: EdgeInsets.only(
left: ScreenUtil.instance.setWidth(12),
),
child: baseText(head, 15, 0xFF323232),
child: baseText(head, 15, ALColors.Color323232),
);
}
......@@ -101,19 +101,23 @@ class CountryState extends BasePage {
margin: EdgeInsets.only(
left: ScreenUtil.instance.setWidth(12),
),
child: baseText(country.name, 15, 0xFF323232),
child: baseText(country.name, 15, ALColors.Color323232),
));
}
@override
void dispose() {
super.dispose();
_scrollController.dispose();
}
@override
String pageName() {
// TODO: implement pageName
return null;
return "country_page";
}
@override
String referrer() {
// TODO: implement referrer
return null;
return _model.refer;
}
}
......@@ -6,6 +6,7 @@
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';
......@@ -91,8 +92,9 @@ class UserSettingModel extends BaseModel {
saveLive.dispost();
}
void jumpToCAM(BuildContext context) {
jumpToCamera(context, refere, Api.PROVIDER_NAME, true, 1, null)
void jumpToCAM(BuildContext context, String pageName) {
clickEvent(pageName, "quit");
jumpToCamera(context, pageName, Api.PROVIDER_NAME, true, 1, null)
.then((value) {
if (value != null) {
selectImgPath = value[0];
......@@ -116,4 +118,8 @@ class UserSettingModel extends BaseModel {
print(error);
});
}
void quit(BuildContext context, String pageName) {
clickEvent(pageName, "quit");
}
}
......@@ -14,6 +14,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/res/GMRes.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';
......@@ -66,7 +67,7 @@ class UserState extends BasePage<UserSettingPage> {
padding: EdgeInsets.only(
right: ScreenUtil.instance.setWidth(30)),
child: Center(
child: baseText("保存", 14, 0xffC4C4C4),
child: baseText("保存", 14, ALColors.ColorC4C4C4),
),
);
} else {
......@@ -76,7 +77,7 @@ class UserState extends BasePage<UserSettingPage> {
padding: EdgeInsets.only(
right: ScreenUtil.instance.setWidth(30)),
child: Center(
child: baseText("保存", 14, 0xff323232),
child: baseText("保存", 14, ALColors.Color323232),
),
));
}
......@@ -89,7 +90,7 @@ class UserState extends BasePage<UserSettingPage> {
Container(
margin: EdgeInsets.fromLTRB(ScreenUtil.instance.setWidth(29),
ScreenUtil.instance.setWidth(25), 0, 0),
child: baseText("设置", 30, 0xff323232),
child: baseText("设置", 30, ALColors.Color323232),
),
Container(
width: ScreenUtil.instance.setWidth(127),
......@@ -101,7 +102,7 @@ class UserState extends BasePage<UserSettingPage> {
ScreenUtil.instance.setWidth(23)),
child: GestureDetector(
onTap: () {
_model.jumpToCAM(context);
_model.jumpToCAM(context, pageName());
},
child: Stack(
alignment: Alignment.bottomRight,
......@@ -114,6 +115,7 @@ class UserState extends BasePage<UserSettingPage> {
// return SvgPicture.asset("images/replace_head.svg");
return Container();
} else {
startTime = DateTime.now().millisecondsSinceEpoch;
return Container(
alignment: Alignment.center,
width: ScreenUtil.instance.setWidth(127),
......@@ -149,12 +151,12 @@ class UserState extends BasePage<UserSettingPage> {
initialData: _model.nameLive.data,
builder: (con, data) {
return Center(
child: baseText(data.data ?? "", 13, 0xff323232),
child: baseText(data.data ?? "", 13, ALColors.Color323232),
);
},
),
false),
divideLine(),
baseDivide(1, 30, ALColors.ColorE4E4E4),
baseItem(() {
_model.jumpToCTY(context, pageName());
},
......@@ -166,18 +168,18 @@ class UserState extends BasePage<UserSettingPage> {
return Container(
margin: EdgeInsets.only(
right: ScreenUtil.instance.setWidth(19)),
child: baseText(data.data ?? "", 13, 0xff323232),
child: baseText(data.data ?? "", 13, ALColors.Color323232),
);
},
),
true),
divideLine(),
baseDivide(1, 30, ALColors.ColorE4E4E4),
baseItem(() {
jumpToComment(context, pageName());
}, "意见与建议", null, true),
divideLine(),
baseDivide(1, 30, ALColors.ColorE4E4E4),
baseItem(() {}, "隐私声明", null, true),
divideLine(),
baseDivide(1, 30, ALColors.ColorE4E4E4),
],
),
Expanded(
......@@ -191,8 +193,10 @@ class UserState extends BasePage<UserSettingPage> {
left: ScreenUtil.instance.setWidth(30),
right: ScreenUtil.instance.setWidth(30)),
child: OutlineButton(
onPressed: () {},
child: baseText("退出登入", 14, 0xff323232),
onPressed: () {
_model.quit(context, pageName());
},
child: baseText("退出登入", 14, ALColors.Color323232),
borderSide: new BorderSide(color: Color(0xff323232)),
),
)
......@@ -201,17 +205,6 @@ class UserState extends BasePage<UserSettingPage> {
);
}
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(),
......@@ -223,7 +216,7 @@ class UserState extends BasePage<UserSettingPage> {
width: double.maxFinite,
child: Row(
children: <Widget>[
baseText(left, 13, 0xff323232),
baseText(left, 13, ALColors.Color323232),
Expanded(
child: Text(""),
),
......@@ -244,7 +237,7 @@ class UserState extends BasePage<UserSettingPage> {
@override
String pageName() {
return "TODO";
return "page_setting_up";
}
@override
......
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