添加火警显示

hmxc
小赖 4 years ago
parent 7dd4bf7d47
commit 26bded1b9e

Binary file not shown.

After

Width:  |  Height:  |  Size: 745 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

@ -116,6 +116,18 @@ class R {
static const String ASSETS_ICONS_APP_REDUCE_PNG =
'assets/icons/app_reduce.png';
/// ![preview](file:///Users/akufe/Documents/aku_community/assets/icons/appointment-address.png)
static const String ASSETS_ICONS_APPOINTMENT_ADDRESS_PNG =
'assets/icons/appointment-address.png';
/// ![preview](file:///Users/akufe/Documents/aku_community/assets/icons/appointment-code.png)
static const String ASSETS_ICONS_APPOINTMENT_CODE_PNG =
'assets/icons/appointment-code.png';
/// ![preview](file:///Users/akufe/Documents/aku_community/assets/icons/appointment_date.png)
static const String ASSETS_ICONS_APPOINTMENT_DATE_PNG =
'assets/icons/appointment_date.png';
/// ![preview](file:///Users/akufe/Documents/aku_community/assets/icons/article_count.png)
static const String ASSETS_ICONS_ARTICLE_COUNT_PNG =
'assets/icons/article_count.png';

@ -293,4 +293,7 @@ class _Message {
class _Facility {
String get type => '/user/facilitiesAppointment/findCategoryList';
///
String get appointment => '/user/facilitiesAppointment/list';
}

@ -6,12 +6,13 @@
import 'package:device_info_plus_web/device_info_plus_web.dart';
import 'package:firebase_core_web/firebase_core_web.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
import 'package:image_picker_for_web/image_picker_for_web.dart';
import 'package:package_info_plus_web/package_info_plus_web.dart';
import 'package:shared_preferences_web/shared_preferences_web.dart';
import 'package:url_launcher_web/url_launcher_web.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
// ignore: public_member_api_docs
void registerPlugins(Registrar registrar) {
DeviceInfoPlusPlugin.registerWith(registrar);

@ -1,5 +1,7 @@
import 'dart:io';
import 'package:aku_community/utils/message_parser.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@ -38,6 +40,7 @@ class MainInitialize {
static Future initJPush() async {
if (kIsWeb || Platform.isMacOS) return;
JPush jpush = new JPush();
Future<dynamic> Function(Map<String, dynamic>? message)? jPushLogger(
String type) {
return (Map<String, dynamic>? message) async {
@ -49,7 +52,10 @@ class MainInitialize {
}
jpush.addEventHandler(
onReceiveNotification: jPushLogger('onReceiveNotification'),
onReceiveNotification: (message) async {
LoggerData.addData(message, tag: 'onReceiveNotification');
await MessageParser(message).shot();
},
onOpenNotification: jPushLogger('onOpenNotification'),
onReceiveMessage: jPushLogger('onReceiveMessage'),
);

@ -1,3 +1,5 @@
import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
import 'package:json_annotation/json_annotation.dart';
part 'facility_appointment_model.g.dart';
@ -7,6 +9,13 @@ class FacilityAppointmentModel {
final int id;
final String code;
final String facilitiesName;
///
///* 1.(30)
///* 2.
///* 3.
///* 4.
///* 5.
final int status;
final String address;
final String appointmentStartDate;
@ -14,6 +23,53 @@ class FacilityAppointmentModel {
final String? nullifyReason;
final String? useEndDate;
DateTime? get appointmentStart => DateUtil.getDateTime(appointmentStartDate);
DateTime? get appointmentEnd => DateUtil.getDateTime(appointmentEndDate);
String get displayDate {
return '${DateUtil.formatDate(
appointmentStart,
format: 'yyyy-MM-dd HH:mm',
)}-${DateUtil.formatDate(
appointmentEnd,
format: 'HH:mm',
)}';
}
Color get statusColor {
switch (status) {
case 1:
return Colors.blue;
case 2:
return Color(0xFF2576E5);
case 3:
return Color(0xFFFB4702);
case 4:
return Color(0xFF999999);
case 5:
return Color(0xFF999999);
default:
return Color(0xFF999999);
}
}
String get statusValue {
switch (status) {
case 1:
return '未签到';
case 2:
return '签到成功';
case 3:
return '预约作废';
case 4:
return '已取消';
case 5:
return '已结束';
default:
return '未知状态';
}
}
FacilityAppointmentModel({
required this.id,
required this.code,

@ -0,0 +1,94 @@
import 'package:aku_community/models/facility/facility_appointment_model.dart';
import 'package:aku_community/widget/bee_divider.dart';
import 'package:flutter/material.dart';
import 'package:aku_community/utils/headers.dart';
class FacilityAppointmentCard extends StatelessWidget {
final FacilityAppointmentModel model;
const FacilityAppointmentCard({Key? key, required this.model})
: super(key: key);
Widget _renderTile({
required String path,
required String name,
required String subTitle,
}) {
return Row(
children: [
Image.asset(
path,
height: 40.w,
width: 40.w,
),
12.wb,
Text(name),
Spacer(),
Text(subTitle),
],
);
}
Widget _renderButton() {
var showTip = model.status == 1 || model.status == 2;
return Row(
children: [
if (showTip) Text('请在预约时间前30分钟内到场扫码'),
],
);
}
@override
Widget build(BuildContext context) {
return Container(
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.w),
color: Colors.white,
),
padding: EdgeInsets.all(24.w),
child: Column(
children: [
Row(
children: [
Text(
model.facilitiesName,
style: TextStyle(
fontSize: 32.sp,
fontWeight: FontWeight.bold,
),
),
Spacer(),
Text(
model.statusValue,
style: TextStyle(
color: model.statusColor,
fontSize: 30.sp,
),
),
],
),
16.hb,
BeeDivider(),
24.hb,
_renderTile(
path: R.ASSETS_ICONS_APPOINTMENT_CODE_PNG,
name: '预约编号',
subTitle: model.code,
),
_renderTile(
path: R.ASSETS_ICONS_APPOINTMENT_ADDRESS_PNG,
name: '设施地址',
subTitle: model.address,
),
_renderTile(
path: R.ASSETS_ICONS_APPOINTMENT_DATE_PNG,
name: '预约时段',
subTitle: model.displayDate,
),
24.hb,
_renderButton(),
],
),
);
}
}

@ -1,3 +1,4 @@
import 'package:aku_community/ui/community/facility/facility_appointment_view.dart';
import 'package:flutter/material.dart';
import 'package:aku_community/widget/bee_scaffold.dart';
@ -34,7 +35,13 @@ class _FacilityAppointmentPageState extends State<FacilityAppointmentPage>
controller: _tabController,
tabs: ['我的预约', '历史预约'],
),
body: SizedBox(),
body: TabBarView(
children: [
FacilityAppointmentView(type: FacilityAppointmentType.MY),
FacilityAppointmentView(type: FacilityAppointmentType.HISTORY),
],
controller: _tabController,
),
);
}
}

@ -1,7 +1,19 @@
import 'package:aku_community/constants/api.dart';
import 'package:aku_community/models/facility/facility_appointment_model.dart';
import 'package:aku_community/pages/things_page/widget/bee_list_view.dart';
import 'package:aku_community/ui/community/facility/facility_appointment_card.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:aku_community/utils/headers.dart';
enum FacilityAppointmentType {
MY,
HISTORY,
}
class FacilityAppointmentView extends StatefulWidget {
FacilityAppointmentView({Key? key}) : super(key: key);
final FacilityAppointmentType type;
FacilityAppointmentView({Key? key, required this.type}) : super(key: key);
@override
_FacilityAppointmentViewState createState() =>
@ -9,8 +21,41 @@ class FacilityAppointmentView extends StatefulWidget {
}
class _FacilityAppointmentViewState extends State<FacilityAppointmentView> {
EasyRefreshController _refreshController = EasyRefreshController();
int get _facilityType {
switch (widget.type) {
case FacilityAppointmentType.MY:
return 1;
case FacilityAppointmentType.HISTORY:
return 2;
}
}
@override
void dispose() {
_refreshController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return SizedBox();
return BeeListView(
path: API.manager.facility.appointment,
controller: _refreshController,
convert: (model) => model.tableList!
.map((e) => FacilityAppointmentModel.fromJson(e))
.toList(),
extraParams: {'facilitiesType': _facilityType},
builder: (items) {
return ListView.separated(
padding: EdgeInsets.all(32.w),
itemBuilder: (context, index) {
return FacilityAppointmentCard(model: items[index]);
},
separatorBuilder: (_, __) => 32.hb,
itemCount: items.length,
);
},
);
}
}

@ -0,0 +1,57 @@
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:aku_community/utils/headers.dart';
class MessageParser {
final Map<String, dynamic> message;
String subTitle = '';
String type = '0';
MessageParser(rawMessage) : message = Map<String, dynamic>.from(rawMessage);
Future shot() async {
///
subTitle = message['alert'];
Map<dynamic, dynamic> rawExtras = message['extras'];
///extra value
String? androidExtra = rawExtras['cn.jpush.android.EXTRA'];
if (androidExtra == null) return;
Map<String, dynamic> _innerMap = jsonDecode(androidExtra);
type = _innerMap['type'] ?? '0';
switch (type) {
case '1':
await fireAlarm(subTitle);
}
}
///
fireAlarm(String content) async {
await Get.dialog(
CupertinoAlertDialog(
title: Text('发生火灾'),
content: Column(
children: [
Text(subTitle),
10.hb,
Icon(
CupertinoIcons.bell_fill,
color: Colors.red,
size: 48.w,
),
],
),
actions: [
CupertinoDialogAction(
child: Text('确认'),
onPressed: () => Get.back(),
),
],
),
barrierDismissible: false,
);
}
}

@ -14,7 +14,7 @@ class BeeDivider extends StatelessWidget {
this.indent,
this.endIndent,
this.color,
this.isHorizontal})
this.isHorizontal =true})
: super(key: key);
BeeDivider.horizontal({
Key? key,

Loading…
Cancel
Save