| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- import 'package:flutter/material.dart';
- import 'package:flutter/src/widgets/framework.dart';
- import 'package:flutter/widgets.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:flutter_slidable/flutter_slidable.dart';
- import 'package:get/get.dart';
- import 'package:get/get_core/src/get_main.dart';
- import 'package:location/base/base_page.dart';
- import 'package:location/data/bean/common_point_bean.dart';
- import 'package:location/resource/assets.gen.dart';
- import 'package:location/resource/colors.gen.dart';
- import 'package:location/resource/string.gen.dart';
- import 'package:location/utils/common_expand.dart';
- import '../../router/app_pages.dart';
- import '../../utils/common_style.dart';
- import '../../widget/common_view.dart';
- import 'common_point_controller.dart';
- class CommonPointPage extends BasePage<CommonPointController> {
- const CommonPointPage({super.key});
- static void start() {
- Get.toNamed(RoutePath.commonPoint);
- }
- @override
- bool immersive() {
- return true;
- }
- @override
- Widget buildBody(BuildContext context) {
- return Stack(
- children: [
- Assets.images.bgPageBackground.image(width: double.infinity),
- SafeArea(
- child: Column(
- children: [buildHeaderView(), Expanded(child: buildContentView())],
- ),
- ),
- Positioned(
- right: 12.5.w,
- bottom: 141.w,
- child: Assets.images.iconCommonPointAiSummary.image(width: 60.w))
- ],
- );
- }
- Widget buildHeaderView() {
- return CommonView.buildAppBar(StringName.commonPointTitle,
- backOnTap: controller.onBack,
- rightWidget: GestureDetector(
- onTap: controller.onSettingClick,
- child: Center(
- child: Text(
- StringName.commonPointSetting,
- style: TextStyle(fontSize: 14.sp, color: ColorName.colorPrimary),
- ),
- ),
- ));
- }
- Widget buildContentView() {
- return Obx(() {
- if (controller.commonPointList.isEmpty) {
- return buildCommonPointEmptyView();
- }
- return buildCommonPointListView();
- });
- }
- Widget buildCommonPointListView() {
- return Column(
- children: [
- Expanded(
- child: ListView.separated(
- padding: EdgeInsets.only(bottom: 160.w),
- separatorBuilder: (context, index) {
- return Container(
- height: 0.5.w,
- margin: EdgeInsets.only(left: 16.w, right: 16.w),
- color: ColorName.black10,
- );
- },
- itemBuilder: (BuildContext context, int index) =>
- buildCommonPointListItem(controller.commonPointList[index]),
- itemCount: controller.commonPointList.length),
- ),
- GestureDetector(
- onTap: controller.onAddCommonPointClick,
- child: Container(
- margin: EdgeInsets.only(
- top: 15.w, left: 15.w, right: 15.w, bottom: 12.w),
- decoration: getPrimaryBtnDecoration(10.r),
- width: double.infinity,
- height: 46.w,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Assets.images.iconCommonPointAdd
- .image(width: 14.w, height: 14.w),
- SizedBox(width: 2.w),
- Text(StringName.commonPointAdd,
- style: TextStyle(fontSize: 14.sp, color: ColorName.white))
- ],
- ),
- ),
- )
- ],
- );
- }
- Widget buildCommonPointEmptyView() {
- return Center(
- child: IntrinsicHeight(
- child: Column(
- children: [
- Assets.images.iconCommonPointNoData.image(width: 157.w),
- SizedBox(height: 12.8.w),
- Text(StringName.commonPointNoData,
- style: TextStyle(fontSize: 13.sp, color: ColorName.black60)),
- SizedBox(height: 36.w),
- GestureDetector(
- onTap: controller.onAddCommonPointClick,
- child: Container(
- decoration: getPrimaryBtnDecoration(10.r),
- width: 136.w,
- height: 46.w,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Assets.images.iconCommonPointAdd
- .image(width: 14.w, height: 14.w),
- SizedBox(width: 2.w),
- Text(StringName.commonPointAdd,
- style:
- TextStyle(fontSize: 14.sp, color: ColorName.white))
- ],
- ),
- ),
- )
- ],
- ),
- ),
- );
- }
- Widget buildCommonPointListItem(CommonPointBean item) {
- return Slidable(
- // Specify a key if the Slidable is dismissible.
- key: ValueKey(item),
- // The end action pane is the one at the right or the bottom side.
- endActionPane: ActionPane(
- extentRatio: 0.1666666666666667,
- motion: ScrollMotion(),
- children: [
- CustomSlidableAction(
- padding: EdgeInsets.zero,
- borderRadius: BorderRadius.circular(10.r),
- backgroundColor: '#FF7272'.color,
- onPressed: (ctx) {},
- child: Text(StringName.commonPointDelete,
- style: TextStyle(fontSize: 12.sp, color: Colors.white)))
- ],
- ),
- child: buildListItem(item));
- }
- Widget buildListItem(CommonPointBean item) {
- return SizedBox(
- width: double.infinity,
- height: 70.w,
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- SizedBox(width: 16.w),
- Container(
- width: 40.w,
- height: 40.w,
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- color: ColorName.colorPrimary.withOpacity(0.1)),
- child: Center(
- child: Text(
- item.title.substring(0, 1),
- style: TextStyle(
- fontSize: 16.sp,
- color: ColorName.colorPrimary,
- fontWeight: FontWeight.bold),
- ),
- )),
- SizedBox(width: 12.w),
- Expanded(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(item.title,
- style: TextStyle(fontSize: 14.sp, color: ColorName.black90)),
- SizedBox(height: 6.w),
- Text(item.addr ?? '',
- style: TextStyle(
- overflow: TextOverflow.ellipsis,
- fontSize: 12.sp,
- color: ColorName.black30))
- ],
- )),
- SizedBox(width: 16.w),
- ],
- ),
- );
- }
- }
|