123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- import 'package:cs_resources/generated/assets.dart';
- import 'package:flutter/material.dart';
- import 'package:auto_route/auto_route.dart';
- import 'package:flutter/rendering.dart';
- import 'package:flutter_hooks/flutter_hooks.dart';
- import 'package:hooks_riverpod/hooks_riverpod.dart';
- import 'package:plugin_basic/provider/user_config/user_config_service.dart';
- import 'package:router/ext/auto_router_extensions.dart';
- import 'package:shared/utils/color_utils.dart';
- import 'package:shared/utils/log_utils.dart';
- import 'package:widgets/custom_sliver_persistent_header_delegate.dart';
- import 'package:widgets/my_load_image.dart';
- import 'package:widgets/ext/ex_widget.dart';
- import 'package:widgets/my_text_view.dart';
- import 'package:widgets/my_appbar.dart';
- import 'package:cs_resources/theme/app_colors_theme.dart';
- import 'package:widgets/widget_export.dart';
- import '../../router/page/services_page_router.dart';
- import 'inProgress/in_progress_page.dart';
- import 'repair/repair_page.dart';
- import 'services_page.dart';
- enum ServicesType {
- cleaning,
- repair,
- }
- @RoutePage()
- class ServicesMainPage extends HookConsumerWidget {
- ServicesMainPage({Key? key}) : super(key: key);
- //启动当前页面
- static void startInstance({BuildContext? context}) {
- if (context != null) {
- context.router.push( ServicesMainPageRoute());
- } else {
- appRouter.push( ServicesMainPageRoute());
- }
- }
- @override
- Widget build(BuildContext context, WidgetRef ref) {
- useEffect(() {
- // 监听窗口
- }, []);
- useEffect(() {
- Log.d("ServicesMainPage initState");
- // 延迟监听
- }, []);
- return Scaffold(
- appBar: MyAppBar.appBar(
- context,
- "ServicesMain",
- backgroundColor: context.appColors.whiteBG,
- ),
- backgroundColor: ColorUtils.string2Color("#F2F3F6"),
- body: Container(
- child: GridView.count(
- crossAxisCount: 2,
- padding: EdgeInsets.all(10),
- mainAxisSpacing: 10,
- crossAxisSpacing: 10,
- childAspectRatio: 165/146,
- children: [
- _buildServiceCard(
- context,
- ServicesType.cleaning,
- Assets.serviceHomeServices,
- "Home Services",
- 102.5,
- 82.5,
- ServicesPage.startInstance,
- ),
- _buildServiceCard(
- context,
- ServicesType.repair,
- Assets.serviceMaintenance,
- "Maintenance",
- 129,
- 107.5,
- RepairPage.startInstance,
- ),
- ]
- ),
- ),
- );
- }
- Widget _buildServiceCard(
- BuildContext context,
- ServicesType type,
- String imagePath,
- String title,
- double iconWidth,
- double iconHeight,
- Function() onTap,
- ) {
- return Container(
- margin: EdgeInsets.all(10),
- decoration: BoxDecoration(
- color: context.appColors.whiteBG,
- borderRadius: BorderRadius.circular(10),
- boxShadow: [
- BoxShadow(
- color: context.appColors.whiteBG,
- blurRadius: 5,
- offset: Offset(0, 3),
- ),
- ],
- ),
- child: Stack(
- children: [
- Padding(
- padding: const EdgeInsets.only(left: 15, right:15.0, top: 10,bottom: 10),
- child: MyTextView(
- title,
- fontSize: 16,
- isFontMedium: true,
- alignment: Alignment.topLeft,
- ),
- ),
- Positioned(
- bottom: 0,
- right: 0,
- child: Container(
- child: MyLoadImage(
- imagePath,
- fit: BoxFit.cover,
- width: iconWidth,
- height: iconHeight,
- ),
- ),
- )
- ]
- )
- ).onTap((){
- if(type == ServicesType.cleaning){
- ServicesPage.startInstance();
- }else if(type == ServicesType.repair){
- RepairPage.startInstance();
- }
- });
- }
- }
|