| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810 |
- import 'package:flutter/material.dart';
- import 'package:skeletonizer/skeletonizer.dart';
- import '../../core/theme/app_colors_extension.dart';
- /// 骨架占位卡片容器(列表加载态)
- class SkeletonLoadingList extends StatelessWidget {
- final int cardCount;
- final Widget Function() cardBuilder;
- final EdgeInsetsGeometry padding;
- const SkeletonLoadingList({
- super.key,
- this.cardCount = 5,
- this.cardBuilder = _defaultBuilder,
- this.padding = const EdgeInsets.fromLTRB(16, 16, 16, 24),
- });
- static Widget _defaultBuilder() => const SkeletonListCard();
- @override
- Widget build(BuildContext context) {
- return SingleChildScrollView(
- padding: padding,
- child: Skeletonizer(
- enabled: true,
- child: Column(
- children: List.generate(
- cardCount,
- (_) => Padding(
- padding: const EdgeInsets.only(bottom: 16),
- child: cardBuilder(),
- ),
- ),
- ),
- ),
- );
- }
- }
- /// 匹配 ListCard 的骨架占位
- class SkeletonListCard extends StatelessWidget {
- const SkeletonListCard({super.key});
- @override
- Widget build(BuildContext context) {
- final colors = Theme.of(context).extension<AppColorsExtension>()!;
- return Skeletonizer(
- enabled: true,
- child: Container(
- padding: const EdgeInsets.all(12),
- decoration: BoxDecoration(
- color: colors.bgCard,
- borderRadius: BorderRadius.circular(8),
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [Bone.text(width: 120), Bone.text(width: 80)],
- ),
- SizedBox(height: 6),
- Bone.text(width: 140),
- SizedBox(height: 6),
- Bone.text(),
- SizedBox(height: 8),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Bone.text(width: 100),
- Bone(
- width: 48,
- height: 20,
- borderRadius: BorderRadius.circular(4),
- ),
- ],
- ),
- ],
- ),
- ),
- );
- }
- }
- /// 匹配车辆列表卡片的骨架占位
- class SkeletonVehicleCard extends StatelessWidget {
- const SkeletonVehicleCard({super.key});
- @override
- Widget build(BuildContext context) {
- final colors = Theme.of(context).extension<AppColorsExtension>()!;
- return Skeletonizer(
- enabled: true,
- child: Container(
- padding: const EdgeInsets.all(12),
- decoration: BoxDecoration(
- color: colors.bgCard,
- borderRadius: BorderRadius.circular(8),
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Bone.text(width: 100),
- Bone(
- width: 48,
- height: 20,
- borderRadius: BorderRadius.circular(4),
- ),
- ],
- ),
- SizedBox(height: 6),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Bone.text(width: 140),
- Bone(
- width: 40,
- height: 16,
- borderRadius: BorderRadius.circular(4),
- ),
- ],
- ),
- SizedBox(height: 6),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Expanded(child: Bone.text()),
- const SizedBox(width: 8),
- Bone.text(width: 120),
- ],
- ),
- ],
- ),
- ),
- );
- }
- }
- /// 匹配外勤日志卡片的骨架占位
- class SkeletonOutingLogCard extends StatelessWidget {
- const SkeletonOutingLogCard({super.key});
- @override
- Widget build(BuildContext context) {
- final colors = Theme.of(context).extension<AppColorsExtension>()!;
- return Skeletonizer(
- enabled: true,
- child: Container(
- padding: const EdgeInsets.all(12),
- decoration: BoxDecoration(
- color: colors.bgCard,
- borderRadius: BorderRadius.circular(8),
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Bone.text(width: 100),
- SizedBox(height: 4),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Expanded(flex: 3, child: Bone.text()),
- const SizedBox(width: 8),
- Bone(
- width: 48,
- height: 20,
- borderRadius: BorderRadius.circular(4),
- ),
- ],
- ),
- SizedBox(height: 4),
- Bone.text(),
- SizedBox(height: 4),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Expanded(flex: 2, child: Bone.text()),
- const SizedBox(width: 8),
- Bone.text(width: 80),
- ],
- ),
- ],
- ),
- ),
- );
- }
- }
- /// 匹配公告卡片的骨架占位
- class SkeletonAnnouncementCard extends StatelessWidget {
- const SkeletonAnnouncementCard({super.key});
- @override
- Widget build(BuildContext context) {
- final colors = Theme.of(context).extension<AppColorsExtension>()!;
- return Skeletonizer(
- enabled: true,
- child: Container(
- padding: const EdgeInsets.all(12),
- decoration: BoxDecoration(
- color: colors.bgCard,
- borderRadius: BorderRadius.circular(8),
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Bone.text(),
- SizedBox(height: 8),
- Row(
- children: [
- Bone(
- width: 56,
- height: 20,
- borderRadius: BorderRadius.circular(4),
- ),
- const SizedBox(width: 8),
- Bone.text(width: 60),
- const Spacer(),
- Bone.text(width: 120),
- ],
- ),
- ],
- ),
- ),
- );
- }
- }
- /// 匹配费用申请导入列表卡片的骨架占位
- class SkeletonImportCard extends StatelessWidget {
- const SkeletonImportCard({super.key});
- @override
- Widget build(BuildContext context) {
- final colors = Theme.of(context).extension<AppColorsExtension>()!;
- return Skeletonizer(
- enabled: true,
- child: Container(
- padding: const EdgeInsets.fromLTRB(16, 12, 16, 8),
- decoration: BoxDecoration(
- color: colors.bgCard,
- borderRadius: BorderRadius.circular(12),
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- children: [
- Bone.square(size: 22, borderRadius: BorderRadius.circular(4)),
- const SizedBox(width: 8),
- Expanded(flex: 3, child: Bone.text()),
- const Spacer(),
- Bone.text(width: 80),
- ],
- ),
- SizedBox(height: 8),
- Row(children: [const SizedBox(width: 30), Bone.text(width: 140)]),
- SizedBox(height: 8),
- Row(
- children: [
- Bone.square(size: 18, borderRadius: BorderRadius.circular(4)),
- const SizedBox(width: 4),
- Bone.text(width: 24),
- const SizedBox(width: 8),
- Expanded(flex: 3, child: Bone.text()),
- const Spacer(),
- Bone.text(width: 64),
- ],
- ),
- SizedBox(height: 8),
- Row(
- children: [
- const SizedBox(width: 54),
- Expanded(flex: 2, child: Bone.text()),
- ],
- ),
- ],
- ),
- ),
- );
- }
- }
- /// 匹配消息卡片的骨架占位
- class SkeletonMessageCard extends StatelessWidget {
- const SkeletonMessageCard({super.key});
- @override
- Widget build(BuildContext context) {
- final colors = Theme.of(context).extension<AppColorsExtension>()!;
- return Skeletonizer(
- enabled: true,
- child: Container(
- height: 88,
- padding: const EdgeInsets.all(12),
- decoration: BoxDecoration(
- color: colors.bgCard,
- borderRadius: BorderRadius.circular(8),
- ),
- child: Row(
- children: [
- Bone.circle(size: 40),
- SizedBox(width: 12),
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Expanded(flex: 3, child: Bone.text()),
- const Spacer(),
- Bone.text(width: 80),
- ],
- ),
- SizedBox(height: 2),
- Bone.text(width: 80),
- SizedBox(height: 2),
- Expanded(flex: 2, child: Bone.text()),
- ],
- ),
- ),
- SizedBox(width: 12),
- Bone(width: 8, height: 8, borderRadius: BorderRadius.circular(4)),
- ],
- ),
- ),
- );
- }
- }
- /// 详情页骨架(ExpenseDetailPage / ExpenseApplyDetailPage)
- /// 匹配 FormSection 卡片布局:基本信息 + 明细 + 附件
- class SkeletonDetailPage extends StatelessWidget {
- const SkeletonDetailPage({super.key});
- @override
- Widget build(BuildContext context) {
- return SingleChildScrollView(
- padding: const EdgeInsets.fromLTRB(16, 16, 16, 24),
- child: Skeletonizer(
- enabled: true,
- child: Column(
- children: [
- _FormCard(rows: 7),
- const SizedBox(height: 16),
- _FormCard(rows: 2),
- const SizedBox(height: 16),
- _FormCard(rows: 3),
- const SizedBox(height: 24),
- const Center(child: Bone(width: 120, height: 14)),
- ],
- ),
- ),
- );
- }
- }
- /// 表单页骨架(ExpenseApplyCreatePage / ExpenseCreatePage)
- /// 匹配 FormSection + 输入框 + 底部操作栏布局
- class SkeletonFormPage extends StatelessWidget {
- final bool showImportLink;
- const SkeletonFormPage({super.key, this.showImportLink = false});
- @override
- Widget build(BuildContext context) {
- final colors = Theme.of(context).extension<AppColorsExtension>()!;
- final bottomPadding = MediaQuery.of(context).padding.bottom;
- return Stack(
- children: [
- SingleChildScrollView(
- padding: EdgeInsets.fromLTRB(16, 16, 16, 80 + bottomPadding),
- child: Skeletonizer(
- enabled: true,
- child: Column(
- children: [
- if (showImportLink) ...[
- // 导入申请单按钮骨架
- Container(
- padding: const EdgeInsets.symmetric(
- horizontal: 12,
- vertical: 10,
- ),
- decoration: BoxDecoration(
- color: colors.bgCard,
- borderRadius: BorderRadius.circular(12),
- ),
- child: Row(
- children: [
- Bone.square(
- size: 20,
- borderRadius: BorderRadius.circular(4),
- ),
- const SizedBox(width: 8),
- Bone(width: 160, height: 14),
- ],
- ),
- ),
- const SizedBox(height: 16),
- ],
- _FormCard(rows: 5),
- const SizedBox(height: 16),
- _FormCard(rows: 2),
- const SizedBox(height: 16),
- _FormCard(rows: 3),
- const SizedBox(height: 24),
- const Center(child: Bone(width: 120, height: 14)),
- ],
- ),
- ),
- ),
- // 底部操作栏骨架,贴底并适配安全区
- Positioned(
- left: 0,
- right: 0,
- bottom: 0,
- child: Skeletonizer(
- enabled: true,
- child: Container(
- padding: EdgeInsets.fromLTRB(16, 12, 16, 12 + bottomPadding),
- decoration: BoxDecoration(
- color: colors.bgCard,
- border: Border(top: BorderSide(color: colors.border)),
- ),
- child: Row(
- children: [
- Expanded(
- child: Bone(
- height: 44,
- borderRadius: BorderRadius.circular(8),
- ),
- ),
- const SizedBox(width: 12),
- Expanded(
- child: Bone(
- height: 44,
- borderRadius: BorderRadius.circular(8),
- ),
- ),
- ],
- ),
- ),
- ),
- ),
- ],
- );
- }
- }
- class _FormCard extends StatelessWidget {
- final int rows;
- const _FormCard({required this.rows});
- @override
- Widget build(BuildContext context) {
- final colors = Theme.of(context).extension<AppColorsExtension>()!;
- return Container(
- padding: const EdgeInsets.all(16),
- decoration: BoxDecoration(
- color: colors.bgCard,
- borderRadius: BorderRadius.circular(12),
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- children: [
- Bone.square(size: 20, borderRadius: BorderRadius.circular(4)),
- const SizedBox(width: 8),
- Bone(width: 80, height: 16),
- const Spacer(),
- Bone(width: 40, height: 16),
- ],
- ),
- const SizedBox(height: 20),
- ...List.generate(
- rows,
- (i) => Padding(
- padding: EdgeInsets.only(bottom: i < rows - 1 ? 16 : 0),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Bone(width: 64, height: 14),
- Bone(width: 140 + (i % 3) * 20, height: 14),
- ],
- ),
- ),
- ),
- ],
- ),
- );
- }
- }
- // ═══ 报表页骨架 — 各页面按实际布局独立定义 ═══
- /// 事前申请明细报表骨架(ExpenseApplyDetailReportPage)
- /// 布局:筛选栏 + 统计卡片(1行2个) + 折线图(单线) + 明细列表
- class SkeletonExpenseApplyDetailReportPage extends StatelessWidget {
- const SkeletonExpenseApplyDetailReportPage({super.key});
- @override
- Widget build(BuildContext context) {
- final colors = Theme.of(context).extension<AppColorsExtension>()!;
- return Column(
- children: [
- _dateFilterChip(colors),
- Expanded(
- child: SingleChildScrollView(
- child: Skeletonizer(
- enabled: true,
- child: Column(
- children: [
- // 统计卡片 — 1行2列
- Padding(
- padding: const EdgeInsets.fromLTRB(12, 12, 12, 0),
- child: Row(
- children: [
- Expanded(
- child: Bone(
- height: 80,
- borderRadius: BorderRadius.circular(8),
- ),
- ),
- const SizedBox(width: 8),
- Expanded(
- child: Bone(
- height: 80,
- borderRadius: BorderRadius.circular(8),
- ),
- ),
- ],
- ),
- ),
- const SizedBox(height: 16),
- // 折线图 — 标题 + 1个图例 + 图表区
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 12),
- child: Container(
- padding: const EdgeInsets.all(16),
- decoration: BoxDecoration(
- color: colors.bgCard,
- borderRadius: BorderRadius.circular(8),
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Bone(width: 120, height: 16),
- const SizedBox(height: 8),
- Row(
- children: [
- Bone.square(
- size: 8,
- borderRadius: BorderRadius.circular(4),
- ),
- const SizedBox(width: 4),
- Bone(width: 60, height: 12),
- ],
- ),
- const SizedBox(height: 16),
- Row(
- children: [
- Expanded(
- child: Bone(
- height: 200,
- borderRadius: BorderRadius.circular(8),
- ),
- ),
- ],
- ),
- ],
- ),
- ),
- ),
- const SizedBox(height: 16),
- // 明细列表
- _detailListSkeleton(colors),
- const SizedBox(height: 80),
- ],
- ),
- ),
- ),
- ),
- ],
- );
- }
- }
- /// 费用报销明细报表骨架(ExpenseDetailReportPage)
- /// 布局:筛选栏 + 统计卡片(2+1) + 双折线图 + 柱形图 + 明细列表
- class SkeletonExpenseDetailReportPage extends StatelessWidget {
- const SkeletonExpenseDetailReportPage({super.key});
- @override
- Widget build(BuildContext context) {
- final colors = Theme.of(context).extension<AppColorsExtension>()!;
- return Column(
- children: [
- _dateFilterChip(colors),
- Expanded(
- child: SingleChildScrollView(
- child: Skeletonizer(
- enabled: true,
- child: Column(
- children: [
- // 统计卡片 — 1行2列 + 1个全宽
- Padding(
- padding: const EdgeInsets.fromLTRB(12, 12, 12, 0),
- child: Row(
- children: [
- Expanded(
- child: Bone(
- height: 80,
- borderRadius: BorderRadius.circular(8),
- ),
- ),
- const SizedBox(width: 8),
- Expanded(
- child: Bone(
- height: 80,
- borderRadius: BorderRadius.circular(8),
- ),
- ),
- ],
- ),
- ),
- const SizedBox(height: 8),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 12),
- child: Row(
- children: [
- Expanded(
- child: Bone(
- height: 80,
- borderRadius: BorderRadius.circular(8),
- ),
- ),
- ],
- ),
- ),
- const SizedBox(height: 16),
- // 双折线图 — 标题 + 2个图例 + 图表区
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 12),
- child: Container(
- padding: const EdgeInsets.all(16),
- decoration: BoxDecoration(
- color: colors.bgCard,
- borderRadius: BorderRadius.circular(8),
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Bone(width: 120, height: 16),
- const SizedBox(height: 8),
- Row(
- children: [
- Bone.square(
- size: 8,
- borderRadius: BorderRadius.circular(4),
- ),
- const SizedBox(width: 4),
- Bone(width: 60, height: 12),
- const SizedBox(width: 16),
- Bone.square(
- size: 8,
- borderRadius: BorderRadius.circular(4),
- ),
- const SizedBox(width: 4),
- Bone(width: 60, height: 12),
- ],
- ),
- const SizedBox(height: 16),
- Row(
- children: [
- Expanded(
- child: Bone(
- height: 200,
- borderRadius: BorderRadius.circular(8),
- ),
- ),
- ],
- ),
- ],
- ),
- ),
- ),
- const SizedBox(height: 16),
- // 柱形图 — 标题 + 图表区
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 12),
- child: Container(
- padding: const EdgeInsets.all(16),
- decoration: BoxDecoration(
- color: colors.bgCard,
- borderRadius: BorderRadius.circular(8),
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Bone(width: 160, height: 16),
- const SizedBox(height: 16),
- Row(
- children: [
- Expanded(
- child: Bone(
- height: 220,
- borderRadius: BorderRadius.circular(8),
- ),
- ),
- ],
- ),
- ],
- ),
- ),
- ),
- const SizedBox(height: 12),
- // 明细列表
- _detailListSkeleton(colors),
- const SizedBox(height: 80),
- ],
- ),
- ),
- ),
- ),
- ],
- );
- }
- }
- // ── 日期筛选 chip 占位 ──
- Widget _dateFilterChip(AppColorsExtension colors) => Container(
- padding: const EdgeInsets.fromLTRB(12, 8, 12, 12),
- color: colors.bgCard,
- child: Container(
- height: 40,
- decoration: BoxDecoration(
- color: colors.bgSecondaryContainer,
- borderRadius: BorderRadius.circular(20),
- ),
- ),
- );
- // ── 明细列表骨架 ──
- Widget _detailListSkeleton(AppColorsExtension colors) => Padding(
- padding: const EdgeInsets.symmetric(horizontal: 12),
- child: Container(
- width: double.infinity,
- decoration: BoxDecoration(
- color: colors.bgCard,
- borderRadius: BorderRadius.circular(8),
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Padding(
- padding: const EdgeInsets.fromLTRB(16, 12, 16, 8),
- child: Row(
- children: [
- Bone(width: 80, height: 16),
- const Spacer(),
- Bone(width: 100, height: 14),
- ],
- ),
- ),
- const Divider(height: 1),
- ...List.generate(4, (i) {
- return Column(
- children: [
- Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: 16,
- vertical: 12,
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Bone(width: 120 + (i % 3) * 40, height: 14),
- Bone(width: 80, height: 16),
- ],
- ),
- const SizedBox(height: 6),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Bone(width: 90, height: 12),
- Bone(width: 80, height: 16),
- ],
- ),
- if (i == 0) ...[
- const SizedBox(height: 6),
- Bone(width: 200, height: 14),
- ],
- ],
- ),
- ),
- if (i < 3) const Divider(height: 1),
- ],
- );
- }),
- ],
- ),
- ),
- );
|