Compare commits

17 Commits

Author SHA1 Message Date
jingyun 38a96109bc fix:UI 2026-06-23 15:05:03 +08:00
jingyun 428969245d fix:金条详情和编辑,添加一致 2026-06-23 14:42:13 +08:00
jingyun 2e10f01496 fix:免责声明 2026-06-23 11:07:12 +08:00
jingyun 7d571e22eb fix:换platform_metadata库 2026-06-23 11:06:58 +08:00
jingyun 088bb61411 fix:多余的屏蔽 2026-06-23 10:42:29 +08:00
jingyun aeb7ebd642 feat:分享功能 2026-06-23 10:42:14 +08:00
jingyun d59c3212b8 fix:日历选择交互 2026-06-23 10:18:36 +08:00
jingyun 8cf919283b fix:增加图片选择和拍照功能 2026-06-23 10:07:35 +08:00
jingyun 75ba309e8c fix:我的和设置列表 2026-06-22 16:54:55 +08:00
jingyun 3513fbac0f fix:隐藏修改多余 2026-06-22 15:33:38 +08:00
jingyun ab99010306 fix:持仓详情编辑,资讯下拉加载更多 2026-06-22 11:36:09 +08:00
jingyun 08023aff82 fix:h5地址 2026-06-18 18:54:30 +08:00
jingyun 0b4b113de8 fix:折算设置 2026-06-18 18:44:23 +08:00
jingyun 975f115859 fix:折扣设置页 2026-06-18 18:22:49 +08:00
jingyun 2d7523f901 fix:UI对齐demo 2026-06-18 18:08:29 +08:00
jingyun f42ad566e0 fix:靠原型不齐页面 2026-06-18 16:53:08 +08:00
jingyun 35eed6b5b8 fix:jinzhi包名和签名 2026-06-18 15:13:24 +08:00
47 changed files with 7838 additions and 1363 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
.PHONY: runner run test lint apk ipa build-web
WEB_API_URL ?= https://jinzhi.api.local
WEB_API_URL ?= https://jinzhi.api.yqzhice.top
WEB_BASE_HREF ?= /flutter/
GITVERSION := $(shell git describe --tags --always --dirty 2>/dev/null || git rev-parse --short HEAD)
COMMON_DART_DEFINES := --dart-define=GITVERSION=$(GITVERSION)
+2 -2
View File
@@ -23,7 +23,7 @@ fun requireSigningProperty(name: String): String {
}
android {
namespace = "com.jinzhi.app"
namespace = "com.jinzhi.butler"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion
@@ -47,7 +47,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.jinzhi.app"
applicationId = "com.jinzhi.butler"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = flutter.minSdkVersion
Binary file not shown.
+4
View File
@@ -1,5 +1,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
<!-- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />-->
<!-- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />-->
@@ -1,4 +1,4 @@
package com.jinzhi.app
package com.jinzhi.butler
import io.flutter.embedding.android.FlutterActivity
+20
View File
@@ -0,0 +1,20 @@
应用名称:
金值
iOS平台
Bundle ID
公钥
证书SHA-1指纹
Android
包名:
com.jinzhi.butler
MD5
bf875d2980f09f3acca3614b10aa0463
公钥(16进制)
a61ce1268140ae32cd7aeb43dfb2324a1bb04aba5c7cd5879e6f3b3e052f926ef80b9eccfc53b057a6a01d7dadf573ac19bf4bcfa9c4296fae20a0e1f4f598685321e4b3767bbc3a98d6afd056a522194528c3df1fed3872c697c49bc40fdc963071018ec644233e19e78bae9d3b5e5925e925322c5211f12fb079aa19464abd44bb782d81a30cc55c1b090f691d18aeb73beb26a710f45bb31a605ccf6519fe17e03130666e787bd2de0ceb8fd4bb66f2fd706af34db7840a504da090bb37f50e06153a84c3215ab1e6cbbb225b681baa84d90f97f1e245664d3fb6a1072506f4ba0548a4c28d84b239ed8500b0eb914bd3585565658e964317b48c0d84791b
签名证书SHA-1指纹
70 A8 9B 61 BE 5C 51 0A B8 42 78 2A FE 66 3A 4D 55 B9 10 4F
+8
View File
@@ -39,5 +39,13 @@ end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
'PERMISSION_CAMERA=1',
'PERMISSION_PHOTOS=1',
]
end
end
end
+40 -1
View File
@@ -11,16 +11,31 @@ PODS:
- FlutterMacOS
- fluttertoast (0.0.2):
- Flutter
- gal (1.0.0):
- Flutter
- FlutterMacOS
- image_picker_ios (0.0.1):
- Flutter
- package_info_plus (0.4.5):
- Flutter
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- permission_handler_apple (9.4.8):
- Flutter
- photo_manager (3.9.0):
- Flutter
- FlutterMacOS
- platform_metadata (0.0.1):
- Flutter
- share_plus (0.0.1):
- Flutter
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
- sqflite_darwin (0.0.4):
- Flutter
- FlutterMacOS
- url_launcher_ios (0.0.1):
- Flutter
- video_player_avfoundation (0.0.1):
@@ -34,10 +49,16 @@ DEPENDENCIES:
- flutter_paid (from `.symlinks/plugins/flutter_paid/ios`)
- flutter_secure_storage_darwin (from `.symlinks/plugins/flutter_secure_storage_darwin/darwin`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
- gal (from `.symlinks/plugins/gal/darwin`)
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- photo_manager (from `.symlinks/plugins/photo_manager/darwin`)
- platform_metadata (from `.symlinks/plugins/platform_metadata/ios`)
- share_plus (from `.symlinks/plugins/share_plus/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- sqflite_darwin (from `.symlinks/plugins/sqflite_darwin/darwin`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
- video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/darwin`)
@@ -54,14 +75,26 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_secure_storage_darwin/darwin"
fluttertoast:
:path: ".symlinks/plugins/fluttertoast/ios"
gal:
:path: ".symlinks/plugins/gal/darwin"
image_picker_ios:
:path: ".symlinks/plugins/image_picker_ios/ios"
package_info_plus:
:path: ".symlinks/plugins/package_info_plus/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
permission_handler_apple:
:path: ".symlinks/plugins/permission_handler_apple/ios"
photo_manager:
:path: ".symlinks/plugins/photo_manager/darwin"
platform_metadata:
:path: ".symlinks/plugins/platform_metadata/ios"
share_plus:
:path: ".symlinks/plugins/share_plus/ios"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
sqflite_darwin:
:path: ".symlinks/plugins/sqflite_darwin/darwin"
url_launcher_ios:
:path: ".symlinks/plugins/url_launcher_ios/ios"
video_player_avfoundation:
@@ -74,13 +107,19 @@ SPEC CHECKSUMS:
flutter_paid: 6055d15f439071fefb849e3cebc279915ed70db5
flutter_secure_storage_darwin: acdb3f316ed05a3e68f856e0353b133eec373a23
fluttertoast: 2c67e14dce98bbdb200df9e1acf610d7a6264ea1
gal: baecd024ebfd13c441269ca7404792a7152fde89
image_picker_ios: e0ece4aa2a75771a7de3fa735d26d90817041326
package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499
path_provider_foundation: bb55f6dbba17d0dccd6737fe6f7f34fbd0376880
permission_handler_apple: 92d754bbaa7361d436db2d6c3c1c2a0fdcec462e
photo_manager: 25fd77df14f4f0ba5ef99e2c61814dde77e2bceb
platform_metadata: a4d1e9569219bb2dcbb54510554611df032ea023
share_plus: 50da8cb520a8f0f65671c6c6a99b3617ed10a58a
shared_preferences_foundation: 7036424c3d8ec98dfe75ff1667cb0cd531ec82bb
sqflite_darwin: 20b2a3a3b70e43edae938624ce550a3cbf66a3d0
url_launcher_ios: 7a95fa5b60cc718a708b8f2966718e93db0cef1b
video_player_avfoundation: dd410b52df6d2466a42d28550e33e4146928280a
PODFILE CHECKSUM: 3c63482e143d1b91d2d2560aee9fb04ecc74ac7e
PODFILE CHECKSUM: b6c30c22d7ac3adf21bf40601823fcf685f5b3d6
COCOAPODS: 1.16.2
+18 -4
View File
@@ -198,6 +198,7 @@
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
38380B0F0A71332BD02F1E6B /* [CP] Embed Pods Frameworks */,
EA4FE8E3948A035FEE08B35D /* [CP] Copy Pods Resources */,
);
buildRules = (
);
@@ -299,14 +300,10 @@
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
inputPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
@@ -365,6 +362,23 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
EA4FE8E3948A035FEE08B35D /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
+6
View File
@@ -56,5 +56,11 @@
<true/>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>NSCameraUsageDescription</key>
<string>用于为贵金属持仓添加发票、证书及实物照片。</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>用于为贵金属持仓添加发票、证书及实物照片。</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>用于为贵金属持仓添加发票、证书及实物照片。</string>
</dict>
</plist>
+29 -19
View File
@@ -1,12 +1,13 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import '../common/router/app_router.dart';
import '../common/theme/jinzhi_theme.dart';
import '../common/theme/spacing.dart';
import '../common/theme/theme_controller.dart';
import '../common/widgets/smart_refresh.dart';
class JinzhiApp extends ConsumerWidget {
const JinzhiApp({super.key});
@@ -15,26 +16,35 @@ class JinzhiApp extends ConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
final router = ref.watch(routerProvider);
final mode = ref.watch(themeModeControllerProvider);
// DM Sans 作主字体(拉丁/数字),中文走系统级联(iOS 苹方 / Android 厂商
// 中文字体)——主流做法,不显式点名、不内置字体。
final dmSansFamily = GoogleFonts.dmSans().fontFamily;
final textTheme = ShadTextTheme(family: dmSansFamily);
return ShadApp.router(
title: '金值',
themeMode: mode,
theme: ShadThemeData(
brightness: Brightness.light,
colorScheme: jinzhiLightScheme,
textTheme: textTheme,
radius: BorderRadius.circular(Spacing.radiusBase),
final textTheme = ShadTextTheme();
return RefreshConfiguration(
springDescription: const SpringDescription(
mass: 1,
stiffness: 364.718677686,
damping: 35.2,
),
darkTheme: ShadThemeData(
brightness: Brightness.dark,
colorScheme: jinzhiDarkScheme,
textTheme: textTheme,
radius: BorderRadius.circular(Spacing.radiusBase),
headerBuilder: () => const MaterialClassicHeader(),
footerBuilder: () => jinzhiClassicFooter,
hideFooterWhenNotFull: true,
headerTriggerDistance: 60,
maxOverScrollExtent: 100,
child: ShadApp.router(
title: '金值',
themeMode: mode,
theme: ShadThemeData(
brightness: Brightness.light,
colorScheme: jinzhiLightScheme,
textTheme: textTheme,
radius: BorderRadius.circular(Spacing.radiusBase),
),
darkTheme: ShadThemeData(
brightness: Brightness.dark,
colorScheme: jinzhiDarkScheme,
textTheme: textTheme,
radius: BorderRadius.circular(Spacing.radiusBase),
),
routerConfig: router,
),
routerConfig: router,
);
}
}
+1 -1
View File
@@ -4,7 +4,7 @@ class AppConfig {
factory AppConfig.fromEnvironment() {
const url = String.fromEnvironment(
'JINZHI_API_BASE_URL',
defaultValue: 'https://jinzhi.api.local',
defaultValue: 'https://jinzhi.api.yqzhice.top',
);
return const AppConfig(apiBaseUrl: url);
}
+1 -1
View File
@@ -3,7 +3,7 @@ class AppH5Urls {
static const baseUrl = String.fromEnvironment(
'JINZHI_H5_BASE_URL',
defaultValue: 'https://jinzhi.h5.local',
defaultValue: 'https://jinzhi.h5.yqzhice.top',
);
static String get privacyUrl => '$baseUrl/beginner/privacyPolicy.html';
+156
View File
@@ -2,7 +2,10 @@ import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import '../../features/assets/presentation/asset_add_page.dart';
import '../../features/assets/presentation/asset_edit_page.dart';
import '../../features/assets/presentation/assets_page.dart';
import '../../features/assets/presentation/holding_detail_page.dart';
import '../../features/auth/presentation/delete_account_page.dart';
import '../../features/auth/presentation/login_page.dart';
import '../../features/debug/presentation/debug_info_page.dart';
@@ -11,8 +14,11 @@ import '../../features/debug/presentation/debug_shorebird_page.dart';
import '../../features/debug/presentation/fancy_dio_inspector_page.dart';
import '../../features/debug/presentation/typography_test_page.dart';
import '../../features/market/presentation/market_page.dart';
import '../../features/market/presentation/market_kline_page.dart';
import '../../features/news/presentation/news_page.dart';
import '../../features/news/presentation/news_detail_page.dart';
import '../../features/profile/presentation/profile_page.dart';
import '../../features/profile/presentation/profile_action_pages.dart';
import '../../features/settings/presentation/settings_page.dart';
import '../../features/settings/presentation/privacy_consent_page.dart';
import '../services/device_header_service.dart';
@@ -20,9 +26,25 @@ import 'tab_shell.dart';
abstract final class AppRoutes {
static const assets = '/assets';
static const assetAdd = '/assets/add';
static const assetEdit = '/assets/edit';
static const market = '/market';
static const marketKline = '/market/kline';
static const news = '/news';
static const newsDetail = '/news/detail';
static const profile = '/profile';
static const profileInvite = '/profile/invite';
static const profileShare = '/profile/share';
static const profileLocalBackup = '/profile/local-backup';
static const profileCloudBackup = '/profile/cloud-backup';
static const profileWidget = '/profile/widget';
static const profilePurity = '/profile/purity';
static const profileRecycle = '/profile/recycle';
static const profilePriceColor = '/profile/price-color';
static const profileCurrency = '/profile/currency';
static const profileDisclaimer = '/profile/disclaimer';
static const profileAbout = '/profile/about';
static const assetDetail = '/assets/detail';
static const login = '/login';
static const settings = '/settings';
static const deleteAccount = '/delete-account';
@@ -73,6 +95,88 @@ final routerProvider = Provider<GoRouter>((ref) {
),
],
),
GoRoute(
path: AppRoutes.assetDetail,
builder: (ctx, s) => HoldingDetailPage(id: s.uri.queryParameters['id']),
),
GoRoute(
path: AppRoutes.assetAdd,
pageBuilder: (ctx, s) =>
_rightToLeftPage(state: s, child: const AssetAddPage()),
),
GoRoute(
path: AppRoutes.assetEdit,
pageBuilder: (ctx, s) => _rightToLeftPage(
state: s,
child: AssetEditPage(id: s.uri.queryParameters['id'] ?? ''),
),
),
GoRoute(
path: AppRoutes.marketKline,
builder: (ctx, s) => MarketKlinePage(
metalId: s.uri.queryParameters['metal'],
periodId: s.uri.queryParameters['period'],
),
),
GoRoute(
path: AppRoutes.newsDetail,
builder: (ctx, s) => NewsDetailPage(id: s.uri.queryParameters['id']),
),
GoRoute(
path: AppRoutes.profileInvite,
pageBuilder: (ctx, s) =>
_bottomUpPage(state: s, child: const InviteRewardPage()),
),
GoRoute(
path: AppRoutes.profileShare,
pageBuilder: (ctx, s) =>
_bottomUpPage(state: s, child: const ShareCardPage()),
),
GoRoute(
path: AppRoutes.profileLocalBackup,
pageBuilder: (ctx, s) =>
_bottomUpPage(state: s, child: const LocalBackupPage()),
),
GoRoute(
path: AppRoutes.profileCloudBackup,
pageBuilder: (ctx, s) =>
_bottomUpPage(state: s, child: const CloudBackupPage()),
),
GoRoute(
path: AppRoutes.profileWidget,
pageBuilder: (ctx, s) =>
_bottomUpPage(state: s, child: const WidgetSettingsPage()),
),
GoRoute(
path: AppRoutes.profilePurity,
pageBuilder: (ctx, s) =>
_bottomUpPage(state: s, child: const PuritySettingsPage()),
),
GoRoute(
path: AppRoutes.profileRecycle,
pageBuilder: (ctx, s) =>
_bottomUpPage(state: s, child: const RecycleDiscountPage()),
),
GoRoute(
path: AppRoutes.profilePriceColor,
pageBuilder: (ctx, s) =>
_bottomUpPage(state: s, child: const PriceColorPage()),
),
GoRoute(
path: AppRoutes.profileCurrency,
pageBuilder: (ctx, s) =>
_bottomUpPage(state: s, child: const CurrencyPage()),
),
GoRoute(
path: AppRoutes.profileDisclaimer,
pageBuilder: (ctx, s) =>
_rightToLeftPage(state: s, child: const DisclaimerPage()),
),
GoRoute(
path: AppRoutes.profileAbout,
pageBuilder: (ctx, s) =>
_bottomUpPage(state: s, child: const AboutPage()),
),
GoRoute(path: AppRoutes.debug, builder: (_, s) => const DebugPage()),
GoRoute(
path: AppRoutes.login,
@@ -113,3 +217,55 @@ final routerProvider = Provider<GoRouter>((ref) {
],
);
});
CustomTransitionPage<T> _bottomUpPage<T>({
required GoRouterState state,
required Widget child,
}) {
return CustomTransitionPage<T>(
key: state.pageKey,
transitionDuration: const Duration(milliseconds: 260),
reverseTransitionDuration: const Duration(milliseconds: 220),
child: child,
transitionsBuilder: (context, animation, secondaryAnimation, pageChild) {
final curved = CurvedAnimation(
parent: animation,
curve: Curves.easeOutCubic,
reverseCurve: Curves.easeInCubic,
);
return SlideTransition(
position: Tween<Offset>(
begin: const Offset(0, 0.08),
end: Offset.zero,
).animate(curved),
child: FadeTransition(opacity: curved, child: pageChild),
);
},
);
}
CustomTransitionPage<T> _rightToLeftPage<T>({
required GoRouterState state,
required Widget child,
}) {
return CustomTransitionPage<T>(
key: state.pageKey,
transitionDuration: const Duration(milliseconds: 260),
reverseTransitionDuration: const Duration(milliseconds: 220),
child: child,
transitionsBuilder: (context, animation, secondaryAnimation, pageChild) {
final curved = CurvedAnimation(
parent: animation,
curve: Curves.easeOutCubic,
reverseCurve: Curves.easeInCubic,
);
return SlideTransition(
position: Tween<Offset>(
begin: const Offset(1, 0),
end: Offset.zero,
).animate(curved),
child: FadeTransition(opacity: curved, child: pageChild),
);
},
);
}
+91 -121
View File
@@ -1,11 +1,8 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import '../theme/app_icons.dart';
import '../widgets/adaptive.dart';
import 'app_router.dart';
class TabShell extends StatefulWidget {
const TabShell({super.key, required this.child, required this.location});
@@ -44,129 +41,88 @@ class _TabShellState extends State<TabShell> {
return Scaffold(
backgroundColor: cs.background,
resizeToAvoidBottomInset: false,
body: Stack(
children: [
Scaffold(
backgroundColor: cs.background,
resizeToAvoidBottomInset: false,
appBar: AppBar(
backgroundColor: cs.background,
surfaceTintColor: Colors.transparent,
elevation: 0,
scrolledUnderElevation: 0,
centerTitle: true,
toolbarHeight: 32,
leading: canPop
? IconButton(
onPressed: () => context.pop(),
icon: const Icon(Icons.chevron_left, size: 20),
)
: null,
title: AnimatedOpacity(
opacity: _showCompactHeader ? 1 : 0,
duration: const Duration(milliseconds: 160),
curve: Curves.easeOut,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
header.title,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w700,
color: cs.foreground,
height: 1.1,
letterSpacing: 0,
),
),
if (header.subtitle != null) ...[
const SizedBox(height: 2),
Text(
header.subtitle!,
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w400,
color: cs.mutedForeground,
height: 1.1,
letterSpacing: 0,
),
),
],
],
appBar: AppBar(
backgroundColor: cs.background,
surfaceTintColor: Colors.transparent,
elevation: 0,
scrolledUnderElevation: 0,
centerTitle: true,
toolbarHeight: 32,
leading: canPop
? IconButton(
onPressed: () => context.pop(),
icon: const Icon(Icons.chevron_left, size: 20),
)
: null,
title: AnimatedOpacity(
opacity: _showCompactHeader ? 1 : 0,
duration: const Duration(milliseconds: 160),
curve: Curves.easeOut,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
header.title,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w700,
color: cs.foreground,
height: 1.1,
letterSpacing: 0,
),
),
),
body: ColoredBox(
color: cs.background,
child: NotificationListener<ScrollNotification>(
onNotification: _handleScrollNotification,
child: Stack(children: [Positioned.fill(child: widget.child)]),
),
),
bottomNavigationBar: SafeArea(
top: false,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
DecoratedBox(
decoration: BoxDecoration(
color: cs.background,
border: Border(
top: BorderSide(color: cs.border, width: 1),
),
),
child: SizedBox(
height: 62,
// 平板:tab 行限宽 600 居中(demo .nav .tabs
child: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: Adaptive.tabsMaxWidth,
),
child: Row(
children: [
for (var i = 0; i < _tabs.length; i++)
Expanded(
child: _TabButton(
icon: i == _index
? _filledIcons[i]
: _outlineIcons[i],
label: _labels[i],
selected: i == _index,
onTap: () => context.go(_tabs[i]),
),
),
],
),
),
),
if (header.subtitle != null) ...[
const SizedBox(height: 2),
Text(
header.subtitle!,
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w400,
color: cs.mutedForeground,
height: 1.1,
letterSpacing: 0,
),
),
],
],
),
),
),
body: ColoredBox(
color: cs.background,
child: NotificationListener<ScrollNotification>(
onNotification: _handleScrollNotification,
child: Stack(children: [Positioned.fill(child: widget.child)]),
),
),
bottomNavigationBar: DecoratedBox(
decoration: BoxDecoration(
color: Colors.white,
border: Border(top: BorderSide(color: cs.border, width: 1)),
),
child: SafeArea(
top: false,
child: SizedBox(
height: 62,
child: Row(
children: [
for (var i = 0; i < _tabs.length; i++)
Expanded(
child: _TabButton(
icon: i == _index ? _filledIcons[i] : _outlineIcons[i],
label: _labels[i],
selected: i == _index,
onTap: () => context.go(_tabs[i]),
),
),
],
),
],
),
),
if (!kReleaseMode)
Positioned(
right: 16,
bottom: 88,
child: FilledButton(
onPressed: () => context.push(AppRoutes.fancyDioInspector),
style: FilledButton.styleFrom(
backgroundColor: cs.primary,
foregroundColor: cs.primaryForeground,
minimumSize: const Size(60, 60),
shape: const CircleBorder(),
padding: EdgeInsets.zero,
),
child: const Text('请求'),
),
),
],
),
),
);
}
@@ -199,12 +155,26 @@ class _TabButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cs = ShadTheme.of(context).colorScheme;
final color = selected ? cs.foreground : cs.mutedForeground;
final color = selected ? cs.primary : cs.mutedForeground;
return InkWell(
onTap: onTap,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// if (selected)
// Container(
// width: 22,
// height: 2.5,
// margin: const EdgeInsets.only(bottom: 6),
// decoration: BoxDecoration(
// color: cs.primary,
// borderRadius: const BorderRadius.vertical(
// bottom: Radius.circular(3),
// ),
// ),
// )
// else
// const SizedBox(height: 8.5),
Icon(icon, size: 22, color: color),
const SizedBox(height: 4),
Text(
@@ -43,6 +43,8 @@ class DeviceHeaderService {
String _androidOaid = '';
String _androidImei = '';
String _androidMac = '';
IosDeviceInfo? iosDeviceInfo;
AndroidDeviceInfo? androidDeviceInfo;
Future<void>? _baseInitialization;
Future<void>? _identityInitialization;
@@ -120,9 +122,23 @@ class DeviceHeaderService {
_iosIdfv = await _resolveIdfv();
await _collectIosPaidIfMissing();
}
await getDeviceInfo();
} catch (_) {}
}
Future<void> getDeviceInfo() async {
try {
final deviceInfoPlugin = DeviceInfoPlugin();
if (Platform.isIOS) {
iosDeviceInfo = await deviceInfoPlugin.iosInfo;
} else if (Platform.isAndroid) {
androidDeviceInfo = await deviceInfoPlugin.androidInfo;
}
} catch (e) {
print('$e');
}
}
Future<void> _collectAndroidIdIfAgreed() async {
if (_androidId.isNotEmpty) return;
if (!StorageService.to.getBool(storagePrivacyAgreed)) return; // 隐私同意后才采集
+20
View File
@@ -0,0 +1,20 @@
import '../../features/assets/data/asset_models.dart';
class UploadRepository {
const UploadRepository();
Future<UploadResult> uploadAssetImage(AssetImage image) async {
// TODO: Connect to upload backend.
return UploadResult(
remoteUrl: image.remoteUrl,
thumbnailUrl: image.thumbnailUrl,
);
}
}
class UploadResult {
const UploadResult({this.remoteUrl, this.thumbnailUrl});
final String? remoteUrl;
final String? thumbnailUrl;
}
+13
View File
@@ -0,0 +1,13 @@
import '../../features/assets/data/asset_models.dart';
import 'upload_repository.dart';
class UploadService {
const UploadService({required this.repository});
final UploadRepository repository;
Future<UploadResult> uploadAssetImage(AssetImage image) async {
// Placeholder: future implementation will upload the file and return URLs.
return repository.uploadAssetImage(image);
}
}
+119
View File
@@ -0,0 +1,119 @@
import 'dart:io';
import 'dart:ui' as ui;
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:gal/gal.dart';
import 'package:http/http.dart' as http;
import 'package:jinzhi_flutter_app/common/services/device_header_service.dart';
import 'package:permission_handler/permission_handler.dart';
class ImageUtil {
static const String _albumName = 'jinzhi';
static Stream<FileResponse> downloadImage(String url, String key) {
return DefaultCacheManager().getFileStream(
url,
key: key,
withProgress: true,
);
}
static Future<String> downloadImageInFile(String url, String key) async {
final file = await DefaultCacheManager().getSingleFile(url, key: key);
return file.path;
}
static Future<bool> requestForImagePermission() async {
if (Platform.isIOS) {
PermissionStatus photoStatus = await Permission.photosAddOnly.status;
if (photoStatus != PermissionStatus.granted) {
photoStatus = await Permission.photosAddOnly.request();
if (photoStatus != PermissionStatus.granted) {
return false;
}
}
} else if (Platform.isAndroid) {
int? sdkInt = DeviceHeaderService.to.androidDeviceInfo?.version.sdkInt;
if (sdkInt != null && sdkInt >= 33) {
// ✅ Android 13+ 不需要读权限,直接返回 true
// gal 插件内部通过 MediaStore 写入
return true;
} else {
// ✅ Android 10-12 仍可能需要 storage 权限
final status = await Permission.storage.request();
return status.isGranted;
}
} else {
return false;
}
return true;
}
static Future<void> saveImage(FileInfo fileInfo) async {
await Gal.putImage(fileInfo.file.path, album: _albumName);
}
static Future<void> saveImageData(ByteData byteData) async {
Uint8List imageBytes = byteData.buffer.asUint8List();
await Gal.putImageBytes(
imageBytes,
name: 'XWallpaper_share',
album: _albumName,
);
}
static Future<void> saveImageUint8List(Uint8List imageBytes) async {
await Gal.putImageBytes(
imageBytes,
name: 'XWallpaper_share',
album: _albumName,
);
}
static Future<void> saveUIImageData(ui.Image image) async {
final byteData = await image.toByteData(format: ui.ImageByteFormat.png);
Uint8List imageBytes = byteData!.buffer.asUint8List();
await Gal.putImageBytes(
imageBytes,
name: 'XWallpaper_share',
album: _albumName,
);
}
static Future<Uint8List> createTransparentImage(double aspectRatio) async {
double minSize = 100;
double width = minSize * aspectRatio;
double height = minSize;
final recorder = PictureRecorder();
final canvas = Canvas(
recorder,
Rect.fromLTWH(0, 0, width.toDouble(), height.toDouble()),
);
final paint = Paint()..color = Colors.transparent;
canvas.drawRect(
Rect.fromLTWH(0.0, 0.0, width.toDouble(), height.toDouble()),
paint,
);
final picture = recorder.endRecording();
final img = await picture.toImage(width.toInt(), height.toInt());
final pngBytes = await img.toByteData(format: ImageByteFormat.png);
return pngBytes!.buffer.asUint8List();
}
// 下载图片并返回 Uint8List(简单实现)
static Future<Uint8List?> fetchThumbBytes(String? url) async {
if (url == null || url.isEmpty) return null;
try {
final resp = await http.get(Uri.parse(url));
if (resp.statusCode == 200) return resp.bodyBytes;
} catch (_) {}
return null;
}
}
+74
View File
@@ -0,0 +1,74 @@
// ignore_for_file: use_build_context_synchronously
import 'dart:typed_data';
import 'dart:ui' as ui;
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:share_plus/share_plus.dart';
ui.Rect? shareOriginForContext(BuildContext context) {
final renderObject = context.findRenderObject();
if (renderObject is! RenderBox || !renderObject.hasSize) {
return null;
}
return renderObject.localToGlobal(Offset.zero) & renderObject.size;
}
Future<Uint8List> captureWidgetPng(
GlobalKey key, {
double pixelRatio = 3.0,
}) async {
await WidgetsBinding.instance.endOfFrame;
final context = key.currentContext;
if (context == null) {
throw StateError('share target is not mounted');
}
final renderObject = context.findRenderObject();
if (renderObject is! RenderRepaintBoundary) {
throw StateError('share target is not a repaint boundary');
}
final image = await renderObject.toImage(pixelRatio: pixelRatio);
final byteData = await image.toByteData(format: ui.ImageByteFormat.png);
if (byteData == null) {
throw StateError('failed to convert share image');
}
return byteData.buffer.asUint8List();
}
Future<void> sharePngFromBoundary(
GlobalKey key, {
required String fileName,
String? text,
String? subject,
ui.Rect? sharePositionOrigin,
double pixelRatio = 3.0,
}) async {
final bytes = await captureWidgetPng(key, pixelRatio: pixelRatio);
final xFile = XFile.fromData(bytes, mimeType: 'image/png', name: fileName);
await SharePlus.instance.share(
ShareParams(
files: [xFile],
text: text,
subject: subject,
sharePositionOrigin: sharePositionOrigin,
),
);
}
Future<void> sharePlainText({
required String text,
String? subject,
ui.Rect? sharePositionOrigin,
}) async {
await SharePlus.instance.share(
ShareParams(
text: text,
subject: subject,
sharePositionOrigin: sharePositionOrigin,
),
);
}
+292
View File
@@ -0,0 +1,292 @@
import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
class PrototypeFrame extends StatelessWidget {
const PrototypeFrame({
super.key,
required this.child,
this.top = 0,
this.bottom = 24,
});
final Widget child;
final double top;
final double bottom;
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.fromLTRB(18, top, 18, bottom),
child: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 760),
child: child,
),
),
);
}
}
class PrototypeCard extends StatelessWidget {
const PrototypeCard({
super.key,
required this.child,
this.padding = const EdgeInsets.all(16),
this.margin,
this.radius = 14,
this.decoration,
});
final Widget child;
final EdgeInsetsGeometry padding;
final EdgeInsetsGeometry? margin;
final double radius;
final BoxDecoration? decoration;
@override
Widget build(BuildContext context) {
final cs = ShadTheme.of(context).colorScheme;
return Container(
margin: margin,
decoration: decoration ??
BoxDecoration(
color: cs.card,
border: Border.all(color: cs.border, width: 0.5),
borderRadius: BorderRadius.circular(radius),
),
child: Padding(padding: padding, child: child),
);
}
}
class PrototypePill extends StatelessWidget {
const PrototypePill({
super.key,
required this.label,
this.selected = false,
this.leading,
this.onTap,
});
final String label;
final bool selected;
final Widget? leading;
final VoidCallback? onTap;
@override
Widget build(BuildContext context) {
final cs = ShadTheme.of(context).colorScheme;
final bg = selected ? cs.secondary : cs.background;
final fg = selected ? cs.secondaryForeground : cs.mutedForeground;
final borderColor = selected ? const Color(0xFFE3D6B4) : cs.border;
return InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(999),
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(
color: bg,
borderRadius: BorderRadius.circular(999),
border: Border.all(color: borderColor, width: 0.5),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (leading != null) ...[leading!, const SizedBox(width: 4)],
Text(
label,
style: TextStyle(
fontSize: 12,
fontWeight: selected ? FontWeight.w600 : FontWeight.w500,
color: fg,
),
),
],
),
),
);
}
}
class PrototypeMetricChip extends StatelessWidget {
const PrototypeMetricChip({
super.key,
required this.label,
required this.value,
this.valueColor,
this.background,
});
final String label;
final String value;
final Color? valueColor;
final Color? background;
@override
Widget build(BuildContext context) {
final cs = ShadTheme.of(context).colorScheme;
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: background ?? cs.background,
borderRadius: BorderRadius.circular(999),
border: Border.all(color: cs.border, width: 0.5),
),
child: RichText(
text: TextSpan(
style: TextStyle(fontSize: 10, color: cs.mutedForeground),
children: [
TextSpan(text: '$label '),
TextSpan(
text: value,
style: TextStyle(
fontWeight: FontWeight.w600,
color: valueColor ?? cs.foreground,
),
),
],
),
),
);
}
}
class PrototypeLineChart extends StatelessWidget {
const PrototypeLineChart({
super.key,
required this.values,
this.lineColor = const Color(0xFFB5862A),
this.fillColor = const Color(0xFFF7EFD9),
});
final List<double> values;
final Color lineColor;
final Color fillColor;
@override
Widget build(BuildContext context) {
return CustomPaint(
painter: _PrototypeLineChartPainter(
values: values,
lineColor: lineColor,
fillColor: fillColor,
),
size: Size.infinite,
);
}
}
class _PrototypeLineChartPainter extends CustomPainter {
_PrototypeLineChartPainter({
required this.values,
required this.lineColor,
required this.fillColor,
});
final List<double> values;
final Color lineColor;
final Color fillColor;
@override
void paint(Canvas canvas, Size size) {
if (values.isEmpty || size.isEmpty) return;
final paintGrid = Paint()
..color = const Color(0xFFECEAE3)
..strokeWidth = 1;
final paintLine = Paint()
..color = lineColor
..style = PaintingStyle.stroke
..strokeWidth = 2.4
..strokeJoin = StrokeJoin.round
..strokeCap = StrokeCap.round;
final paintFill = Paint()
..color = fillColor
..style = PaintingStyle.fill;
const padTop = 10.0;
const padBottom = 10.0;
final plotHeight = size.height - padTop - padBottom;
final plotWidth = size.width;
final min = values.reduce((a, b) => a < b ? a : b);
final max = values.reduce((a, b) => a > b ? a : b);
final span = (max - min).abs() < 0.0001 ? 1.0 : max - min;
Offset pointFor(int index) {
final x = values.length == 1
? plotWidth / 2
: index / (values.length - 1) * plotWidth;
final y = padTop + (1 - (values[index] - min) / span) * plotHeight;
return Offset(x, y);
}
for (var i = 0; i < 4; i++) {
final dy = padTop + plotHeight * i / 3;
canvas.drawLine(Offset(0, dy), Offset(size.width, dy), paintGrid);
}
final pts = List.generate(values.length, pointFor);
final path = Path()..moveTo(pts.first.dx, pts.first.dy);
for (final p in pts.skip(1)) {
path.lineTo(p.dx, p.dy);
}
final fillPath = Path()
..addPath(path, Offset.zero)
..lineTo(size.width, size.height)
..lineTo(0, size.height)
..close();
canvas.drawPath(fillPath, paintFill);
canvas.drawPath(path, paintLine);
final last = pts.last;
canvas.drawCircle(last, 3.8, Paint()..color = lineColor);
}
@override
bool shouldRepaint(covariant _PrototypeLineChartPainter oldDelegate) {
return oldDelegate.values != values ||
oldDelegate.lineColor != lineColor ||
oldDelegate.fillColor != fillColor;
}
}
class PrototypeSectionLabel extends StatelessWidget {
const PrototypeSectionLabel(this.label, {super.key, this.trailing});
final String label;
final Widget? trailing;
@override
Widget build(BuildContext context) {
final cs = ShadTheme.of(context).colorScheme;
return Padding(
padding: const EdgeInsets.only(bottom: 10),
child: Row(
children: [
Text(
label,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: cs.foreground,
),
),
const Spacer(),
if (trailing != null) trailing!,
],
),
);
}
}
class PrototypeDivider extends StatelessWidget {
const PrototypeDivider({super.key, this.margin = const EdgeInsets.symmetric(vertical: 10)});
final EdgeInsetsGeometry margin;
@override
Widget build(BuildContext context) {
final cs = ShadTheme.of(context).colorScheme;
return Container(
margin: margin,
height: 0.5,
color: cs.border,
);
}
}
+21
View File
@@ -0,0 +1,21 @@
import 'package:flutter/material.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
const ClassicFooter jinzhiClassicFooter = ClassicFooter(
height: 40,
idleIcon: const SizedBox.shrink(),
canLoadingIcon: const SizedBox.shrink(),
noMoreIcon: const SizedBox.shrink(),
failedIcon: const SizedBox.shrink(),
loadingIcon: const SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(strokeWidth: 2),
),
loadingText: '',
idleText: '',
canLoadingText: '',
noDataText: '',
failedText: '',
textStyle: const TextStyle(fontSize: 12, color: Colors.grey),
);
@@ -49,6 +49,56 @@ class AssetPortfolioController extends StateNotifier<PortfolioSummary> {
);
}
void updateHolding(GoldAssetHolding holding) {
final index = _holdings.indexWhere((item) => item.id == holding.id);
if (index == -1) return;
_holdings[index] = holding;
state = _buildSummary(
holdings: _holdings,
spotPriceFor: _spotPriceFor,
changeFor: _changeFor,
recycleDiscount: recycleDiscount,
);
}
void removeHolding(String id) {
_holdings.removeWhere((item) => item.id == id);
state = _buildSummary(
holdings: _holdings,
spotPriceFor: _spotPriceFor,
changeFor: _changeFor,
recycleDiscount: recycleDiscount,
);
}
void markHoldingSold(String id) {
final index = _holdings.indexWhere((item) => item.id == id);
if (index == -1) return;
final holding = _holdings[index];
_holdings[index] = GoldAssetHolding(
id: holding.id,
name: holding.name,
metal: holding.metal,
category: holding.category,
purity: holding.purity,
purityLabel: holding.purityLabel,
weightGram: holding.weightGram,
costAmount: holding.costAmount,
purchaseDate: holding.purchaseDate,
channel: holding.channel,
note: holding.note,
createdAt: holding.createdAt,
updatedAt: DateTime.now(),
status: HoldingStatus.sold,
);
state = _buildSummary(
holdings: _holdings,
spotPriceFor: _spotPriceFor,
changeFor: _changeFor,
recycleDiscount: recycleDiscount,
);
}
static PortfolioSummary _buildSummary({
required List<GoldAssetHolding> holdings,
required double Function(MetalType metal) spotPriceFor,
+163
View File
@@ -1,5 +1,58 @@
import '../../../common/domain/metal_type.dart';
class AssetImage {
const AssetImage({
required this.localId,
required this.localPath,
required this.createdAt,
this.remoteUrl,
this.thumbnailUrl,
});
final String localId;
final String localPath;
final String? remoteUrl;
final String? thumbnailUrl;
final DateTime createdAt;
AssetImage copyWith({
String? localId,
String? localPath,
String? remoteUrl,
String? thumbnailUrl,
DateTime? createdAt,
}) {
return AssetImage(
localId: localId ?? this.localId,
localPath: localPath ?? this.localPath,
remoteUrl: remoteUrl ?? this.remoteUrl,
thumbnailUrl: thumbnailUrl ?? this.thumbnailUrl,
createdAt: createdAt ?? this.createdAt,
);
}
Map<String, dynamic> toJson() {
return {
'localId': localId,
'localPath': localPath,
'remoteUrl': remoteUrl,
'thumbnailUrl': thumbnailUrl,
'createdAt': createdAt.toIso8601String(),
};
}
factory AssetImage.fromJson(Map<String, dynamic> json) {
return AssetImage(
localId: json['localId'] as String? ?? '',
localPath: json['localPath'] as String? ?? '',
remoteUrl: json['remoteUrl'] as String?,
thumbnailUrl: json['thumbnailUrl'] as String?,
createdAt: DateTime.tryParse(json['createdAt'] as String? ?? '') ??
DateTime.fromMillisecondsSinceEpoch(0),
);
}
}
enum AssetCategory {
bar('金条'),
necklace('项链'),
@@ -28,6 +81,7 @@ class GoldAssetHolding {
required this.weightGram,
required this.createdAt,
required this.updatedAt,
this.images = const [],
this.costAmount,
this.purchaseDate,
this.channel,
@@ -42,6 +96,7 @@ class GoldAssetHolding {
final double purity;
final String purityLabel;
final double weightGram;
final List<AssetImage> images;
final double? costAmount;
final DateTime? purchaseDate;
final String? channel;
@@ -50,7 +105,92 @@ class GoldAssetHolding {
final DateTime updatedAt;
final HoldingStatus status;
GoldAssetHolding copyWith({
String? id,
String? name,
MetalType? metal,
AssetCategory? category,
double? purity,
String? purityLabel,
double? weightGram,
List<AssetImage>? images,
double? costAmount,
DateTime? purchaseDate,
String? channel,
String? note,
DateTime? createdAt,
DateTime? updatedAt,
HoldingStatus? status,
}) {
return GoldAssetHolding(
id: id ?? this.id,
name: name ?? this.name,
metal: metal ?? this.metal,
category: category ?? this.category,
purity: purity ?? this.purity,
purityLabel: purityLabel ?? this.purityLabel,
weightGram: weightGram ?? this.weightGram,
images: images ?? this.images,
costAmount: costAmount ?? this.costAmount,
purchaseDate: purchaseDate ?? this.purchaseDate,
channel: channel ?? this.channel,
note: note ?? this.note,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt,
status: status ?? this.status,
);
}
double materialValue(double spotPrice) => weightGram * purity * spotPrice;
Map<String, dynamic> toJson() {
return {
'id': id,
'name': name,
'metalId': metal.id,
'categoryId': category.name,
'purity': purity,
'purityLabel': purityLabel,
'weightGram': weightGram,
'images': images.map((item) => item.toJson()).toList(growable: false),
'costAmount': costAmount,
'purchaseDate': purchaseDate?.toIso8601String(),
'channel': channel,
'note': note,
'createdAt': createdAt.toIso8601String(),
'updatedAt': updatedAt.toIso8601String(),
'status': status.name,
};
}
factory GoldAssetHolding.fromJson(Map<String, dynamic> json) {
final rawImages = json['images'];
return GoldAssetHolding(
id: json['id'] as String? ?? '',
name: json['name'] as String? ?? '',
metal: _metalFromId(json['metalId'] as String?),
category: _categoryFromId(json['categoryId'] as String?),
purity: (json['purity'] as num?)?.toDouble() ?? 1,
purityLabel: json['purityLabel'] as String? ?? '',
weightGram: (json['weightGram'] as num?)?.toDouble() ?? 0,
images: rawImages is List
? [
for (final raw in rawImages)
if (raw is Map)
AssetImage.fromJson(Map<String, dynamic>.from(raw)),
]
: const [],
costAmount: (json['costAmount'] as num?)?.toDouble(),
purchaseDate: DateTime.tryParse(json['purchaseDate'] as String? ?? ''),
channel: json['channel'] as String?,
note: json['note'] as String?,
createdAt: DateTime.tryParse(json['createdAt'] as String? ?? '') ??
DateTime.fromMillisecondsSinceEpoch(0),
updatedAt: DateTime.tryParse(json['updatedAt'] as String? ?? '') ??
DateTime.fromMillisecondsSinceEpoch(0),
status: _statusFromName(json['status'] as String?),
);
}
}
class HoldingValuation {
@@ -100,3 +240,26 @@ class PortfolioSummary {
final List<MetalBreakdown> breakdowns;
final List<HoldingValuation> holdings;
}
MetalType _metalFromId(String? id) {
return switch (id) {
'gold' => MetalType.gold,
'platinum' => MetalType.platinum,
'silver' => MetalType.silver,
_ => MetalType.gold,
};
}
AssetCategory _categoryFromId(String? id) {
return AssetCategory.values.firstWhere(
(item) => item.name == id,
orElse: () => AssetCategory.bar,
);
}
HoldingStatus _statusFromName(String? value) {
return HoldingStatus.values.firstWhere(
(item) => item.name == value,
orElse: () => HoldingStatus.active,
);
}
@@ -0,0 +1,12 @@
import 'package:flutter/material.dart';
import 'asset_form_page.dart';
class AssetAddPage extends StatelessWidget {
const AssetAddPage({super.key});
@override
Widget build(BuildContext context) {
return const AssetFormPage.create();
}
}
@@ -0,0 +1,21 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import '../application/asset_portfolio_controller.dart';
import 'asset_form_page.dart';
class AssetEditPage extends ConsumerWidget {
const AssetEditPage({super.key, required this.id});
final String id;
@override
Widget build(BuildContext context, WidgetRef ref) {
final holding = ref
.watch(assetPortfolioControllerProvider)
.holdings
.map((item) => item.holding)
.firstWhere((item) => item.id == id);
return AssetFormPage.edit(holding: holding);
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,95 @@
import 'dart:io';
import 'package:flutter/material.dart' hide AssetImage;
import 'package:photo_view/photo_view.dart';
import 'package:photo_view/photo_view_gallery.dart';
import '../data/asset_models.dart';
class AssetImagePreviewPage extends StatefulWidget {
const AssetImagePreviewPage({
super.key,
required this.images,
required this.initialIndex,
});
final List<AssetImage> images;
final int initialIndex;
@override
State<AssetImagePreviewPage> createState() => _AssetImagePreviewPageState();
}
class _AssetImagePreviewPageState extends State<AssetImagePreviewPage> {
late final PageController _pageController;
late int _currentIndex;
@override
void initState() {
super.initState();
_currentIndex = widget.initialIndex.clamp(0, widget.images.length - 1);
_pageController = PageController(initialPage: _currentIndex);
}
@override
void dispose() {
_pageController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
body: SafeArea(
child: Stack(
children: [
PhotoViewGallery.builder(
pageController: _pageController,
itemCount: widget.images.length,
builder: (context, index) {
final image = widget.images[index];
return PhotoViewGalleryPageOptions(
imageProvider: FileImage(File(image.localPath)),
minScale: PhotoViewComputedScale.contained,
maxScale: PhotoViewComputedScale.covered * 2.2,
);
},
onPageChanged: (index) => setState(() {
_currentIndex = index;
}),
backgroundDecoration: const BoxDecoration(color: Colors.black),
),
Positioned(
top: 16,
left: 16,
child: IconButton(
onPressed: () => Navigator.of(context).pop(),
icon: const Icon(Icons.close, color: Colors.white),
),
),
Positioned(
bottom: 24,
left: 0,
right: 0,
child: Center(
child: Container(
padding:
const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(
color: Colors.black54,
borderRadius: BorderRadius.circular(999),
),
child: Text(
'${_currentIndex + 1}/${widget.images.length}',
style: const TextStyle(color: Colors.white, fontSize: 14),
),
),
),
),
],
),
),
);
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,603 @@
import 'dart:io';
import 'package:flutter/material.dart' hide AssetImage;
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import '../../../common/domain/money.dart';
import '../../../common/router/app_router.dart';
import '../../../common/widgets/prototype_ui.dart';
import '../../profile/application/price_color_theme.dart';
import '../../profile/application/profile_settings_controller.dart';
import '../application/asset_portfolio_controller.dart';
import '../data/asset_models.dart';
import 'asset_image_preview_page.dart';
class HoldingDetailPage extends ConsumerWidget {
const HoldingDetailPage({super.key, this.id});
final String? id;
@override
Widget build(BuildContext context, WidgetRef ref) {
final summary = ref.watch(assetPortfolioControllerProvider);
final holding = summary.holdings
.map((item) => item.holding)
.firstWhere(
(item) => id == null || item.id == id,
orElse: () => summary.holdings.first.holding,
);
final valuation = summary.holdings.firstWhere(
(item) => item.holding.id == holding.id,
);
final cs = ShadTheme.of(context).colorScheme;
final palette = priceColorPalette(
ref.watch(profileSettingsControllerProvider).priceColorMode,
);
final changeUp = valuation.todayChange >= 0;
return Scaffold(
backgroundColor: const Color(0xFFFBFAF7),
appBar: AppBar(
backgroundColor: const Color(0xFFFBFAF7),
surfaceTintColor: Colors.transparent,
elevation: 0,
scrolledUnderElevation: 0,
centerTitle: true,
leading: IconButton(
onPressed: () => Navigator.of(context).pop(),
icon: const Icon(Icons.chevron_left, size: 20),
),
title: Text(
holding.name,
style: const TextStyle(fontSize: 17, fontWeight: FontWeight.w600),
),
actions: [
IconButton(
onPressed: () => _showActionsSheet(context, ref, holding),
icon: const Icon(Icons.more_horiz, size: 22),
color: const Color(0xFF8A8780),
),
],
),
body: SafeArea(
child: ListView(
padding: const EdgeInsets.fromLTRB(0, 8, 0, 28),
children: [
PrototypeFrame(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SizedBox(height: 4),
PrototypeCard(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Container(
width: 36,
height: 36,
decoration: BoxDecoration(
color: holding.metal.color.withValues(
alpha: 0.15,
),
borderRadius: BorderRadius.circular(10),
),
child: Icon(
Icons.circle_outlined,
color: holding.metal.color,
size: 18,
),
),
const SizedBox(width: 10),
Text(
'${holding.purityLabel} · ${holding.weightGram.toStringAsFixed(1)}g',
style: TextStyle(
fontSize: 12,
color: cs.mutedForeground,
),
),
],
),
const SizedBox(height: 12),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'¥',
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.w600,
),
),
const SizedBox(width: 2),
Text(
formatCny(
valuation.materialValue,
).replaceFirst('¥', ''),
style: const TextStyle(
fontSize: 42,
fontWeight: FontWeight.w600,
letterSpacing: -1,
height: 1,
),
),
],
),
const SizedBox(height: 10),
Row(
children: [
_ChangeChip(
amount: valuation.todayChange,
positive: changeUp,
upColor: Color(palette.up),
downColor: Color(palette.down),
upBackground: Color(palette.upBackground),
downBackground: Color(palette.downBackground),
),
const SizedBox(width: 8),
Text(
'今日',
style: TextStyle(
fontSize: 12,
color: cs.mutedForeground,
),
),
],
),
],
),
),
const SizedBox(height: 12),
GestureDetector(
onTap: () => context.push(
'${AppRoutes.marketKline}?metal=${holding.metal.id}&period=24h',
),
child: PrototypeCard(
padding: const EdgeInsets.fromLTRB(14, 12, 14, 12),
child: SizedBox(
height: 92,
child: ClipRRect(
borderRadius: BorderRadius.circular(10),
child: PrototypeLineChart(
values: const [
18,
20,
21,
23,
22,
25,
29,
31,
30,
33,
35,
37,
],
),
),
),
),
),
const SizedBox(height: 12),
PrototypeCard(
padding: EdgeInsets.zero,
child: Column(
children: [
_InfoRow(
label: '材料价值(现货)',
value: formatCny(valuation.materialValue),
),
const PrototypeDivider(margin: EdgeInsets.zero),
_InfoRow(
label: '回收参考价',
value: formatCny(valuation.materialValue * 0.97),
),
if (holding.costAmount != null) ...[
const PrototypeDivider(margin: EdgeInsets.zero),
_InfoRow(
label: '买入成本',
value: formatCny(holding.costAmount!),
),
const PrototypeDivider(margin: EdgeInsets.zero),
_InfoRow(
label: '盈亏',
value: _signedCny(
valuation.materialValue - holding.costAmount!,
),
valueColor:
valuation.materialValue - holding.costAmount! >=
0
? Color(palette.up)
: Color(palette.down),
),
],
],
),
),
const SizedBox(height: 12),
PrototypeCard(
padding: EdgeInsets.zero,
child: Column(
children: [
_InfoRow(
label: '金属 / 纯度',
value:
'${holding.metal.label} · ${holding.purityLabel}',
),
const PrototypeDivider(margin: EdgeInsets.zero),
_InfoRow(
label: '克重',
value: '${holding.weightGram.toStringAsFixed(1)} g',
),
const PrototypeDivider(margin: EdgeInsets.zero),
_InfoRow(
label: '购买日期',
value: _dateLabel(holding.purchaseDate),
),
const PrototypeDivider(margin: EdgeInsets.zero),
_InfoRow(label: '购买渠道', value: holding.channel ?? '未填'),
const PrototypeDivider(margin: EdgeInsets.zero),
_InfoRow(
label: '备注',
value: holding.note == null ||
holding.note!.trim().isEmpty
? '未填'
: holding.note!.trim(),
),
],
),
),
const SizedBox(height: 12),
_buildImageSection(context, holding),
const SizedBox(height: 12),
Row(
children: [
Expanded(
child: OutlinedButton(
onPressed: () => context.push(
'${AppRoutes.assetEdit}?id=${holding.id}',
),
style: OutlinedButton.styleFrom(
side: const BorderSide(color: Color(0xFFE3D6B4)),
padding: const EdgeInsets.symmetric(vertical: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14),
),
foregroundColor: const Color(0xFF9A7A2A),
),
child: const Text('编辑'),
),
),
const SizedBox(width: 10),
Expanded(
child: OutlinedButton(
onPressed: () => _markSold(context, ref, holding.id),
style: OutlinedButton.styleFrom(
side: const BorderSide(color: Color(0xFFE6E1D8)),
foregroundColor: const Color(0xFF8A8780),
padding: const EdgeInsets.symmetric(vertical: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14),
),
),
child: const Text('标记卖出 / 转赠'),
),
),
],
),
],
),
),
],
),
),
);
}
void _showActionsSheet(
BuildContext context,
WidgetRef ref,
GoldAssetHolding holding,
) {
showModalBottomSheet<void>(
context: context,
backgroundColor: Colors.white,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(22)),
),
builder: (ctx) => SafeArea(
child: Padding(
padding: const EdgeInsets.fromLTRB(20, 8, 20, 20),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Center(
child: Container(
width: 38,
height: 4,
margin: const EdgeInsets.only(bottom: 16),
decoration: BoxDecoration(
color: const Color(0xFFE3DFD4),
borderRadius: BorderRadius.circular(999),
),
),
),
_ActionMenuTile(
icon: Icons.edit_outlined,
label: '编辑持仓',
onTap: () {
Navigator.of(ctx).pop();
context.push('${AppRoutes.assetEdit}?id=${holding.id}');
},
),
const PrototypeDivider(margin: EdgeInsets.zero),
_ActionMenuTile(
icon: Icons.share_outlined,
label: '分享这张的估值卡',
onTap: () {
Navigator.of(ctx).pop();
context.push(AppRoutes.profileShare);
},
),
const PrototypeDivider(margin: EdgeInsets.zero),
_ActionMenuTile(
icon: Icons.sell_outlined,
label: '标记卖出 / 转赠',
labelColor: const Color(0xFFC0392B),
iconColor: const Color(0xFFC0392B),
onTap: () {
Navigator.of(ctx).pop();
_markSold(context, ref, holding.id);
},
),
const SizedBox(height: 12),
SizedBox(
width: double.infinity,
child: OutlinedButton(
onPressed: () => Navigator.of(ctx).pop(),
child: const Text('取消'),
),
),
],
),
),
),
);
}
void _markSold(BuildContext context, WidgetRef ref, String id) {
ref.read(assetPortfolioControllerProvider.notifier).markHoldingSold(id);
ScaffoldMessenger.of(
context,
).showSnackBar(const SnackBar(content: Text('已标记卖出 / 转赠')));
Navigator.of(context).pop();
}
Widget _buildImageSection(
BuildContext context,
GoldAssetHolding holding,
) {
final images = holding.images;
return PrototypeCard(
padding: const EdgeInsets.fromLTRB(16, 16, 16, 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'凭证照片',
style: TextStyle(fontSize: 13, color: Color(0xFF8A8780)),
),
const SizedBox(height: 12),
if (images.isEmpty)
const Text(
'暂无凭证照片,可在添加资产时上传发票、证书或实物照片。',
style: TextStyle(fontSize: 12, color: Color(0xFFB3AFA5)),
)
else
Wrap(
spacing: 8,
runSpacing: 8,
children: [
for (var index = 0; index < images.length; index++)
_buildDetailImageTile(
context,
holding,
images[index],
index,
),
],
),
],
),
);
}
Widget _buildDetailImageTile(
BuildContext context,
GoldAssetHolding holding,
AssetImage image,
int index,
) {
return GestureDetector(
onTap: () => _openImagePreview(context, holding.images, index),
child: ClipRRect(
borderRadius: BorderRadius.circular(12),
child: Image.file(
File(image.localPath),
width: 84,
height: 84,
fit: BoxFit.cover,
),
),
);
}
void _openImagePreview(
BuildContext context,
List<AssetImage> images,
int initialIndex,
) {
Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (_) => AssetImagePreviewPage(
images: images,
initialIndex: initialIndex,
),
),
);
}
}
class _ActionMenuTile extends StatelessWidget {
const _ActionMenuTile({
required this.icon,
required this.label,
required this.onTap,
this.iconColor,
this.labelColor,
});
final IconData icon;
final String label;
final VoidCallback onTap;
final Color? iconColor;
final Color? labelColor;
@override
Widget build(BuildContext context) {
final cs = ShadTheme.of(context).colorScheme;
return InkWell(
onTap: onTap,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 16),
child: Row(
children: [
Icon(icon, size: 20, color: iconColor ?? const Color(0xFF8A8780)),
const SizedBox(width: 12),
Text(
label,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w600,
color: labelColor ?? cs.foreground,
),
),
],
),
),
);
}
}
class _InfoRow extends StatelessWidget {
const _InfoRow({required this.label, required this.value, this.valueColor});
final String label;
final String value;
final Color? valueColor;
@override
Widget build(BuildContext context) {
final cs = ShadTheme.of(context).colorScheme;
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 11),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
label,
style: TextStyle(fontSize: 13, color: cs.mutedForeground),
),
Text(
value,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: valueColor ?? cs.foreground,
),
),
],
),
);
}
}
class _ChangeChip extends StatelessWidget {
const _ChangeChip({
required this.amount,
required this.positive,
required this.upColor,
required this.downColor,
required this.upBackground,
required this.downBackground,
});
final double amount;
final bool positive;
final Color upColor;
final Color downColor;
final Color upBackground;
final Color downBackground;
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
decoration: BoxDecoration(
color: positive ? upBackground : downBackground,
borderRadius: BorderRadius.circular(999),
),
child: Text(
'${positive ? '' : ''}${formatCny(amount.abs())} · ${positive ? '+' : '-'}${amount.abs().toStringAsFixed(2)}',
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w600,
color: positive ? upColor : downColor,
),
),
);
}
}
class _FieldRow extends StatelessWidget {
const _FieldRow({required this.label, required this.child});
final String label;
final Widget child;
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.fromLTRB(14, 12, 14, 12),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: const Color(0xFFECEAE3), width: 0.5),
),
child: Row(
children: [
Text(
label,
style: const TextStyle(fontSize: 13, color: Color(0xFF8A8780)),
),
const SizedBox(width: 10),
Expanded(child: child),
],
),
);
}
}
String _dateLabel(DateTime? value) {
if (value == null) return '未填';
return '${value.year}-${value.month.toString().padLeft(2, '0')}-${value.day.toString().padLeft(2, '0')}';
}
String _signedCny(double value) {
final sign = value >= 0 ? '+' : '-';
return '$sign${formatCny(value.abs())}';
}
@@ -669,7 +669,9 @@ class _VerifySheetState extends ConsumerState<_VerifySheet> {
final cs = ShadTheme.of(context).colorScheme;
return Padding(
// 键盘弹出时 sheet 跟随上移
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom,
),
child: SafeArea(
child: Padding(
padding: const EdgeInsets.fromLTRB(20, 8, 20, 20),
@@ -715,11 +717,7 @@ class _VerifySheetState extends ConsumerState<_VerifySheet> {
return [
Text(
'正在清除账户数据,请稍候',
style: TextStyle(
fontSize: 13,
height: 1.55,
color: cs.mutedForeground,
),
style: TextStyle(fontSize: 13, height: 1.55, color: cs.mutedForeground),
),
const SizedBox(height: 28),
Center(
@@ -737,11 +735,7 @@ class _VerifySheetState extends ConsumerState<_VerifySheet> {
return [
Text(
'为保障账户安全,注销前需验证您的手机号。验证码将发送至 ${_maskPhone(widget.phone)}',
style: TextStyle(
fontSize: 13,
height: 1.55,
color: cs.mutedForeground,
),
style: TextStyle(fontSize: 13, height: 1.55, color: cs.mutedForeground),
),
if (_error != null) ...[
const SizedBox(height: 10),
@@ -768,11 +762,7 @@ class _VerifySheetState extends ConsumerState<_VerifySheet> {
return [
Text(
'验证码已发送至 ${_maskPhone(widget.phone)}',
style: TextStyle(
fontSize: 13,
height: 1.55,
color: cs.mutedForeground,
),
style: TextStyle(fontSize: 13, height: 1.55, color: cs.mutedForeground),
),
const SizedBox(height: 20),
_PinInput(
@@ -864,7 +854,7 @@ class DeleteAccountSuccessPage extends ConsumerWidget {
),
const SizedBox(height: 10),
Text(
'您的账号及相关数据已清除完毕\n感谢您曾使用研听',
'您的账号及相关数据已清除完毕\n感谢您曾使用金值',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 13,
@@ -259,7 +259,7 @@ class _PhoneStep extends StatelessWidget {
children: [
_SheetTitle('手机号登录', cs),
const SizedBox(height: 8),
_SheetSub('未注册的手机号验证后将自动创建研听账号。', cs),
_SheetSub('未注册的手机号验证后将自动创建金值账号。', cs),
const SizedBox(height: 18),
Row(
children: [
@@ -0,0 +1,227 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import '../../../common/domain/metal_type.dart';
import '../../../common/widgets/prototype_ui.dart';
import '../../profile/application/price_color_theme.dart';
import '../../profile/application/profile_settings_controller.dart';
import '../data/mock_market_repository.dart';
import '../data/market_models.dart';
class MarketKlinePage extends ConsumerWidget {
const MarketKlinePage({super.key, this.metalId, this.periodId});
final String? metalId;
final String? periodId;
@override
Widget build(BuildContext context, WidgetRef ref) {
final repo = ref.watch(mockMarketRepositoryProvider);
final metal = _metalFromId(metalId) ?? MetalType.gold;
final period = _periodFromId(periodId) ?? MarketPeriod.h24;
final quote = repo.quoteFor(metal);
final points = repo.chartFor(metal, period);
final cs = ShadTheme.of(context).colorScheme;
final palette = priceColorPalette(
ref.watch(profileSettingsControllerProvider).priceColorMode,
);
return Scaffold(
backgroundColor: const Color(0xFFFBFAF7),
appBar: AppBar(
backgroundColor: const Color(0xFFFBFAF7),
surfaceTintColor: Colors.transparent,
elevation: 0,
scrolledUnderElevation: 0,
centerTitle: true,
leading: IconButton(
onPressed: () => Navigator.of(context).pop(),
icon: const Icon(Icons.chevron_left, size: 20),
),
title: Text(
'${metal.label} K线',
style: const TextStyle(fontSize: 17, fontWeight: FontWeight.w600),
),
),
body: SafeArea(
child: ListView(
padding: const EdgeInsets.fromLTRB(0, 8, 0, 24),
children: [
PrototypeFrame(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SizedBox(height: 4),
PrototypeCard(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text(
'¥',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w600,
color: cs.foreground,
),
),
const SizedBox(width: 2),
Text(
quote.spotPrice.toStringAsFixed(2),
style: const TextStyle(
fontSize: 29,
fontWeight: FontWeight.w600,
letterSpacing: -1,
),
),
const SizedBox(width: 4),
const Padding(
padding: EdgeInsets.only(top: 8),
child: Text(
'元/克',
style: TextStyle(
fontSize: 12,
color: Color(0xFF8A8780),
),
),
),
],
),
const SizedBox(height: 6),
Text(
'${quote.changeAmount >= 0 ? '+' : ''}${quote.changeAmount.toStringAsFixed(2)} · ${quote.changePercent.toStringAsFixed(2)}%',
style: TextStyle(
color: quote.changeAmount >= 0
? Color(palette.up)
: Color(palette.down),
fontSize: 13,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 12),
Wrap(
spacing: 8,
runSpacing: 8,
children: [
for (final p in MarketPeriod.values)
PrototypePill(
label: p.label,
selected: p == period,
onTap: () =>
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (_) => MarketKlinePage(
metalId: metal.id,
periodId: p.id,
),
),
),
),
],
),
const SizedBox(height: 10),
Row(
children: [
_Ohlc('', points.first.open),
const SizedBox(width: 18),
_Ohlc(
'',
points
.map((e) => e.high)
.reduce((a, b) => a > b ? a : b),
),
const SizedBox(width: 18),
_Ohlc(
'',
points
.map((e) => e.low)
.reduce((a, b) => a < b ? a : b),
),
const SizedBox(width: 18),
_Ohlc('', points.last.close),
],
),
const SizedBox(height: 12),
SizedBox(
height: 300,
child: ClipRRect(
borderRadius: BorderRadius.circular(10),
child: PrototypeLineChart(
values: points
.map((p) => p.close)
.toList(growable: false),
),
),
),
const SizedBox(height: 10),
Text(
'${quote.basisLabel} · ${_timeLabel(quote.updatedAt)}',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 11,
color: cs.mutedForeground,
),
),
],
),
),
],
),
),
],
),
),
);
}
}
class _Ohlc extends StatelessWidget {
const _Ohlc(this.label, this.value);
final String label;
final double value;
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
label,
style: const TextStyle(fontSize: 12, color: Color(0xFF8A8780)),
),
const SizedBox(height: 2),
Text(
value.toStringAsFixed(2),
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w600),
),
],
);
}
}
MetalType? _metalFromId(String? id) {
return switch (id) {
'gold' => MetalType.gold,
'platinum' => MetalType.platinum,
'silver' => MetalType.silver,
_ => null,
};
}
MarketPeriod? _periodFromId(String? id) {
return switch (id) {
'24h' => MarketPeriod.h24,
'5d' => MarketPeriod.d5,
'1m' => MarketPeriod.m1,
'3m' => MarketPeriod.m3,
'1y' => MarketPeriod.y1,
_ => null,
};
}
String _timeLabel(DateTime value) {
return '${value.hour.toString().padLeft(2, '0')}:${value.minute.toString().padLeft(2, '0')}';
}
+729 -127
View File
@@ -1,149 +1,418 @@
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import '../../../common/domain/metal_type.dart';
import '../../../common/domain/money.dart';
import '../../../common/widgets/adaptive.dart';
import '../../../common/router/app_router.dart';
import '../../../common/widgets/prototype_ui.dart';
import '../../profile/application/price_color_theme.dart';
import '../../profile/application/profile_settings_controller.dart';
import '../application/exchange_calculator_controller.dart';
import '../application/market_controller.dart';
import '../data/market_models.dart';
class MarketPage extends ConsumerWidget {
class MarketPage extends HookConsumerWidget {
const MarketPage({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final market = ref.watch(marketControllerProvider);
final exchange = ref.watch(exchangeCalculatorControllerProvider);
final palette = priceColorPalette(
ref.watch(profileSettingsControllerProvider).priceColorMode,
);
final gramCtrl = useTextEditingController(
text: exchange.gram.toStringAsFixed(2),
);
final amountCtrl = useTextEditingController(
text: exchange.amount.toStringAsFixed(2),
);
final gramFocus = useFocusNode();
final amountFocus = useFocusNode();
final cs = ShadTheme.of(context).colorScheme;
useEffect(
() {
if (!gramFocus.hasFocus) {
gramCtrl.text = exchange.gram.toStringAsFixed(
exchange.gram % 1 == 0 ? 0 : 2,
);
}
if (!amountFocus.hasFocus) {
amountCtrl.text = exchange.amount.toStringAsFixed(2);
}
return null;
},
[
exchange.gram,
exchange.amount,
exchange.selectedChannel.id,
exchange.metal.id,
],
);
return SafeArea(
top: false,
child: ListView(
padding: const EdgeInsets.fromLTRB(18, 18, 18, 24),
padding: const EdgeInsets.fromLTRB(0, 8, 0, 20),
children: [
Center(
child: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: Adaptive.contentMaxWidth,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SegmentedButton<MetalType>(
segments: [
for (final metal in MetalType.values)
ButtonSegment(value: metal, label: Text(metal.label)),
PrototypeFrame(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Row(
children: [
const Text(
'行情',
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.w600,
),
),
const Spacer(),
GestureDetector(
onTap: () =>
_showPriceAlertSheet(context, market.selectedMetal),
child: Container(
width: 30,
height: 30,
decoration: BoxDecoration(
color: const Color(0xFFF7F4EE),
borderRadius: BorderRadius.circular(999),
),
child: const Icon(
Icons.notifications_none_outlined,
size: 18,
color: Color(0xFF9A968D),
),
),
),
],
),
const SizedBox(height: 14),
Row(
children: [
for (var i = 0; i < MetalType.values.length; i++) ...[
Expanded(
child: _MetalTab(
label: MetalType.values[i].label,
selected: MetalType.values[i] == market.selectedMetal,
onTap: () {
final metal = MetalType.values[i];
ref
.read(marketControllerProvider.notifier)
.selectMetal(metal);
ref
.read(
exchangeCalculatorControllerProvider.notifier,
)
.selectMetal(metal);
},
),
),
if (i != MetalType.values.length - 1)
const SizedBox(width: 8),
],
selected: {market.selectedMetal},
onSelectionChanged: (next) {
final metal = next.first;
ref
.read(marketControllerProvider.notifier)
.selectMetal(metal);
ref
.read(exchangeCalculatorControllerProvider.notifier)
.selectMetal(metal);
},
),
const SizedBox(height: 12),
_Card(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(market.quote.basisLabel, style: _mutedStyle(cs)),
const SizedBox(height: 8),
Text(
'${formatCny(market.quote.spotPrice)} / 克',
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.w800,
color: cs.foreground,
],
),
const SizedBox(height: 10),
PrototypeCard(
padding: const EdgeInsets.fromLTRB(14, 12, 14, 13),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
'¥',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w600,
color: cs.foreground,
),
),
),
const SizedBox(height: 6),
Text(
'${market.quote.changeAmount >= 0 ? '+' : ''}${market.quote.changeAmount.toStringAsFixed(2)} · ${market.quote.changePercent.toStringAsFixed(2)}%',
style: TextStyle(
color: market.quote.changeAmount >= 0
? const Color(0xFFC0392B)
: const Color(0xFF2E8B6F),
const SizedBox(width: 2),
Text(
formatCny(
market.quote.spotPrice,
).replaceFirst('¥', ''),
style: TextStyle(
fontSize: 29,
fontWeight: FontWeight.w600,
color: cs.foreground,
letterSpacing: -1,
height: 1,
),
),
),
const SizedBox(height: 14),
Wrap(
spacing: 8,
children: [
for (final period in MarketPeriod.values)
ChoiceChip(
label: Text(period.label),
selected: period == market.period,
onSelected: (_) => ref
.read(marketControllerProvider.notifier)
.selectPeriod(period),
const Padding(
padding: EdgeInsets.only(left: 4, bottom: 2),
child: Text(
'元/克',
style: TextStyle(
fontSize: 12,
color: Color(0xFF8A8780),
),
),
),
],
),
const SizedBox(height: 6),
Row(
children: [
_ChangeChip(
amount: market.quote.changeAmount,
percent: market.quote.changePercent,
upColor: Color(palette.up),
downColor: Color(palette.down),
upBackground: Color(palette.upBackground),
downBackground: Color(palette.downBackground),
),
const SizedBox(width: 8),
Text(
'报价 ${_timeLabel(market.quote.updatedAt)}',
style: const TextStyle(
fontSize: 12,
color: Color(0xFF8A8780),
),
),
const Spacer(),
GestureDetector(
onTap: () {},
child: const Icon(
Icons.info_outline,
size: 16,
color: Color(0xFFB3AFA5),
),
),
],
),
const SizedBox(height: 10),
Row(
children: [
for (final period in MarketPeriod.values) ...[
_PeriodPill(
label: period.label,
selected: period == market.period,
onTap: () => ref
.read(marketControllerProvider.notifier)
.selectPeriod(period),
),
if (period != MarketPeriod.values.last)
const SizedBox(width: 6),
],
],
),
const SizedBox(height: 8),
GestureDetector(
onTap: () => context.push(
'${AppRoutes.marketKline}?metal=${market.selectedMetal.id}&period=${market.period.id}',
),
const SizedBox(height: 14),
Text(
'走势图 mock 点位:${market.points.length}',
style: _mutedStyle(cs),
child: SizedBox(
height: 88,
child: ClipRRect(
borderRadius: BorderRadius.circular(10),
child: PrototypeLineChart(
values: market.points
.map((p) => p.close)
.toList(growable: false),
),
),
),
),
const SizedBox(height: 10),
Container(height: 0.5, color: cs.border),
const SizedBox(height: 10),
Row(
children: [
const Text(
'兑换试算',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
),
),
],
),
const SizedBox(height: 8),
SizedBox(
height: 32,
child: ListView.separated(
scrollDirection: Axis.horizontal,
physics: const BouncingScrollPhysics(),
itemCount: exchange.channels.length,
separatorBuilder: (context, index) =>
const SizedBox(width: 7),
itemBuilder: (context, index) {
final channel = exchange.channels[index];
return PrototypePill(
label: channel.name,
selected:
channel.id == exchange.selectedChannel.id,
onTap: () => ref
.read(
exchangeCalculatorControllerProvider
.notifier,
)
.selectChannel(channel.id),
);
},
),
),
const SizedBox(height: 10),
if (!exchange.swapped) ...[
_ExchangeField(
controller: gramCtrl,
focusNode: gramFocus,
unit: exchange.metal.label,
leading: '',
onChanged: (value) {
final gram = double.tryParse(value) ?? 0;
ref
.read(
exchangeCalculatorControllerProvider.notifier,
)
.setGram(gram);
},
),
const SizedBox(height: 8),
Center(
child: GestureDetector(
onTap: () => ref
.read(
exchangeCalculatorControllerProvider.notifier,
)
.toggleSwapped(),
child: Container(
width: 30,
height: 30,
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
color: cs.border,
width: 0.5,
),
shape: BoxShape.circle,
boxShadow: const [
BoxShadow(
color: Color(0x1F281F0C),
blurRadius: 7,
offset: Offset(0, 2),
),
],
),
child: const Icon(
Icons.swap_vert,
size: 16,
color: Color(0xFFB5862A),
),
),
),
),
const SizedBox(height: 8),
_ExchangeField(
controller: amountCtrl,
focusNode: amountFocus,
unit: 'CNY',
leading: '¥',
onChanged: (value) {
final amount = double.tryParse(value) ?? 0;
ref
.read(
exchangeCalculatorControllerProvider.notifier,
)
.setAmount(amount);
},
),
] else ...[
_ExchangeField(
controller: amountCtrl,
focusNode: amountFocus,
unit: 'CNY',
leading: '¥',
onChanged: (value) {
final amount = double.tryParse(value) ?? 0;
ref
.read(
exchangeCalculatorControllerProvider.notifier,
)
.setAmount(amount);
},
),
const SizedBox(height: 8),
Center(
child: GestureDetector(
onTap: () => ref
.read(
exchangeCalculatorControllerProvider.notifier,
)
.toggleSwapped(),
child: Container(
width: 30,
height: 30,
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
color: cs.border,
width: 0.5,
),
shape: BoxShape.circle,
boxShadow: const [
BoxShadow(
color: Color(0x1F281F0C),
blurRadius: 7,
offset: Offset(0, 2),
),
],
),
child: const Icon(
Icons.swap_vert,
size: 16,
color: Color(0xFFB5862A),
),
),
),
),
const SizedBox(height: 8),
_ExchangeField(
controller: gramCtrl,
focusNode: gramFocus,
unit: exchange.metal.label,
leading: '',
onChanged: (value) {
final gram = double.tryParse(value) ?? 0;
ref
.read(
exchangeCalculatorControllerProvider.notifier,
)
.setGram(gram);
},
),
],
),
const SizedBox(height: 10),
Text(
'1 克 ${exchange.metal.label} = ${formatCny(exchange.selectedChannel.pricePerGram)} · ${exchange.selectedChannel.source} · ${_timeLabel(exchange.selectedChannel.updatedAt)} · 参考',
style: const TextStyle(
fontSize: 12,
color: Color(0xFF6E6A60),
),
),
const SizedBox(height: 5),
Text(
exchange.selectedChannel.hint,
style: const TextStyle(
fontSize: 11,
color: Color(0xFFB3AFA5),
height: 1.5,
),
),
],
),
const SizedBox(height: 12),
_Card(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'兑换试算',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
color: cs.foreground,
),
),
const SizedBox(height: 10),
Text(
'${formatGram(exchange.gram)} ${exchange.metal.label} = ${formatCny(exchange.amount)}',
style: TextStyle(fontSize: 20, color: cs.foreground),
),
const SizedBox(height: 8),
Text(
'1 克 ${exchange.metal.label} = ${formatCny(exchange.selectedChannel.pricePerGram)} · ${exchange.selectedChannel.source}',
style: _mutedStyle(cs),
),
const SizedBox(height: 10),
Wrap(
spacing: 8,
runSpacing: 8,
children: [
for (final channel in exchange.channels)
ChoiceChip(
label: Text(channel.name),
selected:
channel.id == exchange.selectedChannel.id,
onSelected: (_) => ref
.read(
exchangeCalculatorControllerProvider
.notifier,
)
.selectChannel(channel.id),
),
],
),
const SizedBox(height: 8),
Text(
exchange.selectedChannel.hint,
style: _mutedStyle(cs),
),
],
),
),
],
),
),
],
),
),
],
@@ -152,25 +421,358 @@ class MarketPage extends ConsumerWidget {
}
}
class _Card extends StatelessWidget {
const _Card({required this.child});
class _ExchangeField extends StatelessWidget {
const _ExchangeField({
required this.controller,
required this.focusNode,
required this.unit,
required this.leading,
required this.onChanged,
});
final Widget child;
final TextEditingController controller;
final FocusNode focusNode;
final String unit;
final String leading;
final ValueChanged<String> onChanged;
@override
Widget build(BuildContext context) {
final cs = ShadTheme.of(context).colorScheme;
return DecoratedBox(
return Container(
padding: const EdgeInsets.symmetric(horizontal: 13, vertical: 9),
decoration: BoxDecoration(
color: cs.card,
border: Border.all(color: cs.border),
borderRadius: BorderRadius.circular(12),
color: Colors.white,
borderRadius: BorderRadius.circular(13),
border: Border.all(color: const Color(0xFFE3D6B4), width: 0.5),
),
child: Row(
children: [
Text(
leading,
style: const TextStyle(fontSize: 14, color: Color(0xFF8A8780)),
),
const SizedBox(width: 8),
Expanded(
child: TextField(
controller: controller,
focusNode: focusNode,
keyboardType: const TextInputType.numberWithOptions(
decimal: true,
),
textAlign: TextAlign.right,
decoration: const InputDecoration(
border: InputBorder.none,
isDense: true,
contentPadding: EdgeInsets.zero,
),
style: const TextStyle(fontSize: 21, fontWeight: FontWeight.w600),
onChanged: onChanged,
),
),
const SizedBox(width: 8),
Text(
unit,
style: const TextStyle(fontSize: 14, color: Color(0xFF8A8780)),
),
],
),
child: Padding(padding: const EdgeInsets.all(16), child: child),
);
}
}
TextStyle _mutedStyle(ShadColorScheme cs) {
return TextStyle(fontSize: 13, color: cs.mutedForeground, letterSpacing: 0);
class _PeriodPill extends StatelessWidget {
const _PeriodPill({
required this.label,
required this.selected,
required this.onTap,
});
final String label;
final bool selected;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
return PrototypePill(label: label, selected: selected, onTap: onTap);
}
}
class _MetalTab extends StatelessWidget {
const _MetalTab({
required this.label,
required this.selected,
required this.onTap,
});
final String label;
final bool selected;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(12),
child: Container(
height: 32,
alignment: Alignment.center,
decoration: BoxDecoration(
color: selected ? const Color(0xFFF6ECD6) : Colors.white,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: selected ? const Color(0xFFE3D6B4) : const Color(0xFFE6E1D8),
width: 0.5,
),
),
child: Text(
label,
style: TextStyle(
fontSize: 13,
fontWeight: selected ? FontWeight.w600 : FontWeight.w500,
color: selected ? const Color(0xFF7A5B12) : const Color(0xFF6E6A60),
),
),
),
);
}
}
class _ChangeChip extends StatelessWidget {
const _ChangeChip({
required this.amount,
required this.percent,
required this.upColor,
required this.downColor,
required this.upBackground,
required this.downBackground,
});
final double amount;
final double percent;
final Color upColor;
final Color downColor;
final Color upBackground;
final Color downBackground;
@override
Widget build(BuildContext context) {
final positive = amount >= 0;
return Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
decoration: BoxDecoration(
color: positive ? upBackground : downBackground,
borderRadius: BorderRadius.circular(999),
),
child: Text(
'${positive ? '' : ''}¥${amount.abs().toStringAsFixed(2)} · ${positive ? '+' : '-'}${percent.abs().toStringAsFixed(2)}%',
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w600,
color: positive ? upColor : downColor,
),
),
);
}
}
Future<void> _showPriceAlertSheet(BuildContext context, MetalType metal) async {
var dir = 'up';
final controller = TextEditingController(text: '960.00');
try {
await showModalBottomSheet<void>(
context: context,
backgroundColor: Colors.white,
isScrollControlled: true,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(22)),
),
builder: (ctx) {
return StatefulBuilder(
builder: (ctx, setState) {
return SafeArea(
child: Padding(
padding: EdgeInsets.only(
bottom: MediaQuery.viewInsetsOf(ctx).bottom,
),
child: Padding(
padding: const EdgeInsets.fromLTRB(20, 8, 20, 24),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Center(
child: Container(
width: 38,
height: 4,
margin: const EdgeInsets.only(bottom: 14),
decoration: BoxDecoration(
color: const Color(0xFFE3DFD4),
borderRadius: BorderRadius.circular(999),
),
),
),
const Text(
'设置到价提醒',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 4),
Text(
'${metal.label} 到价时提醒你',
style: const TextStyle(
fontSize: 12,
color: Color(0xFF8A8780),
),
),
const SizedBox(height: 14),
Row(
children: [
Expanded(
child: GestureDetector(
onTap: () => setState(() => dir = 'up'),
child: Container(
padding: const EdgeInsets.symmetric(
vertical: 10,
),
decoration: BoxDecoration(
color: dir == 'up'
? const Color(0xFFF6ECD6)
: Colors.white,
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: dir == 'up'
? const Color(0xFFE3D6B4)
: const Color(0xFFECEAE3),
width: 0.5,
),
),
child: const Text(
'涨到',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w600,
),
),
),
),
),
const SizedBox(width: 8),
Expanded(
child: GestureDetector(
onTap: () => setState(() => dir = 'down'),
child: Container(
padding: const EdgeInsets.symmetric(
vertical: 10,
),
decoration: BoxDecoration(
color: dir == 'down'
? const Color(0xFFF6ECD6)
: Colors.white,
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: dir == 'down'
? const Color(0xFFE3D6B4)
: const Color(0xFFECEAE3),
width: 0.5,
),
),
child: const Text(
'跌到',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w600,
),
),
),
),
),
],
),
const SizedBox(height: 14),
Container(
padding: const EdgeInsets.symmetric(
horizontal: 13,
vertical: 10,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(13),
border: Border.all(
color: const Color(0xFFE3D6B4),
width: 0.5,
),
),
child: Row(
children: [
const Text(
'¥',
style: TextStyle(
fontSize: 14,
color: Color(0xFF8A8780),
),
),
const SizedBox(width: 8),
Expanded(
child: TextField(
controller: controller,
keyboardType:
const TextInputType.numberWithOptions(
decimal: true,
),
textAlign: TextAlign.right,
decoration: const InputDecoration(
border: InputBorder.none,
isDense: true,
),
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.w600,
),
),
),
const SizedBox(width: 8),
const Text(
'元/克',
style: TextStyle(
fontSize: 13,
color: Color(0xFF8A8780),
),
),
],
),
),
const SizedBox(height: 16),
FilledButton(
onPressed: () {
Navigator.of(ctx).pop();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
'已设到价提醒 · $metal ${dir == 'up' ? '涨到' : '跌到'} ¥${controller.text}',
),
),
);
},
child: const Text('完成'),
),
],
),
),
),
);
},
);
},
);
} finally {
controller.dispose();
}
}
String _timeLabel(DateTime value) {
return '${value.hour.toString().padLeft(2, '0')}:${value.minute.toString().padLeft(2, '0')}';
}
@@ -8,10 +8,17 @@ final newsControllerProvider = StateNotifierProvider<NewsController, NewsState>(
);
class NewsState {
const NewsState({required this.items, required this.refreshedAt});
const NewsState({
required this.items,
required this.refreshedAt,
required this.hasMore,
required this.loadingMore,
});
final List<NewsItem> items;
final DateTime refreshedAt;
final bool hasMore;
final bool loadingMore;
}
class NewsController extends StateNotifier<NewsState> {
@@ -20,15 +27,42 @@ class NewsController extends StateNotifier<NewsState> {
NewsState(
items: _repository.loadFeed(),
refreshedAt: DateTime(2026, 6, 18, 16, 11),
hasMore: true,
loadingMore: false,
),
);
final MockNewsRepository _repository;
static const _pageSize = 3;
void refresh() {
final items = _repository.loadFeed(limit: _pageSize);
state = NewsState(
items: _repository.loadFeed(),
items: items,
refreshedAt: DateTime.now(),
hasMore: items.length == _pageSize,
loadingMore: false,
);
}
bool loadMore() {
if (state.loadingMore || !state.hasMore) return state.hasMore;
state = NewsState(
items: state.items,
refreshedAt: state.refreshedAt,
hasMore: state.hasMore,
loadingMore: true,
);
final next = _repository.loadFeed(
offset: state.items.length,
limit: _pageSize,
);
state = NewsState(
items: [...state.items, ...next],
refreshedAt: state.refreshedAt,
hasMore: next.length == _pageSize,
loadingMore: false,
);
return state.hasMore;
}
}
@@ -8,7 +8,7 @@ final mockNewsRepositoryProvider = Provider<MockNewsRepository>(
);
class MockNewsRepository {
List<NewsItem> loadFeed() {
List<NewsItem> loadFeed({int offset = 0, int limit = 3}) {
final base = DateTime(2026, 6, 18, 16, 11);
final items = [
NewsItem(
@@ -23,6 +23,18 @@ class MockNewsRepository {
'对持有者而言,材料价值更适合用于日常估值;对购买者而言,需要额外关注工费、品牌溢价与回收折扣。',
],
),
NewsItem(
id: 'news_gold_002',
metal: MetalType.gold,
title: '金饰零售端促销频繁,注意工费与克重拆分',
source: '门店观察',
publishedAt: base.subtract(const Duration(hours: 3, minutes: 12)),
summary: '促销券常常只影响零售支付价,材料价值并不会同步下降。',
body: const [
'金饰零售端的活动更偏向工费减免、赠品或满减,对材料价值本身没有直接影响。',
'记录资产时建议保留克重、纯度、成本和购买渠道,便于后续估值对照。',
],
),
NewsItem(
id: 'news_silver_001',
metal: MetalType.silver,
@@ -35,6 +47,18 @@ class MockNewsRepository {
'银饰通常包含较高加工与零售成本,材料价值占比可能低于用户直觉。',
],
),
NewsItem(
id: 'news_silver_002',
metal: MetalType.silver,
title: '白银工艺件价格波动更敏感,建议看实时材料价',
source: '市场简报',
publishedAt: base.subtract(const Duration(hours: 4, minutes: 8)),
summary: '白银饰品受工费和零售渠道影响更大,短线估值容易偏离材料价值。',
body: const [
'白银工艺件的零售价常常受加工复杂度影响,和材料价值的差异更明显。',
'如果只看零售价很容易高估持仓,记录时建议同时看克重和纯度。',
],
),
NewsItem(
id: 'news_platinum_001',
metal: MetalType.platinum,
@@ -47,7 +71,21 @@ class MockNewsRepository {
'记录持仓时建议保留纯度、克重、购买渠道和成本信息,便于后续估值与盈亏回看。',
],
),
NewsItem(
id: 'news_platinum_002',
metal: MetalType.platinum,
title: '铂金回收询价分层明显,渠道差异值得记录',
source: '金属观察',
publishedAt: base.subtract(const Duration(hours: 5, minutes: 16)),
summary: '不同渠道对 PT950 的检测和报价方式并不一样,保存渠道信息很重要。',
body: const [
'铂金回收通常会区分门店、品牌和回收市场,检测流程与报价节奏都有差异。',
'把渠道信息留在资产记录里,后面回看更容易对上真实回收路径。',
],
),
];
return [...items]..sort((a, b) => b.publishedAt.compareTo(a.publishedAt));
final sorted = [...items]
..sort((a, b) => b.publishedAt.compareTo(a.publishedAt));
return sorted.skip(offset).take(limit).toList(growable: false);
}
}
@@ -0,0 +1,148 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import '../../../common/config/app_h5_urls.dart';
import '../../../common/util/share_util.dart';
import '../../../common/widgets/app_toast.dart';
import '../../../common/widgets/prototype_ui.dart';
import '../application/news_controller.dart';
class NewsDetailPage extends ConsumerWidget {
const NewsDetailPage({super.key, this.id});
final String? id;
@override
Widget build(BuildContext context, WidgetRef ref) {
final news = ref.watch(newsControllerProvider).items;
final item = news.firstWhere(
(item) => id == null || item.id == id,
orElse: () => news.first,
);
final cs = ShadTheme.of(context).colorScheme;
return Scaffold(
backgroundColor: const Color(0xFFFBFAF7),
appBar: AppBar(
backgroundColor: const Color(0xFFFBFAF7),
surfaceTintColor: Colors.transparent,
elevation: 0,
scrolledUnderElevation: 0,
centerTitle: true,
leading: IconButton(
onPressed: () => Navigator.of(context).pop(),
icon: const Icon(Icons.chevron_left, size: 20),
),
title: Text(
item.metal.label,
style: const TextStyle(fontSize: 17, fontWeight: FontWeight.w600),
),
actions: [
Builder(
builder: (buttonContext) => IconButton(
onPressed: () async {
final shareText = [
item.title,
'${item.source} · ${_timeLabel(item.publishedAt)} · ${item.metal.label}',
item.summary,
'打开金值查看:${AppH5Urls.baseUrl}/news/detail?id=${item.id}',
].join('\n');
try {
await sharePlainText(
text: shareText,
subject: item.title,
sharePositionOrigin: shareOriginForContext(buttonContext),
);
} catch (e) {
debugPrint('share news failed: $e');
if (!context.mounted) return;
await toastInfo(msg: '分享失败');
}
},
icon: const Icon(Icons.ios_share_outlined, size: 20),
color: const Color(0xFF8A8780),
),
),
],
),
body: SafeArea(
child: ListView(
padding: const EdgeInsets.fromLTRB(0, 8, 0, 24),
children: [
PrototypeFrame(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SizedBox(height: 4),
PrototypeCard(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Container(
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 3,
),
decoration: BoxDecoration(
color: item.metal.color.withValues(alpha: 0.12),
borderRadius: BorderRadius.circular(999),
),
child: Text(
item.metal.label,
style: TextStyle(
color: item.metal.color,
fontWeight: FontWeight.w700,
fontSize: 12,
),
),
),
const SizedBox(width: 8),
Text(
'${item.source} · ${_timeLabel(item.publishedAt)}',
style: TextStyle(
fontSize: 12,
color: cs.mutedForeground,
),
),
],
),
const SizedBox(height: 12),
Text(
item.title,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.w700,
height: 1.4,
),
),
const SizedBox(height: 12),
for (final paragraph in item.body) ...[
Text(
paragraph,
style: TextStyle(
fontSize: 15,
height: 1.7,
color: cs.foreground,
),
),
const SizedBox(height: 12),
],
],
),
),
],
),
),
],
),
),
);
}
}
String _timeLabel(DateTime value) {
return '${value.hour.toString().padLeft(2, '0')}:${value.minute.toString().padLeft(2, '0')}';
}
+131 -84
View File
@@ -1,122 +1,169 @@
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import '../../../common/widgets/adaptive.dart';
import '../../../common/router/app_router.dart';
import '../../../common/widgets/prototype_ui.dart';
import '../application/news_controller.dart';
class NewsPage extends ConsumerWidget {
class NewsPage extends HookConsumerWidget {
const NewsPage({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final news = ref.watch(newsControllerProvider);
final notifier = ref.read(newsControllerProvider.notifier);
final cs = ShadTheme.of(context).colorScheme;
final controller = useMemoized(
() => RefreshController(initialRefresh: false),
);
useEffect(() {
return controller.dispose;
}, [controller]);
return SafeArea(
top: false,
child: ListView(
padding: const EdgeInsets.fromLTRB(18, 18, 18, 24),
children: [
Center(
child: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: Adaptive.contentMaxWidth,
),
child: SmartRefresher(
controller: controller,
enablePullDown: true,
enablePullUp: true,
header: const MaterialClassicHeader(),
onRefresh: () async {
notifier.refresh();
controller.refreshCompleted();
},
onLoading: () async {
if (!news.hasMore || news.loadingMore) {
controller.loadNoData();
return;
}
final hasMore = notifier.loadMore();
if (hasMore) {
controller.loadComplete();
} else {
controller.loadNoData();
}
},
child: ListView(
physics: const AlwaysScrollableScrollPhysics(),
padding: const EdgeInsets.fromLTRB(0, 8, 0, 20),
children: [
PrototypeFrame(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Row(
children: [
Expanded(
child: Text(
'信息整理 · 非投资建议',
style: TextStyle(
color: cs.mutedForeground,
fontSize: 13,
),
),
),
TextButton(
onPressed: () =>
ref.read(newsControllerProvider.notifier).refresh(),
child: const Text('刷新'),
),
],
const Text(
'资讯',
style: TextStyle(fontSize: 17, fontWeight: FontWeight.w600),
),
const SizedBox(height: 8),
for (final item in news.items)
Padding(
padding: const EdgeInsets.only(bottom: 10),
child: DecoratedBox(
decoration: BoxDecoration(
color: cs.card,
border: Border.all(color: cs.border),
borderRadius: BorderRadius.circular(12),
const SizedBox(height: 10),
for (final item in news.items) ...[
PrototypeCard(
margin: const EdgeInsets.only(bottom: 10),
child: InkWell(
onTap: () => context.push(
'${AppRoutes.newsDetail}?id=${item.id}',
),
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Container(
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 3,
),
decoration: BoxDecoration(
color: item.metal.color.withValues(
alpha: 0.12,
),
borderRadius: BorderRadius.circular(999),
),
child: Text(
item.metal.shortLabel,
style: TextStyle(
color: item.metal.color,
fontWeight: FontWeight.w700,
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Container(
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 3,
),
const SizedBox(width: 8),
Text(
'${item.source} · ${item.publishedAt.hour.toString().padLeft(2, '0')}:${item.publishedAt.minute.toString().padLeft(2, '0')}',
decoration: BoxDecoration(
color: item.metal.color.withValues(
alpha: 0.12,
),
borderRadius: BorderRadius.circular(999),
),
child: Text(
item.metal.shortLabel,
style: TextStyle(
color: cs.mutedForeground,
color: item.metal.color,
fontWeight: FontWeight.w700,
fontSize: 12,
),
),
],
),
const SizedBox(height: 10),
Text(
item.title,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
color: cs.foreground,
),
),
const SizedBox(height: 8),
Text(
item.summary,
style: TextStyle(
const SizedBox(width: 8),
Text(
'${item.source} · ${_timeLabel(item.publishedAt)}',
style: TextStyle(
fontSize: 12,
color: cs.mutedForeground,
),
),
const Spacer(),
Icon(
Icons.chevron_right,
size: 16,
color: cs.mutedForeground,
height: 1.5,
),
],
),
const SizedBox(height: 10),
Text(
item.title,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
),
],
),
),
const SizedBox(height: 8),
Text(
item.summary,
style: TextStyle(
fontSize: 14,
color: cs.mutedForeground,
height: 1.55,
),
),
],
),
),
),
],
if (news.loadingMore)
const Padding(
padding: EdgeInsets.symmetric(vertical: 16),
child: Center(
child: SizedBox(
width: 18,
height: 18,
child: CircularProgressIndicator(strokeWidth: 2),
),
),
),
if (!news.hasMore)
Padding(
padding: const EdgeInsets.symmetric(vertical: 14),
child: Text(
'没有更多资讯了',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
color: cs.mutedForeground,
),
),
),
],
),
),
),
],
],
),
),
);
}
}
String _timeLabel(DateTime value) {
return '${value.hour.toString().padLeft(2, '0')}:${value.minute.toString().padLeft(2, '0')}';
}
@@ -0,0 +1,36 @@
import '../data/profile_models.dart';
class PriceColorPalette {
const PriceColorPalette({
required this.up,
required this.down,
required this.upBackground,
required this.downBackground,
});
final int up;
final int down;
final int upBackground;
final int downBackground;
}
const _redUpGreenDown = PriceColorPalette(
up: 0xFFC0392B,
down: 0xFF2E8B6F,
upBackground: 0xFFFBEDEA,
downBackground: 0xFFE7F2EE,
);
const _greenUpRedDown = PriceColorPalette(
up: 0xFF2E8B6F,
down: 0xFFC0392B,
upBackground: 0xFFE7F2EE,
downBackground: 0xFFFBEDEA,
);
PriceColorPalette priceColorPalette(PriceColorMode mode) {
return switch (mode) {
PriceColorMode.redUpGreenDown => _redUpGreenDown,
PriceColorMode.greenUpRedDown => _greenUpRedDown,
};
}
@@ -40,4 +40,13 @@ class ProfileSettingsController extends StateNotifier<ProfileSettings> {
void setPriceColorMode(PriceColorMode mode) {
state = state.copyWith(priceColorMode: mode);
}
void setRecycleDiscount(MetalType metal, double value) {
state = state.copyWith(
recycleDiscounts: {
...state.recycleDiscounts,
metal: value.clamp(0.7, 1.0),
},
);
}
}
File diff suppressed because it is too large Load Diff
@@ -1,13 +1,18 @@
import 'package:flutter/material.dart';
import 'package:flutter_remix/flutter_remix.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:url_launcher/url_launcher_string.dart';
import '../../../common/config/app_h5_urls.dart';
import '../../../common/router/app_router.dart';
import '../../../common/widgets/adaptive.dart';
import '../../../common/widgets/app_toast.dart';
import '../../../common/widgets/prototype_ui.dart';
import '../../auth/application/auth_controller.dart';
import '../../auth/data/auth_models.dart';
import '../../profile/application/profile_settings_controller.dart';
import '../application/profile_settings_controller.dart';
import '../data/profile_models.dart';
class ProfilePage extends ConsumerWidget {
const ProfilePage({super.key});
@@ -25,161 +30,381 @@ class ProfilePage extends ConsumerWidget {
return SafeArea(
top: false,
child: ListView(
padding: const EdgeInsets.fromLTRB(18, 18, 18, 24),
padding: const EdgeInsets.fromLTRB(0, 8, 0, 20),
children: [
Center(
child: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: Adaptive.contentMaxWidth,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
_Card(
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
currentUser?.nickname ?? '未登录',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w700,
color: cs.foreground,
),
),
const SizedBox(height: 6),
Text(
currentUser?.phone ?? '登录后可使用本地同步、云备份占位和账户管理。',
style: TextStyle(color: cs.mutedForeground),
),
],
),
PrototypeFrame(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Text(
'我的',
style: TextStyle(fontSize: 17, fontWeight: FontWeight.w600),
),
const SizedBox(height: 14),
PrototypeCard(
child: Row(
children: [
Container(
width: 46,
height: 46,
decoration: BoxDecoration(
color: const Color(0xFFF1EFE9),
borderRadius: BorderRadius.circular(999),
),
FilledButton(
onPressed: () => context.push(AppRoutes.settings),
child: const Text('设置'),
child: const Icon(
Icons.person_outline,
color: Color(0xFF9A968D),
),
],
),
),
const SizedBox(height: 12),
_Card(
child: Column(
children: [
_SettingRow(
label: '隐藏金额',
value: settings.amountHidden ? '已隐藏' : '显示中',
trailing: Switch(
value: settings.amountHidden,
onChanged: (_) => ref
.read(
profileSettingsControllerProvider.notifier,
)
.toggleAmountHidden(),
),
),
_SettingRow(
label: '回收折扣',
value:
'${(settings.recycleDiscounts.values.first * 100).toStringAsFixed(0)}%',
),
_SettingRow(
label: '涨跌颜色',
value: settings.priceColorMode.label,
),
_SettingRow(
label: '纯度系数',
value: '${settings.purityPresets.length}',
),
],
),
),
const SizedBox(height: 12),
_Card(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
FilledButton.tonal(
onPressed: loggedIn
? () => context.push(AppRoutes.login)
: () => context.push(AppRoutes.login),
child: Text(loggedIn ? '切换账号' : '去登录'),
),
const SizedBox(height: 10),
OutlinedButton(
onPressed: () => context.push(AppRoutes.settings),
child: const Text('打开设置'),
),
],
),
),
const SizedBox(height: 12),
_Card(
child: Text(
'风险提示 · 数据来源 · 免责\n价格、资讯与估值均为本地 mock 数据,仅用于产品原型验证,不构成投资建议。',
style: TextStyle(
color: cs.mutedForeground,
height: 1.6,
fontSize: 13,
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
currentUser?.nickname ?? '未登录',
style: const TextStyle(
fontSize: 15,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 4),
Text(
currentUser?.phone ?? '登录后可云备份、多端同步',
style: TextStyle(
fontSize: 12,
color: cs.mutedForeground,
),
),
],
),
),
if (!loggedIn)
FilledButton(
onPressed: () => context.push(AppRoutes.login),
style: FilledButton.styleFrom(
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 10,
),
minimumSize: Size.zero,
),
child: Text('登录'),
),
],
),
),
const SizedBox(height: 12),
PrototypeCard(
padding: EdgeInsets.zero,
child: Column(
children: [
_MenuRow(
title: '邀请好友,各得奖励',
subtitle: '需登录',
icon: Icons.card_giftcard_outlined,
onTap: () => _showInviteSheet(context),
),
const PrototypeDivider(margin: EdgeInsets.zero),
_MenuRow(
title: '分享我的贵金属估值卡',
subtitle: '免登录 · 自动打码金额',
icon: Icons.share_outlined,
onTap: () =>
_showShareCardSheet(context, currentUser?.nickname),
),
],
),
),
const SizedBox(height: 12),
// PrototypeCard(
// padding: EdgeInsets.zero,
// child: Column(
// children: [
// SettingRow(
// icon: Icons.download_outlined,
// title: '本地导出备份',
// trailing: '导出',
// onTap: () => _showLocalBackupSheet(context),
// ),
// const PrototypeDivider(margin: EdgeInsets.zero),
// SettingRow(
// icon: Icons.cloud_outlined,
// title: '云备份 · 多端同步',
// trailing: loggedIn ? '已登录' : '登录解锁',
// onTap: () => _showCloudBackupSheet(context, loggedIn),
// ),
// ],
// ),
// ),
// const SizedBox(height: 12),
PrototypeCard(
padding: EdgeInsets.zero,
child: Column(
children: [
SettingRow(
icon: Icons.tune_outlined,
title: '纯度系数管理',
trailing: '${settings.purityPresets.length}',
onTap: () => _showPuritySheet(context, settings),
),
const PrototypeDivider(margin: EdgeInsets.zero),
SettingRow(
icon: Icons.percent_outlined,
title: '回收折扣设置',
trailing:
'${(settings.recycleDiscounts.values.first * 100).toStringAsFixed(0)}%',
onTap: () => _showRecycleSheet(context, settings),
),
const PrototypeDivider(margin: EdgeInsets.zero),
SettingRow(
icon: Icons.palette_outlined,
title: '涨跌颜色',
trailing: settings.priceColorMode.label,
onTap: () {
final nextMode =
settings.priceColorMode ==
PriceColorMode.redUpGreenDown
? PriceColorMode.greenUpRedDown
: PriceColorMode.redUpGreenDown;
ref
.read(profileSettingsControllerProvider.notifier)
.setPriceColorMode(nextMode);
toastInfo(msg: '已切换为「${nextMode.label}');
},
),
const PrototypeDivider(margin: EdgeInsets.zero),
SettingRow(
icon: Icons.currency_yen_outlined,
title: '显示币种',
trailing: '¥ CNY',
onTap: () => toastInfo(msg: '当前仅支持 ¥ CNY'),
),
const PrototypeDivider(margin: EdgeInsets.zero),
SettingRow(
icon: Icons.grid_view_outlined,
title: '添加桌面小组件',
trailing: '占位',
onTap: () => _showWidgetSheet(context),
),
],
),
),
const SizedBox(height: 12),
PrototypeCard(
padding: EdgeInsets.zero,
child: Column(
children: [
SettingRow(
icon: Icons.settings,
title: '设置',
trailing: null,
onTap: () => context.push(AppRoutes.settings),
),
const PrototypeDivider(margin: EdgeInsets.zero),
SettingRow(
icon: FlutterRemix.file_list_3_line,
title: '用户协议',
onTap: () => launchUrlString(
AppH5UrlsHelper.withCacheBuster(
AppH5Urls.userProtocolUrl,
),
mode: LaunchMode.inAppBrowserView,
),
),
const PrototypeDivider(margin: EdgeInsets.zero),
SettingRow(
icon: FlutterRemix.shield_check_line,
title: '隐私政策',
onTap: () => launchUrlString(
AppH5UrlsHelper.withCacheBuster(AppH5Urls.privacyUrl),
mode: LaunchMode.inAppBrowserView,
),
),
const PrototypeDivider(margin: EdgeInsets.zero),
SettingRow(
icon: Icons.info_outline,
title: '免责声明',
trailing: null,
onTap: () => _showDisclaimer(context),
),
// const PrototypeDivider(margin: EdgeInsets.zero),
// SettingRow(
// icon: Icons.feedback_outlined,
// title: '意见反馈 · 关于金值',
// trailing: null,
// onTap: () => _showAbout(context),
// ),
],
),
),
const SizedBox(height: 14),
PrototypeCard(
child: Text(
'风险提示 · 数据来源 · 免责\n金值是贵金属资产记录与估值工具,所有信息不构成投资建议。\n· 行情 / 兑换价格均为参考,标注来源与更新时间,实际以交易系统 / 门店为准。\n· 材料价值 = 克重 × 纯度系数 × 上海金现货,非金店零售价(含工费 / 品牌溢价)、非回收实收价。\n· 资讯为信息整理,非投资建议;历史走势不代表未来。',
style: TextStyle(
color: cs.mutedForeground,
height: 1.7,
fontSize: 12,
),
),
),
],
),
),
],
),
);
}
void _showDisclaimer(BuildContext context) {
context.push(AppRoutes.profileDisclaimer);
}
Future<void> _showInviteSheet(BuildContext context) async {
context.push(AppRoutes.profileInvite);
}
Future<void> _showShareCardSheet(
BuildContext context,
String? nickname,
) async {
context.push(AppRoutes.profileShare);
}
Future<void> _showLocalBackupSheet(BuildContext context) async {
context.push(AppRoutes.profileLocalBackup);
}
Future<void> _showCloudBackupSheet(
BuildContext context,
bool loggedIn,
) async {
context.push(AppRoutes.profileCloudBackup);
}
Future<void> _showWidgetSheet(BuildContext context) async {
context.push(AppRoutes.profileWidget);
}
Future<void> _showPuritySheet(
BuildContext context,
ProfileSettings settings,
) async {
context.push(AppRoutes.profilePurity);
}
Future<void> _showRecycleSheet(
BuildContext context,
ProfileSettings settings,
) async {
context.push(AppRoutes.profileRecycle);
}
void _showAbout(BuildContext context) {
context.push(AppRoutes.profileAbout);
}
}
class _MenuRow extends StatelessWidget {
const _MenuRow({
required this.title,
required this.subtitle,
required this.icon,
required this.onTap,
});
final String title;
final String subtitle;
final IconData icon;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
final cs = ShadTheme.of(context).colorScheme;
return InkWell(
onTap: onTap,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
child: Row(
children: [
Icon(icon, size: 20, color: const Color(0xFF8A8780)),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 4),
Text(
subtitle,
style: TextStyle(fontSize: 12, color: cs.mutedForeground),
),
],
),
),
),
],
Icon(Icons.chevron_right, size: 16, color: cs.mutedForeground),
],
),
),
);
}
}
class _SettingRow extends StatelessWidget {
const _SettingRow({required this.label, required this.value, this.trailing});
class SettingRow extends StatelessWidget {
const SettingRow({
required this.icon,
required this.title,
required this.onTap,
this.trailing,
this.destructive = false,
});
final String label;
final String value;
final Widget? trailing;
final IconData icon;
final String title;
final String? trailing;
final VoidCallback onTap;
final bool destructive;
@override
Widget build(BuildContext context) {
final cs = ShadTheme.of(context).colorScheme;
return Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: Row(
children: [
Expanded(
child: Text(
label,
style: TextStyle(fontSize: 15, color: cs.foreground),
final color = destructive ? cs.destructive : cs.foreground;
return InkWell(
onTap: onTap,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
child: Row(
children: [
Icon(icon, size: 20, color: const Color(0xFF8A8780)),
const SizedBox(width: 12),
Expanded(
child: Text(
title,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: color,
),
),
),
),
Text(value, style: TextStyle(color: cs.mutedForeground)),
if (trailing != null) ...[const SizedBox(width: 8), trailing!],
],
if (trailing != null)
Text(
trailing!,
style: TextStyle(fontSize: 12, color: cs.mutedForeground),
),
const SizedBox(width: 6),
Icon(Icons.chevron_right, size: 16, color: cs.mutedForeground),
],
),
),
);
}
}
class _Card extends StatelessWidget {
const _Card({required this.child});
final Widget child;
@override
Widget build(BuildContext context) {
final cs = ShadTheme.of(context).colorScheme;
return DecoratedBox(
decoration: BoxDecoration(
color: cs.card,
border: Border.all(color: cs.border),
borderRadius: BorderRadius.circular(12),
),
child: Padding(padding: const EdgeInsets.all(16), child: child),
);
}
}
@@ -119,7 +119,7 @@ class _PrivacyConsentPageState extends State<PrivacyConsentPage> {
const _LaunchMark(size: 88),
const SizedBox(height: 26),
Text(
'研听',
'金值',
style: TextStyle(
fontSize: 42,
fontWeight: FontWeight.w800,
@@ -308,7 +308,7 @@ class _PrivacyConsentSheetState extends State<_PrivacyConsentSheet> {
children: [
_grip(cs),
Text(
'欢迎使用研听',
'欢迎使用金值',
style: TextStyle(
fontSize: 19,
fontWeight: FontWeight.w700,
File diff suppressed because it is too large Load Diff
+316 -4
View File
@@ -215,6 +215,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.1.2"
cross_file:
dependency: transitive
description:
name: cross_file
sha256: "28bb3ae56f117b5aec029d702a90f57d285cd975c3c5c281eaca38dbc47c5937"
url: "https://pub.dev"
source: hosted
version: "0.3.5+2"
crypto:
dependency: transitive
description:
@@ -359,6 +367,38 @@ packages:
url: "https://pub.dev"
source: hosted
version: "7.0.1"
file_selector_linux:
dependency: transitive
description:
name: file_selector_linux
sha256: "2567f398e06ac72dcf2e98a0c95df2a9edd03c2c2e0cacd4780f20cdf56263a0"
url: "https://pub.dev"
source: hosted
version: "0.9.4"
file_selector_macos:
dependency: transitive
description:
name: file_selector_macos
sha256: "5e0bbe9c312416f1787a68259ea1505b52f258c587f12920422671807c4d618a"
url: "https://pub.dev"
source: hosted
version: "0.9.5"
file_selector_platform_interface:
dependency: transitive
description:
name: file_selector_platform_interface
sha256: "35e0bd61ebcdb91a3505813b055b09b79dfdc7d0aee9c09a7ba59ae4bb13dc85"
url: "https://pub.dev"
source: hosted
version: "2.7.0"
file_selector_windows:
dependency: transitive
description:
name: file_selector_windows
sha256: "62197474ae75893a62df75939c777763d39c2bc5f73ce5b88497208bc269abfd"
url: "https://pub.dev"
source: hosted
version: "0.9.3+5"
fixnum:
dependency: "direct main"
description:
@@ -380,6 +420,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.5.2"
flutter_cache_manager:
dependency: "direct main"
description:
name: flutter_cache_manager
sha256: "400b6592f16a4409a7f2bb929a9a7e38c72cceb8ffb99ee57bbf2cb2cecf8386"
url: "https://pub.dev"
source: hosted
version: "3.4.1"
flutter_dotenv:
dependency: "direct main"
description:
@@ -440,6 +488,14 @@ packages:
relative: true
source: path
version: "0.0.1"
flutter_plugin_android_lifecycle:
dependency: transitive
description:
name: flutter_plugin_android_lifecycle
sha256: "38d1c268de9097ff59cf0e844ac38759fc78f76836d37edad06fa21e182055a0"
url: "https://pub.dev"
source: hosted
version: "2.0.34"
flutter_remix:
dependency: "direct main"
description:
@@ -554,6 +610,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.0.0"
gal:
dependency: "direct main"
description:
name: gal
sha256: "969598f986789127fd407a750413249e1352116d4c2be66e81837ffeeaafdfee"
url: "https://pub.dev"
source: hosted
version: "2.3.2"
glob:
dependency: transitive
description:
@@ -658,6 +722,70 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.8.0"
image_picker:
dependency: "direct main"
description:
name: image_picker
sha256: "91c025426c2881c551100bce834e201c835a170151545f58d17da5180ca7d9ac"
url: "https://pub.dev"
source: hosted
version: "1.2.2"
image_picker_android:
dependency: transitive
description:
name: image_picker_android
sha256: d5b3e1774af29c9ab00103afb0d4614070f924d2e0057ac867ec98800114793f
url: "https://pub.dev"
source: hosted
version: "0.8.13+17"
image_picker_for_web:
dependency: transitive
description:
name: image_picker_for_web
sha256: "66257a3191ab360d23a55c8241c91a6e329d31e94efa7be9cf7a212e65850214"
url: "https://pub.dev"
source: hosted
version: "3.1.1"
image_picker_ios:
dependency: transitive
description:
name: image_picker_ios
sha256: "956c16a42c0c708f914021666ffcd8265dde36e673c9fa68c81f7d085d9774ad"
url: "https://pub.dev"
source: hosted
version: "0.8.13+3"
image_picker_linux:
dependency: transitive
description:
name: image_picker_linux
sha256: "1f81c5f2046b9ab724f85523e4af65be1d47b038160a8c8deed909762c308ed4"
url: "https://pub.dev"
source: hosted
version: "0.2.2"
image_picker_macos:
dependency: transitive
description:
name: image_picker_macos
sha256: "86f0f15a309de7e1a552c12df9ce5b59fe927e71385329355aec4776c6a8ec91"
url: "https://pub.dev"
source: hosted
version: "0.2.2+1"
image_picker_platform_interface:
dependency: transitive
description:
name: image_picker_platform_interface
sha256: "567e056716333a1647c64bb6bd873cff7622233a5c3f694be28a583d4715690c"
url: "https://pub.dev"
source: hosted
version: "2.11.1"
image_picker_windows:
dependency: transitive
description:
name: image_picker_windows
sha256: d248c86554a72b5495a31c56f060cf73a41c7ff541689327b1a7dbccc33adfae
url: "https://pub.dev"
source: hosted
version: "0.2.2"
intl:
dependency: transitive
description:
@@ -802,6 +930,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.0"
nested:
dependency: transitive
description:
name: nested
sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20"
url: "https://pub.dev"
source: hosted
version: "1.0.0"
package_config:
dependency: transitive
description:
@@ -843,7 +979,7 @@ packages:
source: hosted
version: "1.1.0"
path_provider:
dependency: transitive
dependency: "direct main"
description:
name: path_provider
sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd"
@@ -890,6 +1026,54 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.3.0"
permission_handler:
dependency: "direct main"
description:
name: permission_handler
sha256: "59adad729136f01ea9e35a48f5d1395e25cba6cea552249ddbe9cf950f5d7849"
url: "https://pub.dev"
source: hosted
version: "11.4.0"
permission_handler_android:
dependency: transitive
description:
name: permission_handler_android
sha256: d3971dcdd76182a0c198c096b5db2f0884b0d4196723d21a866fc4cdea057ebc
url: "https://pub.dev"
source: hosted
version: "12.1.0"
permission_handler_apple:
dependency: transitive
description:
name: permission_handler_apple
sha256: "79dfa1df734798aa3cfdad166d3a3698c206d8813de13516ea1071b5d7e2f420"
url: "https://pub.dev"
source: hosted
version: "9.4.10"
permission_handler_html:
dependency: transitive
description:
name: permission_handler_html
sha256: "38f000e83355abb3392140f6bc3030660cfaef189e1f87824facb76300b4ff24"
url: "https://pub.dev"
source: hosted
version: "0.1.3+5"
permission_handler_platform_interface:
dependency: transitive
description:
name: permission_handler_platform_interface
sha256: eb99b295153abce5d683cac8c02e22faab63e50679b937fa1bf67d58bb282878
url: "https://pub.dev"
source: hosted
version: "4.3.0"
permission_handler_windows:
dependency: transitive
description:
name: permission_handler_windows
sha256: "1a790728016f79a41216d88672dbc5df30e686e811ad4e698bfc51f76ad91f1e"
url: "https://pub.dev"
source: hosted
version: "0.2.1"
petitparser:
dependency: transitive
description:
@@ -898,6 +1082,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "7.0.2"
photo_manager:
dependency: transitive
description:
name: photo_manager
sha256: fb3bc8ea653370f88742b3baa304700107c83d12748aa58b2b9f2ed3ef15e6c2
url: "https://pub.dev"
source: hosted
version: "3.9.0"
photo_manager_image_provider:
dependency: transitive
description:
name: photo_manager_image_provider
sha256: b6015b67b32f345f57cf32c126f871bced2501236c405aafaefa885f7c821e4f
url: "https://pub.dev"
source: hosted
version: "2.2.0"
photo_view:
dependency: "direct main"
description:
name: photo_view
sha256: "1fc3d970a91295fbd1364296575f854c9863f225505c28c46e0a03e48960c75e"
url: "https://pub.dev"
source: hosted
version: "0.15.0"
platform:
dependency: transitive
description:
@@ -910,9 +1118,9 @@ packages:
dependency: "direct main"
description:
path: "."
ref: f381964
resolved-ref: f3819645c70c02b878c754a61ef9ebd3421f2127
url: "https://github.com/maoios/platform_metadata.git"
ref: main
resolved-ref: bbe1aa0213d3f310f35be59829380ecf01fe9e96
url: "https://gitea.neuronlabs.art/zhouyu/platform_metadata.git"
source: git
version: "0.0.2+2"
plugin_platform_interface:
@@ -947,6 +1155,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.2.0"
provider:
dependency: transitive
description:
name: provider
sha256: "4e82183fa20e5ca25703ead7e05de9e4cceed1fbd1eadc1ac3cb6f565a09f272"
url: "https://pub.dev"
source: hosted
version: "6.1.5+1"
pub_semver:
dependency: transitive
description:
@@ -963,6 +1179,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.5.0"
pull_to_refresh:
dependency: "direct main"
description:
name: pull_to_refresh
sha256: bbadd5a931837b57739cf08736bea63167e284e71fb23b218c8c9a6e042aad12
url: "https://pub.dev"
source: hosted
version: "2.0.0"
retrofit:
dependency: "direct main"
description:
@@ -1043,6 +1267,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.53.6"
share_plus:
dependency: "direct main"
description:
name: share_plus
sha256: "223873d106614442ea6f20db5a038685cc5b32a2fba81cdecaefbbae0523f7fa"
url: "https://pub.dev"
source: hosted
version: "12.0.2"
share_plus_platform_interface:
dependency: transitive
description:
name: share_plus_platform_interface
sha256: "88023e53a13429bd65d8e85e11a9b484f49d4c190abbd96c7932b74d6927cc9a"
url: "https://pub.dev"
source: hosted
version: "6.1.0"
shared_preferences:
dependency: "direct main"
description:
@@ -1168,6 +1408,46 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.10.2"
sqflite:
dependency: transitive
description:
name: sqflite
sha256: e2297b1da52f127bc7a3da11439985d9b536f75070f3325e62ada69a5c585d03
url: "https://pub.dev"
source: hosted
version: "2.4.2"
sqflite_android:
dependency: transitive
description:
name: sqflite_android
sha256: ecd684501ebc2ae9a83536e8b15731642b9570dc8623e0073d227d0ee2bfea88
url: "https://pub.dev"
source: hosted
version: "2.4.2+2"
sqflite_common:
dependency: transitive
description:
name: sqflite_common
sha256: "6ef422a4525ecc601db6c0a2233ff448c731307906e92cabc9ba292afaae16a6"
url: "https://pub.dev"
source: hosted
version: "2.5.6"
sqflite_darwin:
dependency: transitive
description:
name: sqflite_darwin
sha256: "279832e5cde3fe99e8571879498c9211f3ca6391b0d818df4e17d9fff5c6ccb3"
url: "https://pub.dev"
source: hosted
version: "2.4.2"
sqflite_platform_interface:
dependency: transitive
description:
name: sqflite_platform_interface
sha256: "8dd4515c7bdcae0a785b0062859336de775e8c65db81ae33dd5445f35be61920"
url: "https://pub.dev"
source: hosted
version: "2.4.0"
stack_trace:
dependency: transitive
description:
@@ -1208,6 +1488,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.4.1"
synchronized:
dependency: transitive
description:
name: synchronized
sha256: c254ade258ec8282947a0acbbc90b9575b4f19673533ee46f2f6e9b3aeefd7c0
url: "https://pub.dev"
source: hosted
version: "3.4.0"
term_glyph:
dependency: transitive
description:
@@ -1416,6 +1704,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.4.0"
visibility_detector:
dependency: transitive
description:
name: visibility_detector
sha256: dd5cc11e13494f432d15939c3aa8ae76844c42b723398643ce9addb88a5ed420
url: "https://pub.dev"
source: hosted
version: "0.4.0+2"
vm_service:
dependency: transitive
description:
@@ -1456,6 +1752,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.0.3"
wechat_assets_picker:
dependency: "direct main"
description:
name: wechat_assets_picker
sha256: e2e447c12a6254e523b83415deb0b77953a96eafcb4586901b7d93039d2ca9d6
url: "https://pub.dev"
source: hosted
version: "10.1.2"
wechat_picker_library:
dependency: transitive
description:
name: wechat_picker_library
sha256: "5cb61b9aa935b60da5b043f8446fbb9c5077419f20ccc4856bf444aec4f44bc1"
url: "https://pub.dev"
source: hosted
version: "1.0.7"
win32:
dependency: transitive
description:
+12 -5
View File
@@ -34,11 +34,20 @@ dependencies:
shadcn_ui: ^0.53.6
google_fonts: ^6.2.1
flutter_remix: ^0.0.3
pull_to_refresh: ^2.0.0
shimmer: ^3.0.0
flutter_markdown_plus: ^1.0.7
video_player: ^2.9.2 # 启动页视频背景
# 工具
url_launcher: ^6.3.1
gal: ^2.3.2
image_picker: ^1.1.2
share_plus: ^12.0.1
wechat_assets_picker: ^10.1.2
flutter_cache_manager: ^3.4.1
photo_view: ^0.15.0
path_provider: ^2.1.5
permission_handler: ^11.3.1
fancy_dio_inspector: ^2.0.1
cupertino_icons: ^1.0.8
android_id:
@@ -49,11 +58,9 @@ dependencies:
path: packages/flutter_paid
platform_metadata:
git:
# 待合并git的请求
# url: https://github.com/zhouyuzhouyu/platform_metadata.git
# ref: 3e3b6f5
url: https://github.com/maoios/platform_metadata.git
ref: f381964
# gitea 内网镜像 — server (yanzhi-api-01) 直连 github 走不通,改走内网。
url: https://gitea.neuronlabs.art/zhouyu/platform_metadata.git
ref: main
flutter_dotenv: ^6.0.1
fluttertoast: ^9.0.0
+1 -1
View File
@@ -5,7 +5,7 @@
# BASE_HREF base href(默认 /flutter/
set -euo pipefail
API_BASE_URL="${API_BASE_URL:-https://jinzhi.api.local}"
API_BASE_URL="${API_BASE_URL:-https://jinzhi.api.yqzhice.top}"
BASE_HREF="${BASE_HREF:-/flutter/}"
echo "▶ flutter pub get"