feat: add Flutter mobile clients and staff delivery API

This commit is contained in:
david
2026-07-30 21:47:41 +08:00
parent 550efb3812
commit 36a5ced1c0
228 changed files with 17159 additions and 22 deletions

View File

@@ -0,0 +1,109 @@
import 'package:flutter/material.dart';
import '../../../data/repositories/client_repository.dart';
import '../../../domain/models/client_models.dart';
import '../../core/widgets.dart';
class HomePage extends StatefulWidget {
const HomePage({required this.repository, super.key});
final ClientRepository repository;
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
late Future<(List<ClientRecord>, Map<String, Object?>?)> _future;
@override
void initState() {
super.initState();
_future = _load();
}
Future<(List<ClientRecord>, Map<String, Object?>?)> _load() async =>
(await widget.repository.contents(), await widget.repository.serviceRelation());
Future<void> _refresh() async {
setState(() => _future = _load());
await _future;
}
@override
Widget build(BuildContext context) => Scaffold(
body: SafeArea(
child: FutureBuilder<(List<ClientRecord>, Map<String, Object?>?)>(
future: _future,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: CircularProgressIndicator());
}
if (snapshot.hasError) {
return EmptyState(
title: '首页加载失败',
description: snapshot.error.toString(),
onRetry: _refresh,
);
}
final (contents, relation) = snapshot.data ?? (const <ClientRecord>[], null);
return RefreshIndicator(
onRefresh: _refresh,
child: ListView(
physics: const AlwaysScrollableScrollPhysics(),
padding: const EdgeInsets.only(bottom: 24),
children: [
const PageIntro(
eyebrow: '安全生活',
title: '今天也要安心用气',
description: '设备控制能力尚未开放,本页只展示真实服务与安全内容。',
),
Card(
margin: const EdgeInsets.symmetric(horizontal: 16),
child: Padding(
padding: const EdgeInsets.all(20),
child: Row(
children: [
Icon(
Icons.store_mall_directory_outlined,
size: 38,
color: Theme.of(context).colorScheme.primary,
),
const SizedBox(width: 14),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text('当前服务归属', style: TextStyle(fontWeight: FontWeight.w800)),
const SizedBox(height: 4),
Text(
relation == null
? '尚未建立服务关系'
: '${relation['gas_name'] ?? ''} ${relation['delivery_name'] ?? ''}',
),
],
),
),
],
),
),
),
const Padding(
padding: EdgeInsets.fromLTRB(20, 26, 20, 8),
child: Text('安全公告', style: TextStyle(fontWeight: FontWeight.w800, fontSize: 18)),
),
if (contents.isEmpty)
const Padding(
padding: EdgeInsets.all(20),
child: Text('暂无已发布内容'),
)
else
...contents.take(6).map((item) => RecordCard(record: item)),
],
),
);
},
),
),
);
}