parent
9474139828
commit
c6939e6a70
@ -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,
|
||||||
|
);
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue