9 changed files with 291 additions and 188 deletions
@ -0,0 +1,85 @@ |
|||||||
|
import 'package:flutter/material.dart'; |
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
||||||
|
import 'package:get/get_navigation/src/root/get_material_app.dart'; |
||||||
|
import 'package:problem_check_system/app/core/routes/app_pages.dart'; |
||||||
|
import 'package:problem_check_system/app/core/routes/app_routes.dart'; // 导入路由常量 |
||||||
|
import 'package:problem_check_system/app/core/bindings/initial_binding.dart'; |
||||||
|
import 'package:flutter_localizations/flutter_localizations.dart'; |
||||||
|
|
||||||
|
class MainApp extends StatelessWidget { |
||||||
|
const MainApp({super.key}); |
||||||
|
|
||||||
|
@override |
||||||
|
Widget build(BuildContext context) { |
||||||
|
// 填入设计稿中设备的屏幕尺寸, 单位dp |
||||||
|
return ScreenUtilInit( |
||||||
|
designSize: const Size(375, 812), |
||||||
|
minTextAdapt: true, |
||||||
|
splitScreenMode: true, |
||||||
|
builder: (context, _) { |
||||||
|
// 使用 _ 忽略 child 参数 |
||||||
|
return GetMaterialApp( |
||||||
|
debugShowCheckedModeBanner: false, |
||||||
|
// --- 关键配置 --- |
||||||
|
localizationsDelegates: const [ |
||||||
|
// 必需:用于 Material 组件库的本地化 |
||||||
|
GlobalMaterialLocalizations.delegate, |
||||||
|
// 必需:用于 Widgets 库的本地化 |
||||||
|
GlobalWidgetsLocalizations.delegate, |
||||||
|
// 必需:用于 iOS 风格组件的本地化 |
||||||
|
GlobalCupertinoLocalizations.delegate, |
||||||
|
], |
||||||
|
supportedLocales: const [ |
||||||
|
Locale('zh', 'CN'), // 支持中文 |
||||||
|
], |
||||||
|
title: '问题检查系统', // 使用更有意义的应用标题 |
||||||
|
theme: ThemeData( |
||||||
|
useMaterial3: true, |
||||||
|
|
||||||
|
// 【推荐】使用 colorSchemeSeed 从一个种子颜色生成完整的 M3 调色板 |
||||||
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.lightBlue), |
||||||
|
primaryColor: Colors.lightBlue, |
||||||
|
// (可选) 如果想进一步定制 NavigationBar 的主题 |
||||||
|
navigationBarTheme: NavigationBarThemeData( |
||||||
|
// 1. 在主题中设置你想要的高度 |
||||||
|
height: 48, // 比如我们想让它更高,设置为 70 |
||||||
|
// 2. 【关键】增大图标尺寸,让内容撑满新高度 |
||||||
|
// 使用 MaterialStateProperty.resolveWith 来响应不同状态(如下拉、聚焦等) |
||||||
|
iconTheme: WidgetStateProperty.resolveWith((states) { |
||||||
|
// 你可以根据状态返回不同的 IconThemeData |
||||||
|
return IconThemeData( |
||||||
|
size: 24, // 将图标大小从默认的 24 增大到 28 |
||||||
|
); |
||||||
|
}), |
||||||
|
// 标签行为:控制标签是否总是显示 |
||||||
|
labelBehavior: |
||||||
|
NavigationDestinationLabelBehavior.onlyShowSelected, |
||||||
|
// backgroundColor: Colors.white, |
||||||
|
// 指示器的颜色 |
||||||
|
indicatorColor: Colors.deepOrange.shade200, |
||||||
|
// 【核心】使用 indicatorShape 属性并传入我们的自定义类 |
||||||
|
// indicatorShape: const CustomIndicatorShape( |
||||||
|
// // 在这里调整你想要的宽度 |
||||||
|
// // horizontalPadding: 24.0, // 让指示器变得更窄 |
||||||
|
// // horizontalPadding: 8.0, // 让指示器变得更宽 |
||||||
|
// horizontalPadding: 0, // 让指示器宽度接近内容宽度 |
||||||
|
// ), |
||||||
|
// 标签文本样式 |
||||||
|
labelTextStyle: WidgetStateProperty.all( |
||||||
|
TextStyle( |
||||||
|
fontSize: 12.sp, |
||||||
|
fontWeight: FontWeight.w500, |
||||||
|
color: Colors.deepOrange, |
||||||
|
), |
||||||
|
), |
||||||
|
), |
||||||
|
), |
||||||
|
// 仅使用 GetX 路由系统 |
||||||
|
initialRoute: AppRoutes.login, // 使用路由常量作为初始页面 |
||||||
|
initialBinding: InitialBinding(), // 如果有全局绑定,继续保留 |
||||||
|
getPages: AppPages.routes, // 绑定所有路由 |
||||||
|
); |
||||||
|
}, |
||||||
|
); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,40 @@ |
|||||||
|
// // lib/core/usecases/usecase.dart |
||||||
|
|
||||||
|
// // 定义一个通用的 UseCase 抽象类 |
||||||
|
// // Type: 代表成功时返回的数据类型 (例如: List<EnterpriseEntity>) |
||||||
|
// // Params: 代表执行这个 UseCase所需要的参数 (例如: 一个包含 ID 的类) |
||||||
|
// import 'package:equatable/equatable.dart'; |
||||||
|
|
||||||
|
// abstract class UseCase<Type, Params> { |
||||||
|
// /// 所有 Use Case 子类都必须实现这个 call 方法 |
||||||
|
// /// 它被设计为异步操作,因此返回一个 Future |
||||||
|
// /// Either<Failure, Type> 是一种函数式编程的错误处理方式 |
||||||
|
// /// Left 代表失败 (Failure),Right 代表成功 (Type) |
||||||
|
// Future<Either<Failure, Type>> call(Params params); |
||||||
|
// } |
||||||
|
// // lib/core/usecases/usecase.dart (可以放在同一个文件中) |
||||||
|
|
||||||
|
// /// 当 UseCase 不需要任何参数时,使用这个类 |
||||||
|
// class NoParams extends Equatable { |
||||||
|
// @override |
||||||
|
// List<Object?> get props => []; |
||||||
|
// } |
||||||
|
|
||||||
|
// // 定义一个通用的失败类,所有具体的 Failure 都应该继承它 |
||||||
|
// abstract class Failure extends Equatable { |
||||||
|
// const Failure([List properties = const <dynamic>[]]); |
||||||
|
|
||||||
|
// @override |
||||||
|
// List<Object?> get props => []; |
||||||
|
// } |
||||||
|
|
||||||
|
// // 定义一些具体的失败类型 |
||||||
|
|
||||||
|
// /// 当调用服务器 API 失败时使用 |
||||||
|
// class ServerFailure extends Failure {} |
||||||
|
|
||||||
|
// /// 当操作本地缓存失败时使用 |
||||||
|
// class CacheFailure extends Failure {} |
||||||
|
|
||||||
|
// /// 当没有网络连接时使用 |
||||||
|
// class NetworkFailure extends Failure {} |
||||||
@ -0,0 +1,12 @@ |
|||||||
|
import 'package:problem_check_system/app/features/enterprise/domain/entities/enterprise.dart'; |
||||||
|
import 'package:problem_check_system/app/features/enterprise/domain/repositories/enterprise_repository.dart'; |
||||||
|
|
||||||
|
class GetEnterprisesUsecase { |
||||||
|
final EnterpriseRepository repository; |
||||||
|
|
||||||
|
GetEnterprisesUsecase({required this.repository}); |
||||||
|
|
||||||
|
Future<List<Enterprise>> call() { |
||||||
|
return repository.getAllEnterprises(); |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue