Commit 4e01db3a authored by 林生雨's avatar 林生雨

temp

parent d94ecc47
/*
* @author lsy
* @date 2020-01-02
**/
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_common/flutter_common.dart';
import 'package:gm_flutter/commonModel/base/BaseComponent.dart';
class MessageBarView extends StatelessWidget {
final LiveData<int> topIndexLive;
final LiveData<double> topScrollLive;
final PageController pageController;
bool leftShow = false;
bool rightShow = false;
MessageBarView({
this.topIndexLive,
this.topScrollLive,
this.pageController,
}) {}
@override
Widget build(BuildContext context) {
return topView(context);
}
Widget topViewItem(String text, int index) {
return StreamBuilder(
stream: topIndexLive.stream,
initialData: topIndexLive.data ?? 0.0,
builder: (con, data) {
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
// pageController.jumpToPage(index);
pageController.animateToPage(index,
duration: Duration(milliseconds: 200), curve: Curves.ease);
},
child: Container(
alignment: Alignment.bottomCenter,
width: double.maxFinite,
height: double.maxFinite,
child: baseText(text, 16,
data.data == index ? Color(0xff282828) : Color(0xffB5B5B5)),
),
);
},
);
}
Widget topView(BuildContext context) {
return Container(
height: 49,
width: double.maxFinite,
child: Column(
children: <Widget>[
Expanded(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(child: topViewItem("价格", 0)),
Expanded(child: topViewItem("医院", 1)),
Expanded(child: topViewItem("医生", 2)),
Expanded(child: topViewItem("评价", 3)),
],
),
),
Container(
alignment: Alignment.topLeft,
height: 8,
margin: EdgeInsets.only(top: 4, bottom: 5),
width: double.maxFinite,
child: StreamBuilder(
stream: topScrollLive.stream,
initialData: topScrollLive.data ?? 0.0,
builder: (con, data) {
return Container(
margin: EdgeInsets.only(
left: MediaQuery.of(context).size.width / 12 +
4.5 +
data.data),
width: 22,
height: 3,
decoration: BoxDecoration(
borderRadius: new BorderRadius.circular((1.5)),
color: Color(0xff3FB5AF),
),
);
},
),
)
],
),
);
}
}
......@@ -6,6 +6,7 @@ import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:gm_flutter/ClueModel/server/entity/LevelOneFeedList.dart';
import 'package:gm_flutter/ClueModel/view/FiveStarView.dart';
import 'package:gm_flutter/commonModel/base/BaseComponent.dart';
import 'package:gm_flutter/commonModel/base/BaseUtil.dart';
......@@ -161,7 +162,12 @@ class LevelOneItem extends StatelessWidget {
Positioned(
bottom: 67,
left: 57,
child: baseText(cards.hospital.name, 12, Color(0xff666666)),
child: baseText(cards.hospital.address, 12, Color(0xff666666)),
),
Positioned(
left: 57,
top: 43.5,
child: FiveStarView(cards.hospital.star, 5),
)
],
),
......@@ -191,7 +197,7 @@ class LevelOneItem extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
baseText("¥", 12, Color(0xffFF5963)),
baseText(cards.plan, 15, Color(0xffFF5963))
baseText(cards.plan.maxPrice, 15, Color(0xffFF5963))
],
),
),
......
/*
* @author lsy
* @date 2020/6/29
**/
import 'package:flutter_common/commonModel/live/BaseModel.dart';
import 'package:flutter_common/commonModel/live/LiveData.dart';
import 'package:gm_flutter/ClueModel/server/api/ClueApi.serv.dart';
import 'package:gm_flutter/ClueModel/server/entity/LevelOneFeedList.dart';
import 'package:gm_flutter/commonModel/GMBase.dart';
import 'package:gm_flutter/commonModel/bean/Pair.dart';
import 'package:gm_flutter/commonModel/rx/RxDispose.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
class LevelOneModel extends BaseModel {
LiveData<double> appBarLive = LiveData();
LiveData<List<String>> rectLive = LiveData();
LiveData<List<String>> explainLive = LiveData();
LiveData<bool> showTab = LiveData();
LiveData<int> topIndexLive = new LiveData();
LiveData<double> topScrollLive = new LiveData();
RxDispose rxDispose = RxDispose();
LiveData<Pair<int,List<Cards>>> cardsLive = LiveData();
Map<int, List<Cards>> data = new Map();
List list = ["plan", "hospital", "doctor", "diary"];
List pageList = [1, 1, 1, 1];
void refreshView(bool clear, {RefreshController refreshListener}) {
int index = currentIndex;
if (clear) {
data.clear();
pageList = [1, 1, 1, 1];
}
ClueApiImpl.getInstance()
.getLevelOneList(
DioUtil.getInstance().getDio(), 123, list[index], pageList[index])
.listen((event) {
}).addToDispose(rxDispose).onError((err) {
});
}
int currentIndex = 0;
@override
void dispose() {
showTab.dispost();
cardsLive.dispost();
appBarLive.dispost();
rectLive.dispost();
topIndexLive.dispost();
topScrollLive.dispost();
}
void selectPage(int index) {
if (currentIndex == index) {
return;
}
currentIndex = index;
}
}
......@@ -3,10 +3,13 @@
* @date 2020/6/28
**/
import 'package:flutter_common/Annotations/anno/Get.dart';
import 'package:flutter_common/Annotations/anno/Query.dart';
import 'package:flutter_common/Annotations/anno/ServiceCenter.dart';
import 'package:gm_flutter/ClueModel/server/entity/LevelOneFeedList.dart';
@ServiceCenter()
class ClueApi {
}
\ No newline at end of file
abstract class ClueApi {
@Get("api/janus/plans/plan_feed")
LevelOneFeedList getLevelOneList(@Query("plan_id") int plan_id,
@Query("tab_type") String tab_type, @Query("page") int page);
}
......@@ -14,6 +14,8 @@ import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:gm_flutter/ClueModel/server/entity/LevelOneFeedList.dart';
const bool inProduction = const bool.fromEnvironment("dart.vm.product");
class ClueApiImpl {
......@@ -30,6 +32,23 @@ class ClueApiImpl {
return _instance;
}
Stream<LevelOneFeedList> getLevelOneList(
Dio _dio, int plan_id, String tab_type, int page) {
return Stream.fromFuture(get(_dio, 'api/janus/plans/plan_feed', data: {
'plan_id': plan_id,
'tab_type': tab_type,
'page': page,
})).flatMap((value) {
if (value != null &&
(value.statusCode >= 200 && value.statusCode < 300)) {
return Stream.fromFuture(
compute(parseLevelOneFeedList, value.toString()));
} else {
throw Exception("--未知网络错误--");
}
});
}
///==================base method==================
Future<Response> get(Dio _dio, url, {data, options, cancelToken}) async {
......@@ -166,3 +185,7 @@ class ClueApiImpl {
return reason;
}
}
LevelOneFeedList parseLevelOneFeedList(String value) {
return LevelOneFeedList.fromJson(json.decode(value));
}
......@@ -10,7 +10,9 @@ class LevelOneFeedList {
LevelOneFeedList.fromJson(Map<String, dynamic> json) {
if (json['cards'] != null) {
cards = new List<Cards>();
json['cards'].forEach((v) { cards.add(new Cards.fromJson(v)); });
json['cards'].forEach((v) {
cards.add(new Cards.fromJson(v));
});
}
}
......@@ -35,8 +37,11 @@ class Cards {
Cards.fromJson(Map<String, dynamic> json) {
cardType = json['card_type'];
plan = json['plan'] != null ? new Plan.fromJson(json['plan']) : null;
hospital = json['hospital'] != null ? new Hospital.fromJson(json['hospital']) : null;
doctor = json['doctor'] != null ? new Hospital.fromJson(json['doctor']) : null;
hospital = json['hospital'] != null
? new Hospital.fromJson(json['hospital'])
: null;
doctor =
json['doctor'] != null ? new Hospital.fromJson(json['doctor']) : null;
diary = json['diary'] != null ? new Diary.fromJson(json['diary']) : null;
}
......@@ -70,7 +75,16 @@ class Plan {
String consultUrl;
String phoneAuthroize;
Plan({this.planName, this.minPrice, this.maxPrice, this.positiveRate, this.salesCount, this.baseAttrs, this.projectImage, this.consultUrl, this.phoneAuthroize});
Plan(
{this.planName,
this.minPrice,
this.maxPrice,
this.positiveRate,
this.salesCount,
this.baseAttrs,
this.projectImage,
this.consultUrl,
this.phoneAuthroize});
Plan.fromJson(Map<String, dynamic> json) {
planName = json['plan_name'];
......@@ -80,7 +94,9 @@ class Plan {
salesCount = json['sales_count'];
if (json['base_attrs'] != null) {
baseAttrs = new List<BaseAttrs>();
json['base_attrs'].forEach((v) { baseAttrs.add(new BaseAttrs.fromJson(v)); });
json['base_attrs'].forEach((v) {
baseAttrs.add(new BaseAttrs.fromJson(v));
});
}
projectImage = json['project_image'];
consultUrl = json['consult_url'];
......@@ -128,20 +144,33 @@ class Hospital {
String name;
String minPrice;
String maxPrice;
String address;
int star;
List<BaseAttrs> baseAttrs;
String consultUrl;
String phoneAuthroize;
Hospital({this.portrait, this.name, this.minPrice, this.maxPrice, this.baseAttrs, this.consultUrl, this.phoneAuthroize});
Hospital(
{this.portrait,
this.name,
this.minPrice,
this.maxPrice,
this.baseAttrs,
this.consultUrl,
this.phoneAuthroize});
Hospital.fromJson(Map<String, dynamic> json) {
portrait = json['portrait'];
name = json['name'];
star = json['star'];
address = json['address'];
minPrice = json['min_price'];
maxPrice = json['max_price'];
if (json['base_attrs'] != null) {
baseAttrs = new List<BaseAttrs>();
json['base_attrs'].forEach((v) { baseAttrs.add(new BaseAttrs.fromJson(v)); });
json['base_attrs'].forEach((v) {
baseAttrs.add(new BaseAttrs.fromJson(v));
});
}
consultUrl = json['consult_url'];
phoneAuthroize = json['phone_authroize'];
......@@ -153,6 +182,8 @@ class Hospital {
data['name'] = this.name;
data['min_price'] = this.minPrice;
data['max_price'] = this.maxPrice;
data['address'] = this.address;
data['star'] = this.star;
if (this.baseAttrs != null) {
data['base_attrs'] = this.baseAttrs.map((v) => v.toJson()).toList();
}
......@@ -201,7 +232,44 @@ class Diary {
UserLevel userLevel;
int serviceId;
Diary({this.diaryNum, this.videoUrl, this.isIdentification, this.isLiked, this.titleStyleType, this.replyNum, this.lasestTopicCreatedTime, this.images, this.relationServiceSku, this.createdTime, this.latestTopicId, this.id, this.city, this.userId, this.title, this.isVoted, this.diaryId, this.preImageList, this.voteNum, this.tagsNewEra, this.content, this.videoPic, this.shortVideoUrl, this.diaryAmount, this.diaryTitle, this.authorType, this.tags, this.contentLevel, this.lastModified, this.user, this.isOnline, this.date, this.membershipLevel, this.viewNum, this.postImageList, this.userLevel, this.serviceId});
Diary(
{this.diaryNum,
this.videoUrl,
this.isIdentification,
this.isLiked,
this.titleStyleType,
this.replyNum,
this.lasestTopicCreatedTime,
this.images,
this.relationServiceSku,
this.createdTime,
this.latestTopicId,
this.id,
this.city,
this.userId,
this.title,
this.isVoted,
this.diaryId,
this.preImageList,
this.voteNum,
this.tagsNewEra,
this.content,
this.videoPic,
this.shortVideoUrl,
this.diaryAmount,
this.diaryTitle,
this.authorType,
this.tags,
this.contentLevel,
this.lastModified,
this.user,
this.isOnline,
this.date,
this.membershipLevel,
this.viewNum,
this.postImageList,
this.userLevel,
this.serviceId});
Diary.fromJson(Map<String, dynamic> json) {
diaryNum = json['diary_num'];
......@@ -213,9 +281,13 @@ class Diary {
lasestTopicCreatedTime = json['lasest_topic_created_time'];
if (json['images'] != null) {
images = new List<Images>();
json['images'].forEach((v) { images.add(new Images.fromJson(v)); });
json['images'].forEach((v) {
images.add(new Images.fromJson(v));
});
}
relationServiceSku = json['relation_service_sku'] != null ? new RelationServiceSku.fromJson(json['relation_service_sku']) : null;
relationServiceSku = json['relation_service_sku'] != null
? new RelationServiceSku.fromJson(json['relation_service_sku'])
: null;
createdTime = json['created_time'];
latestTopicId = json['latest_topic_id'];
id = json['id'];
......@@ -228,7 +300,9 @@ class Diary {
voteNum = json['vote_num'];
if (json['tags_new_era'] != null) {
tagsNewEra = new List<TagsNewEra>();
json['tags_new_era'].forEach((v) { tagsNewEra.add(new TagsNewEra.fromJson(v)); });
json['tags_new_era'].forEach((v) {
tagsNewEra.add(new TagsNewEra.fromJson(v));
});
}
content = json['content'];
videoPic = json['video_pic'];
......@@ -238,7 +312,9 @@ class Diary {
authorType = json['author_type'];
if (json['tags'] != null) {
tags = new List<Tags>();
json['tags'].forEach((v) { tags.add(new Tags.fromJson(v)); });
json['tags'].forEach((v) {
tags.add(new Tags.fromJson(v));
});
}
contentLevel = json['content_level'];
lastModified = json['last_modified'];
......@@ -248,7 +324,9 @@ class Diary {
membershipLevel = json['membership_level'];
viewNum = json['view_num'];
postImageList = json['post_image_list'].cast<String>();
userLevel = json['user_level'] != null ? new UserLevel.fromJson(json['user_level']) : null;
userLevel = json['user_level'] != null
? new UserLevel.fromJson(json['user_level'])
: null;
serviceId = json['service_id'];
}
......@@ -318,7 +396,16 @@ class Images {
String imageHalf;
String desc;
Images({this.imageWide, this.imageType, this.image, this.sImagePlatform, this.imageSlimwidth, this.smallWide, this.imageThumb, this.imageHalf, this.desc});
Images(
{this.imageWide,
this.imageType,
this.image,
this.sImagePlatform,
this.imageSlimwidth,
this.smallWide,
this.imageThumb,
this.imageHalf,
this.desc});
Images.fromJson(Map<String, dynamic> json) {
imageWide = json['image_wide'];
......@@ -348,17 +435,14 @@ class Images {
}
class RelationServiceSku {
RelationServiceSku();
RelationServiceSku.fromJson(Map<String, dynamic> json) {
}
RelationServiceSku.fromJson(Map<String, dynamic> json) {}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
return data;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
return data;
}
}
class TagsNewEra {
......@@ -395,7 +479,14 @@ class User {
String userName;
String membershipLevel;
User({this.city, this.userId, this.topicNumPosted, this.voteNumGained, this.portrait, this.userName, this.membershipLevel});
User(
{this.city,
this.userId,
this.topicNumPosted,
this.voteNumGained,
this.portrait,
this.userName,
this.membershipLevel});
User.fromJson(Map<String, dynamic> json) {
city = json['city'];
......
/*
* @author lsy
* @date 2020/6/30
**/
import 'package:flutter/cupertino.dart';
class PosUtil {
static Offset findPos(GlobalKey globalKey) {
Offset offset;
if (globalKey.currentContext != null) {
RenderBox box = globalKey.currentContext.findRenderObject();
offset = box.localToGlobal(Offset.zero);
}
return offset;
}
}
......@@ -9,4 +9,3 @@ export 'base/BaseUtil.dart';
export 'net/Api.dart';
export 'net/DioUtil.dart';
export 'picker/loadingPicker.dart';
export 'util/DartUtil.dart';
......@@ -5,10 +5,13 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_common/commonModel/eventbus/GlobalEventBus.dart';
import 'package:flutter_common/commonModel/view/iOSLoading.dart';
import 'package:flutter_svg/svg.dart';
import 'package:gm_flutter/commonModel/GMBase.dart';
import 'package:gm_flutter/commonModel/util/DartUtil.dart';
import 'package:gm_flutter/commonModel/view/ImagesAnimation.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
double SCREENWIDTH;
......@@ -25,9 +28,8 @@ AppBar baseAppBar(
double elevation = 0.0,
Widget titleWidget = null}) {
return _baseAppBarChangeTitle(
title: title == null
? Container()
: baseText(title, 16, Color(0xff323232)),
title:
title == null ? Container() : baseText(title, 16, Color(0xff323232)),
action: action,
centerTitle: centerTitle,
backClick: backClick,
......@@ -248,8 +250,86 @@ Widget baseRedPoint(int num) {
alignment: Alignment.center,
width: 15,
height: 15,
decoration:
BoxDecoration(shape: BoxShape.circle, color: Color(0xffFF5963)),
decoration: BoxDecoration(shape: BoxShape.circle, color: Color(0xffFF5963)),
child: baseText("${num}", 11, Color(0xffFFFFFF)),
);
}
Widget baseRefreshView(RefreshController refreshController,
VoidCallback refresh, Widget topFix, Widget List,
{bool pullUp = false,
bool pullDown = true,
VoidCallback onLoading,
ScrollController scrollController,
CustomScrollView customScrollView}) {
return SmartRefresher(
enablePullDown: pullDown,
enablePullUp: pullUp,
onLoading: onLoading ?? () {},
header: normalRefreshHeader(),
controller: refreshController,
onRefresh: refresh,
footer: CustomFooter(
builder: (BuildContext context, LoadStatus mode) {
Widget body;
// if (mode == LoadStatus.idle) {
// body = baseText("准备加载", 12, Color(0xff545454));
// } else
if (mode == LoadStatus.loading) {
body = baseText("加载中", 12, Color(0xff545454));
} else if (mode == LoadStatus.failed) {
body = baseText("加载失败", 12, Color(0xff545454));
} else if (mode == LoadStatus.noMore) {
body = baseText("没有更多数据了", 12, Color(0xff545454));
} else {
body = Container();
}
return Container(
height: 55.0,
child: Center(child: body),
);
},
),
child: customScrollView ??
CustomScrollView(
controller: scrollController,
slivers: <Widget>[
SliverToBoxAdapter(
child: topFix,
),
List,
],
));
}
Widget normalRefreshHeader() {
return CustomHeader(
builder: (BuildContext context, RefreshStatus mode) {
Widget body;
// if (mode == RefreshStatus.idle) {
//
// } else
if (mode == RefreshStatus.refreshing) {
body = ImagesAnimation(
w: 46,
h: 15,
durationSeconds: 1500,
entry: ImagesAnimationEntry(1, 20, "assets/ptr_header_loading"));
}
// else if (mode == RefreshStatus.failed) {
// body = Text("Load Failed!Click retry!");
// }
else {
body = Image.asset(
"assets/ptr_header_loading01.png",
width: 46,
height: 15,
);
}
return Container(
height: 55.0,
child: Center(child: body),
);
},
);
}
......@@ -70,7 +70,7 @@ class MyApp extends State<MyAppWidget> {
WindowUtil.setBarStatus(true);
return MaterialApp(
theme: ThemeData(),
builder: FlutterBoost.init(postPush: _onRoutePushed),
// builder: FlutterBoost.init(postPush: _onRoutePushed),
home: RouterCenterImpl().findClueRouter().getLevelOnePage());
}
......
......@@ -3,7 +3,7 @@ description: A new flutter module project.
version: 1.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
sdk: ">=2.6.0 <3.0.0"
dependencies:
flutter:
......
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