refactor(client): SubScaffold 六合一(视觉零变化)+ tablet 注释订正 + 平板通知铃入口(#20)
This commit is contained in:
@@ -20,39 +20,7 @@ import '../services/auth_api.dart';
|
||||
import '../state/account_providers.dart';
|
||||
import 'pangolin_button.dart';
|
||||
import 'pangolin_icons.dart';
|
||||
|
||||
/// 通用:带返回箭头的子页骨架。embedded=true 时只返回内容(desktop 内容区下钻,
|
||||
/// 返回/标题由外层 shell 顶栏提供),否则整页 Scaffold(mobile/tablet 全屏 push)。
|
||||
class _SubScaffold extends StatelessWidget {
|
||||
const _SubScaffold({required this.title, required this.child, this.onBack, this.embedded = false});
|
||||
final String title;
|
||||
final Widget child;
|
||||
final VoidCallback? onBack;
|
||||
final bool embedded;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final c = context.pangolin;
|
||||
if (embedded) return child;
|
||||
return Scaffold(
|
||||
backgroundColor: c.bg,
|
||||
body: SafeArea(
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(8, 6, 16, 10),
|
||||
child: Row(children: [
|
||||
IconButton(
|
||||
onPressed: onBack ?? () => Navigator.of(context).maybePop(),
|
||||
icon: Icon(PangolinIcons.arrowLeft, size: 22, color: c.fg1),
|
||||
),
|
||||
Text(title, style: PangolinText.h3.copyWith(color: c.fg1, fontWeight: FontWeight.w700)),
|
||||
]),
|
||||
),
|
||||
Expanded(child: child),
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
import 'sub_scaffold.dart';
|
||||
|
||||
/// ── 设置(移动端从「我的」下钻)── 复用桌面 SettingsPage 内容,套移动返回栏。
|
||||
class SettingsScreen extends StatelessWidget {
|
||||
@@ -62,7 +30,7 @@ class SettingsScreen extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return _SubScaffold(title: t.settingsTitle, onBack: onBack, child: const SettingsPage());
|
||||
return SubScaffold(title: t.settingsTitle, onBack: onBack, child: const SettingsPage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +81,7 @@ class DevicesScreen extends ConsumerWidget {
|
||||
]),
|
||||
);
|
||||
|
||||
return _SubScaffold(
|
||||
return SubScaffold(
|
||||
title: t.myDevices, onBack: onBack, embedded: embedded, child: _DevicesAutoRefresh(child: content()));
|
||||
}
|
||||
|
||||
@@ -314,7 +282,7 @@ class _RedeemScreenState extends ConsumerState<RedeemScreen> {
|
||||
Widget build(BuildContext context) {
|
||||
final c = context.pangolin;
|
||||
final t = widget.t;
|
||||
return _SubScaffold(
|
||||
return SubScaffold(
|
||||
title: t.redeemTitle,
|
||||
onBack: widget.onBack,
|
||||
embedded: widget.embedded,
|
||||
@@ -379,7 +347,7 @@ class ContactScreen extends StatelessWidget {
|
||||
accent: ch.accent,
|
||||
))
|
||||
.toList();
|
||||
return _SubScaffold(
|
||||
return SubScaffold(
|
||||
title: t.contactTitle,
|
||||
onBack: onBack,
|
||||
child: ListView(padding: const EdgeInsets.fromLTRB(20, 4, 20, 24), children: [
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
// sub_scaffold.dart — 通用「返回箭头 + 标题」子页脚手架(六处收敛,视觉零变化)。
|
||||
//
|
||||
// 收敛自 account_screens.dart/orders_page.dart 的私有 `_SubScaffold`,以及
|
||||
// purchase_page.dart/payment_page.dart/invite_page.dart/notifications_page.dart
|
||||
// 里结构相同的内联等价实现。逐像素沿用原实现(同 padding/字号/图标),纯收敛非重设计。
|
||||
//
|
||||
// embedded=true 时只返回内容(desktop 内容区下钻,返回/标题由外层 shell 顶栏提供);
|
||||
// 否则整页 Scaffold + SafeArea + 返回箭头行(mobile/tablet 全屏 push)。
|
||||
// wrapPageBody=true 时由本组件把 child 套进 PageBody(桌面内容页统一宽度容器);默认
|
||||
// false——调用方若已自行用 PageBody 包裹 child(如购买页需要 wide 变体),避免重复包裹。
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../pangolin_theme.dart';
|
||||
import 'page_body.dart';
|
||||
import 'pangolin_icons.dart';
|
||||
|
||||
class SubScaffold extends StatelessWidget {
|
||||
const SubScaffold({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.child,
|
||||
this.onBack,
|
||||
this.embedded = false,
|
||||
this.wrapPageBody = false,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final Widget child;
|
||||
final VoidCallback? onBack;
|
||||
final bool embedded;
|
||||
final bool wrapPageBody;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final c = context.pangolin;
|
||||
final body = wrapPageBody ? PageBody(child: child) : child;
|
||||
if (embedded) return body;
|
||||
return Scaffold(
|
||||
backgroundColor: c.bg,
|
||||
body: SafeArea(
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(8, 6, 16, 10),
|
||||
child: Row(children: [
|
||||
IconButton(
|
||||
onPressed: onBack ?? () => Navigator.of(context).maybePop(),
|
||||
icon: Icon(PangolinIcons.arrowLeft, size: 22, color: c.fg1),
|
||||
),
|
||||
Text(title, style: PangolinText.h3.copyWith(color: c.fg1, fontWeight: FontWeight.w700)),
|
||||
]),
|
||||
),
|
||||
Expanded(child: body),
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user