feat: 主页面功能

This commit is contained in:
chengsiwen committed 2026-07-03 09:24:19 +08:00
1 parent 91edb73885
commit f233f1c642
21 files changed
+1295 -104

No files matched your search

+117
View File
@@ -0,0 +1,117 @@
import 'package:get/get.dart';
import 'package:flutter/material.dart';
/// navigator
class AppNav {
/// clear all route
static Future<T?>? offAllNamed<T>(
String newRouteName, {
Map? arguments,
RoutePredicate? predicate,
String? tag,
Map? parameters,
}) {
return Get.offAllNamed<T>(
newRouteName,
arguments: arguments,
predicate: predicate,
parameters: {...?parameters},
);
}
static Future<T?>? off<T>(Widget page, {arguments, preventDuplicates}) {
return Get.off<T>(
() => page,
arguments: arguments,
preventDuplicates: preventDuplicates ?? false,
);
}
static Future<T?>? offAll<T>(Widget page, {arguments, preventDuplicates}) {
return Get.offAll<T>(() => page, arguments: arguments);
}
static Future<T?>? offNamed<T>(
String newRouteName, {
arguments,
preventDuplicates,
}) {
return Get.offNamed<T>(
newRouteName,
arguments: arguments,
preventDuplicates: preventDuplicates ?? true,
);
}
/// to name
static Future<T?>? toNamed<T>(
String newRouteName, {
arguments,
String? tag,
Map? parameters,
}) {
return Get.toNamed<T>(
newRouteName,
arguments: arguments,
parameters: {...?parameters},
);
}
/// to route
static Future<T?>? to<T>(Widget page, {arguments, binding}) {
return Get.to<T>(
() => page,
arguments: arguments,
binding: binding,
preventDuplicates: false,
);
}
static void _until<T>({String? routeName, T? result}) {
if (result == null) {
Get.back<T>(result: result);
return;
}
// Get.back<T>(result: result);
//
if (routeName == null) {
Get.back<T>(result: result);
return;
}
}
/// back pre
/// [result]
static void back<T>({T? result, String? routeName}) {
_until(routeName: routeName, result: result);
}
/// show dialog
static Future<T?> showDialog<T>(
Widget child, {
bool barrierDismissible = false,
}) {
return Get.dialog<T>(
Center(child: child),
barrierDismissible: barrierDismissible,
);
}
/// show bottom sheet
static Future<T?> showBottom<T>(
Widget child, {
Color? safeAreaColor,
double? borderRadius,
bool isDismissible = false,
bool isScrollControlled = false,
bool? enableDrag,
}) {
return Get.bottomSheet<T>(
child,
isScrollControlled: isScrollControlled,
enableDrag: enableDrag ?? true,
isDismissible: isDismissible,
);
}
}
+89
View File
@@ -0,0 +1,89 @@
import 'package:flutter/material.dart';
class ConstImage {
ConstImage._();
/// main
static const String appBottom = "assets/main/app_bottom.png";
static const String pageBg = "assets/main/page_bg.png";
static const String btHomeUnsel = "assets/main/bt_home_unsel.png";
static const String btPlayUnsel = "assets/main/bt_play_unsel.png";
static const String btCollectUnsel = "assets/main/bt_collect_unsel.png";
static const String btMineUnsel = "assets/main/bt_mine_unsel.png";
static const String btHomeSel = "assets/main/bt_home_seled.png";
static const String btPlaySel = "assets/main/bt_play_seled.png";
static const String btCollectSel = "assets/main/bt_collect_seled.png";
static const String btMineSel = "assets/main/bt_mine_seled.png";
static const String spaceImg = "assets/main/space_img.png";
}
class HelpImage {
static Widget asset(
String path, {
BoxFit? fit,
double? width,
double? height,
Color? color,
bool isDartData = false,
String? dartPath,
}) {
return Image.asset(
path,
fit: fit,
width: width,
height: height,
color: color,
);
}
static Widget networkRadius(
String path, {
BoxFit? fit,
double? width,
double? height,
BoxShape? shape,
BorderRadius? borderRadius,
Widget? errorWidget,
}) {
return ClipRRect(
borderRadius: borderRadius ?? BorderRadius.circular(3),
child: network(
path,
fit: fit,
width: width,
height: height,
shape: shape,
errorWidget: errorWidget,
),
);
}
/// load network
static Widget network(
String path, {
BoxFit? fit,
double? width,
double? height,
Color? color,
BoxShape? shape,
BorderRadius? borderRadius,
Widget? errorWidget,
}) {
return FadeInImage.assetNetwork(
placeholder: ConstImage.spaceImg,
image: path,
width: width, height: height, fit: BoxFit.cover,
imageErrorBuilder: (context, error, stackTrace) {
return asset(
ConstImage.spaceImg,
fit: BoxFit.fill,
width: width, height: height
);
},
);
}
}