| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311 |
- 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)),
- ],
- ),
- ),
- );
- }
- }
|