Browse Source

修改UI, bug

null_safety
fmk 4 years ago
parent
commit
a2672450ed
  1. 30
      lib/generated/l10n.dart
  2. 62
      lib/home/home_page.dart
  3. 6
      lib/integral/integral_page.dart
  4. 71
      lib/main_page.dart
  5. 100
      lib/union/store_details_page.dart
  6. 28
      lib/union/union_page.dart
  7. 4
      lib/view_widget/icon_text.dart
  8. 6
      pubspec.lock
  9. 5
      pubspec.yaml

30
lib/generated/l10n.dart

@ -3985,36 +3985,6 @@ class S {
);
}
/// ``
String get xieyitanchuang {
return Intl.message(
'一心回乡用户隐私政策',
name: 'xieyitanchuang',
desc: '',
args: [],
);
}
/// ``
String get yinsixieyi {
return Intl.message(
'《隐私协议》',
name: 'yinsixieyi',
desc: '',
args: [],
);
}
/// ``
String get shiyongmendian {
return Intl.message(
'适用门店',
name: 'shiyongmendian',
desc: '',
args: [],
);
}
/// `使`
String get privacy_policy4 {
return Intl.message(

62
lib/home/home_page.dart

@ -177,36 +177,36 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
child: Column(
children: [
banner(),
ItemTitle(
text: S
.of(context)
.jinrihuiyuanrenwu,
imgPath: "assets/image/icon_today_task.png",
moreText: S
.of(context)
.renwuzhongxin,
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString('token') == null) {
loginTips();
} else {
Navigator.of(context).pushNamed('/router/integral_page');
}
});
},
),
InkWell(
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString('token') == null) {
loginTips();
} else {
Navigator.of(context).pushNamed('/router/integral_page');
}
});
},
child: signIn(),
),
// ItemTitle(
// text: S
// .of(context)
// .jinrihuiyuanrenwu,
// imgPath: "assets/image/icon_today_task.png",
// moreText: S
// .of(context)
// .renwuzhongxin,
// onTap: () {
// SharedPreferences.getInstance().then((value) {
// if (value.getString('token') == null) {
// loginTips();
// } else {
// Navigator.of(context).pushNamed('/router/integral_page');
// }
// });
// },
// ),
// InkWell(
// onTap: () {
// SharedPreferences.getInstance().then((value) {
// if (value.getString('token') == null) {
// loginTips();
// } else {
// Navigator.of(context).pushNamed('/router/integral_page');
// }
// });
// },
// child: signIn(),
// ),
ItemTitle(
text: S
.of(context)
@ -612,7 +612,7 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
child: ListView.builder(
padding: EdgeInsets.only(left: 10.w, right: 10.w),
scrollDirection: Axis.horizontal,
physics: ClampingScrollPhysics(),
physics: BouncingScrollPhysics(),
itemBuilder: (context, position) {
return Container(
height: 60.h,

6
lib/integral/integral_page.dart

@ -37,8 +37,9 @@ class _IntegralPage extends State<IntegralPage> {
SharedPreferences.getInstance().then((value) {
apiService =
ApiService(Dio(), context: context, token: value.getString("token"));
ApiService(Dio(), context: context, token: value.getString("token"), showLoading: false);
userinfo = UserInfo.fromJson(jsonDecode(value.getString("user")));
SmartDialog.showLoading(msg: S.of(context).zhengzaijiazai);
querySignInfo();
});
}
@ -62,7 +63,7 @@ class _IntegralPage extends State<IntegralPage> {
.indexWhere((element) => element.id == userinfo.memberRankVo.id) +
1);
}
SmartDialog.dismiss();
if (baseData != null && baseData.isSuccess) {
signInfo = SignInfo.fromJson(baseData.data);
setState(() {});
@ -511,6 +512,7 @@ class _IntegralPage extends State<IntegralPage> {
SmartDialog.showToast("今日已签到了");
return;
}
SmartDialog.showLoading(msg: S.of(context).zhengzaijiazai);
BaseData baseData = await apiService.signIn();
if (baseData != null && baseData.isSuccess) {
querySignInfo();

71
lib/main_page.dart

@ -23,6 +23,7 @@ class MainPage extends StatefulWidget {
}
class _MainPage extends State<MainPage> {
List<Widget> _widgetOptions;
List<String> icons;
@ -32,6 +33,8 @@ class _MainPage extends State<MainPage> {
void initState() {
super.initState();
pushRoute();
_widgetOptions = <Widget>[
BrandPage(),
MainHomePage(),
@ -64,32 +67,10 @@ class _MainPage extends State<MainPage> {
xgFlutterPlugin.addEventHandler(xgPushClickAction: (event) async {
print("xgPushClickAction1: ${event.toString()}");
if (event["actionType"] == 2) return event;
Map<String, dynamic> customMessage = jsonDecode(event["customMessage"]);
if (event["actionType"] == 0 && customMessage != null) {
String routeName = "";
Map<String, dynamic> params = {};
switch(customMessage["typed"]) {
case 1://articleId
routeName = "/router/store_detail_page";
params["articleId"] = customMessage["info"];
break;
case 2://activityId
routeName = "/router/store_detail_page";
params["activityId"] = customMessage["info"];
break;
case 3://id
routeName = "/router/union_detail_page";
params["id"] = customMessage["info"];
break;
case 4://goodsId
routeName = "/router/integral_store_page";
params["goodsId"] = customMessage["info"];
break;
}
print("xgPushClickAction: routeName: $routeName");
if (routeName != "") {
Navigator.of(context).pushNamed(routeName, arguments: params);
}
if (event["actionType"] == 0 && event["customMessage"] != null) {
SharedPreferences.getInstance().then((value) {
value.setString("pushData", event["customMessage"]);
});
}
return event;
}, onReceiveNotificationResponse: (event) async {
@ -102,6 +83,40 @@ class _MainPage extends State<MainPage> {
}
pushRoute() async {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
String pushData = sharedPreferences.getString("pushData");
if (pushData == null || pushData == "") return;
Map<String, dynamic> pushMap = jsonDecode(pushData);
if (pushMap != null) {
String routeName = "";
Map<String, dynamic> params = {};
switch(pushMap["typed"]) {
case 1:
routeName = "/router/store_detail_page";
params["articleId"] = pushMap["info"];
break;
case 2:
routeName = "/router/store_detail_page";
params["activityId"] = pushMap["info"];
break;
case 3:
routeName = "/router/union_detail_page";
params["id"] = pushMap["info"];
break;
case 4:
routeName = "/router/integral_store_page";
params["goodsId"] = pushMap["info"];
break;
}
sharedPreferences.setString("pushData", "");
print("xgPushClickAction: routeName: $routeName");
if (routeName != "") {
Navigator.of(context).pushNamed(routeName, arguments: params);
}
}
}
queryUserInfo() async {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
if (sharedPreferences.getString("token") == null || sharedPreferences.getString("token") == "") return;
@ -122,7 +137,7 @@ class _MainPage extends State<MainPage> {
}
}
PageController pageController = PageController();
PageController pageController = PageController(initialPage: 1);
@override
Widget build(BuildContext context) {
@ -172,7 +187,7 @@ class _MainPage extends State<MainPage> {
);
}
var clickIndex = 0;
var clickIndex = 1;
Widget bottomNavigationItem(text, index) {
var isSelected = index == clickIndex;

100
lib/union/store_details_page.dart

@ -1,3 +1,6 @@
import 'dart:io';
import 'package:chewie_audio/chewie_audio.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
@ -13,6 +16,12 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'package:sharesdk_plugin/sharesdk_defines.dart';
import 'package:sharesdk_plugin/sharesdk_interface.dart';
import 'package:sharesdk_plugin/sharesdk_map.dart';
import 'package:video_player/video_player.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:flutter_html/src/replaced_element.dart';
import 'package:flutter/cupertino.dart';
import 'package:chewie/src/chewie_progress_colors.dart' as chewie;
import 'package:chewie/chewie.dart';
class StoreDetailsPage extends StatefulWidget {
final Map<String, dynamic> arguments;
@ -33,6 +42,8 @@ class _StoreDetailsPage extends State<StoreDetailsPage> {
void initState() {
super.initState();
if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView();
SharedPreferences.getInstance().then((value) {
apiService =
ApiService(Dio(), context: context, token: value.getString("token"));
@ -58,11 +69,6 @@ class _StoreDetailsPage extends State<StoreDetailsPage> {
}
share() async {
// await registerWxApi(appId: "wx3b269e795ed23e5f", doOnAndroid: true, universalLink: "https://hx.lotus-wallet.com/app/");
// shareToWeChat(WeChatShareWebPageModel(
// "http://hx.lotus-wallet.com/index.html?id=${widget.arguments["activityId"] ?? widget.arguments["articleId"]}",
// scene: WeChatScene.SESSION));
// SharesdkPlugin.showMenu();
SSDKMap params = SSDKMap()
..setGeneral(
activity != null
@ -152,14 +158,14 @@ class _StoreDetailsPage extends State<StoreDetailsPage> {
? article.mainTitle
: "",
style: TextStyle(
fontSize: 16,
fontSize: 16.sp,
fontWeight: FontWeight.bold,
color: Color(0xFF353535),
),
),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 12),
padding: EdgeInsets.symmetric(horizontal: 12.w),
child: Row(
children: [
InkWell(
@ -212,6 +218,29 @@ class _StoreDetailsPage extends State<StoreDetailsPage> {
return Container();
}),
},
customRender: {
"video" : (context, parsedChild, attributes, element) {
print("video attributes: ${element.attributes}");
print("video attributes: ${element.attributeSpans}");
print("video attributes: ${element.children.first.attributes["src"]}");
print("video attributes: ${parsedChild}");
return videoWidget(double.tryParse(attributes['width'] ?? ""), double.tryParse(element.attributes['height'] ?? ""), element.children.first.attributes["src"], element.attributes["sandbox"]);
},
"iframe" : (context, parsedChild, attributes, element) {
print("iframe attributes: ${element.toString()}");
print("iframe attributes: ${parsedChild}");
return videoWidget(double.tryParse(attributes['width'] ?? ""), double.tryParse(element.attributes['height'] ?? ""), element.children.first.attributes["src"], element.attributes["sandbox"]);
},
"audio" : (context, parsedChild, attributes, element) {
final sources = <String>[
if (element.attributes['src'] != null) element.attributes['src'],
];
if (sources == null || sources.isEmpty || sources.first == null) {
return EmptyContentElement();
}
return audioWidget(attributes['controls'] != null, attributes['loop'] != null, attributes['autoplay'] != null, sources, context.style.width ?? 300.w);
},
},
),
],
),
@ -220,10 +249,65 @@ class _StoreDetailsPage extends State<StoreDetailsPage> {
);
}
VideoPlayerController videoPlayerController;
ChewieController chewieAudioController;
Chewie chewies;
Widget videoWidget(double width, double height, src, sandboxMode) {
print("src : $src");
return Container(
width: MediaQuery.of(context).size.width,
height: (MediaQuery.of(context).size.width) / (width / height),
child: chewies = Chewie(
controller: chewieAudioController = ChewieController(
videoPlayerController: videoPlayerController = VideoPlayerController.network(
src,
),
aspectRatio: width / height,
//
autoPlay: !true,
//
looping: false,
//
//
materialProgressColors: chewie.ChewieProgressColors(
playedColor: Colors.white,
handleColor: Colors.white,
backgroundColor: Colors.grey,
bufferedColor: Colors.transparent,
),
autoInitialize: true,
),
),
);
}
Widget audioWidget(showControls, loop, autoplay, src, width) {
return Container(
width: width,
child: chewies = Chewie(
controller: chewieAudioController = ChewieController(
videoPlayerController: VideoPlayerController.network(
src.first ?? "",
),
autoPlay: autoplay,
looping: loop,
showControls: showControls,
autoInitialize: true,
),
),
);
}
@override
void dispose() {
super.dispose();
if (chewieAudioController != null)
chewieAudioController.dispose();
if (videoPlayerController != null)
videoPlayerController.dispose();
super.dispose();
}
}

28
lib/union/union_page.dart

@ -19,6 +19,7 @@ import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/event_type.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/icon_text.dart';
import 'package:huixiang/view_widget/item_title.dart';
import 'package:amap_flutter_base/amap_flutter_base.dart';
import 'package:amap_flutter_map/amap_flutter_map.dart';
@ -649,6 +650,9 @@ class _UnionPage extends State<UnionPage>
),
],
),
SizedBox(
width: 4.w,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
@ -692,30 +696,32 @@ class _UnionPage extends State<UnionPage>
child: Container(),
flex: 1,
),
Container(
alignment: Alignment.centerRight,
child: Text(
store.address,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Color(0xFF727272),
fontSize: 12.sp,
),
IconText(
store.address,
isMax: true,
overFlow: TextOverflow.ellipsis,
textStyle: TextStyle(
color: Color(0xFF727272),
fontSize: 12.sp,
),
leftImage: "assets/image/icon_union_location_black.png",
iconSize: 14,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
IconText(
(store.openStartTime == null &&
store.openEndTime == null)
? S.of(context).quantian
: "${store.openStartTime.substring(0, store.openStartTime.lastIndexOf(":"))}-${store.openEndTime.substring(0, store.openEndTime.lastIndexOf(":"))}",
style: TextStyle(
textStyle: TextStyle(
color: Color(0xFFA29E9E),
fontSize: 12.sp,
),
leftImage: "assets/image/icon_union_time.png",
iconSize: 14,
),
Visibility(
child: Text(

4
lib/view_widget/icon_text.dart

@ -10,6 +10,7 @@ class IconText extends StatelessWidget {
final double iconSize;
final double space;
final Color iconColor;
final TextOverflow overFlow;
final CrossAxisAlignment textAxisAlignment;
final bool isMax;
@ -22,6 +23,7 @@ class IconText extends StatelessWidget {
this.isMax = false,
this.iconSize = 16,
this.space = 1,
this.overFlow = TextOverflow.fade,
this.textAxisAlignment = CrossAxisAlignment.center,
this.iconColor = Colors.black,
this.textStyle});
@ -58,12 +60,14 @@ class IconText extends StatelessWidget {
widgets.add(isMax ? Expanded(
child: Text(
text,
overflow: overFlow,
textAlign: TextAlign.start,
style: textStyle,
),
flex: 1,
) : Text(
text,
overflow: overFlow,
textAlign: TextAlign.center,
style: textStyle,
));

6
pubspec.lock

@ -170,14 +170,14 @@ packages:
source: hosted
version: "1.0.4"
chewie:
dependency: "direct main"
dependency: transitive
description:
name: chewie
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.12.2"
chewie_audio:
dependency: transitive
dependency: "direct main"
description:
name: chewie_audio
url: "https://pub.flutter-io.cn"
@ -1023,7 +1023,7 @@ packages:
source: hosted
version: "1.2.0"
webview_flutter:
dependency: transitive
dependency: "direct main"
description:
name: webview_flutter
url: "https://pub.flutter-io.cn"

5
pubspec.yaml

@ -85,9 +85,10 @@ dependencies:
cached_network_image: ^2.0.0
flutter_html: ^1.3.0 #2.1.0
photo_view: ^0.11.1
webview_flutter: ^1.0.7
chewie_audio: ^1.1.2
chewie: ^0.12.2
photo_view: ^0.11.1
video_player: ^1.0.1
package_info: ^2.0.2

Loading…
Cancel
Save