更新设施页面逻辑

hmxc
小赖 4 years ago
parent 9474139828
commit c6939e6a70

@ -308,4 +308,8 @@ class _Facility {
///使
String get stop => '/user/facilitiesAppointment/useStop';
///id
String get detailType =>
'/user/facilitiesAppointment/findFacilitiesByCategoryId';
}

@ -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);

@ -0,0 +1,19 @@
import 'package:equatable/equatable.dart';
import 'package:json_annotation/json_annotation.dart';
part 'facility_type_detail_model.g.dart';
@JsonSerializable()
class FacilityTypeDetailModel extends Equatable {
final int id;
final String name;
FacilityTypeDetailModel({
required this.id,
required this.name,
});
factory FacilityTypeDetailModel.fromJson(Map<String, dynamic> json) =>
_$FacilityTypeDetailModelFromJson(json);
@override
List<Object?> get props => [id];
}

@ -0,0 +1,15 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'facility_type_detail_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
FacilityTypeDetailModel _$FacilityTypeDetailModelFromJson(
Map<String, dynamic> json) {
return FacilityTypeDetailModel(
id: json['id'] as int,
name: json['name'] as String,
);
}

@ -1,10 +1,10 @@
import 'package:aku_community/ui/community/facility/pick_facility_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:aku_community/ui/community/facility/facility_appointment_view.dart';
import 'package:aku_community/ui/community/facility/facility_preview_page.dart';
import 'package:aku_community/widget/bee_scaffold.dart';
import 'package:aku_community/widget/tab_bar/bee_tab_bar.dart';
@ -38,7 +38,7 @@ class _FacilityAppointmentPageState extends State<FacilityAppointmentPage>
actions: [
IconButton(
icon: Icon(CupertinoIcons.add_circled),
onPressed: () => Get.to(() => FacilityPreorderPage()),
onPressed: () => Get.to(() => PickFacilityPage()),
),
],
appBarBottom: BeeTabBar(

@ -1,3 +1,5 @@
import 'package:aku_community/models/facility/facility_type_detail_model.dart';
import 'package:aku_community/ui/community/facility/facility_type_detail_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -9,9 +11,7 @@ import 'package:provider/provider.dart';
import 'package:aku_community/base/base_style.dart';
import 'package:aku_community/constants/api.dart';
import 'package:aku_community/constants/app_theme.dart';
import 'package:aku_community/models/facility/facility_type_model.dart';
import 'package:aku_community/provider/app_provider.dart';
import 'package:aku_community/ui/community/facility/pick_facility_page.dart';
import 'package:aku_community/ui/profile/house/pick_my_house_page.dart';
import 'package:aku_community/utils/headers.dart';
import 'package:aku_community/utils/network/net_util.dart';
@ -21,14 +21,15 @@ import 'package:aku_community/widget/buttons/bottom_button.dart';
import 'package:aku_community/widget/picker/bee_date_picker.dart';
class FacilityPreorderPage extends StatefulWidget {
FacilityPreorderPage({Key? key}) : super(key: key);
final int id;
FacilityPreorderPage({Key? key, required this.id}) : super(key: key);
@override
_FacilityPreorderPageState createState() => _FacilityPreorderPageState();
}
class _FacilityPreorderPageState extends State<FacilityPreorderPage> {
FacilityTypeModel? typeModel;
FacilityTypeDetailModel? typeModel;
DateTime? startDate;
DateTime? endDate;
@ -68,7 +69,8 @@ class _FacilityPreorderPageState extends State<FacilityPreorderPage> {
width: 60.w,
),
onTap: () async {
FacilityTypeModel? model = await Get.to(() => PickFacilityPage());
FacilityTypeDetailModel? model =
await Get.to(() => FacilityTypeDetailPage(model: typeModel, id: widget.id));
if (model != null) typeModel = model;
setState(() {});
},

@ -1,3 +1,4 @@
import 'package:aku_community/ui/community/facility/facility_preorder_page.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
@ -74,7 +75,9 @@ class FacilityTypeCard extends StatelessWidget {
24.hb,
],
),
onPressed: () => Get.back(result: model),
onPressed: () {
Get.off(() => FacilityPreorderPage(id: model.id));
},
);
}
}

@ -0,0 +1,68 @@
import 'package:aku_community/constants/api.dart';
import 'package:aku_community/models/facility/facility_type_detail_model.dart';
import 'package:aku_community/utils/network/base_model.dart';
import 'package:aku_community/utils/network/net_util.dart';
import 'package:aku_community/widget/bee_divider.dart';
import 'package:aku_community/widget/bee_scaffold.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:get/get.dart';
class FacilityTypeDetailPage extends StatefulWidget {
final int id;
final FacilityTypeDetailModel? model;
FacilityTypeDetailPage({
Key? key,
required this.model,
required this.id,
}) : super(key: key);
@override
_FacilityTypeDetailPageState createState() => _FacilityTypeDetailPageState();
}
class _FacilityTypeDetailPageState extends State<FacilityTypeDetailPage> {
List<FacilityTypeDetailModel> _models = [];
@override
Widget build(BuildContext context) {
return BeeScaffold(
title: '选择设施',
body: EasyRefresh(
firstRefresh: true,
header: MaterialHeader(),
onRefresh: () async {
BaseModel model = await NetUtil().get(
API.manager.facility.detailType,
params: {'categoryId': widget.id},
);
_models = (model.data as List)
.map((e) => FacilityTypeDetailModel.fromJson(e))
.toList();
setState(() {});
},
child: ListView.separated(
itemBuilder: (context, index) {
final item = _models[index];
return ListTile(
onTap: () => selectModel(item),
leading: Radio(
value: item,
groupValue: widget.model,
onChanged: (_) {
selectModel(item);
},
),
title: Text(item.name),
);
},
separatorBuilder: (_, __) => BeeDivider.horizontal(),
itemCount: _models.length,
),
),
);
}
void selectModel(FacilityTypeDetailModel model) {
Get.back(result: model);
}
}

@ -302,6 +302,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.0.0"
equatable:
dependency: "direct main"
description:
name: equatable
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.0"
extended_list_library:
dependency: transitive
description:

@ -68,6 +68,7 @@ dependencies:
json_annotation: ^4.0.1
waterfall_flow: ^3.0.1
qr_code_scanner: ^0.4.0
equatable: ^2.0.0
dev_dependencies:
flutter_test:

@ -33,3 +33,11 @@ void gitPush() {
arguments: ['push'],
);
}
@Task('build runner')
void gen() async {
await Pub.runAsync(
'build_runner',
arguments: ['build'],
);
}

Loading…
Cancel
Save