outing_log_create_page.dart 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_riverpod/flutter_riverpod.dart';
  3. import 'package:go_router/go_router.dart';
  4. import 'package:tdesign_flutter/tdesign_flutter.dart';
  5. import '../../shared/widgets/nav_bar_config.dart';
  6. import '../../shared/widgets/form_section.dart';
  7. import '../../shared/widgets/form_field_row.dart';
  8. import '../../shared/widgets/action_bar.dart';
  9. import '../../core/i18n/app_localizations.dart';
  10. import '../../core/theme/app_colors_extension.dart';
  11. import '../../core/theme/app_colors.dart';
  12. class OutingLogCreatePage extends ConsumerStatefulWidget {
  13. const OutingLogCreatePage({super.key});
  14. @override
  15. ConsumerState<OutingLogCreatePage> createState() =>
  16. _OutingLogCreatePageState();
  17. }
  18. class _OutingLogCreatePageState extends ConsumerState<OutingLogCreatePage> {
  19. final _customerCtrl = TextEditingController();
  20. final _summaryCtrl = TextEditingController();
  21. final _planCtrl = TextEditingController();
  22. final _summaryFocus = FocusNode();
  23. final _scrollCtrl = ScrollController();
  24. // GPS 模拟
  25. String _gpsAddress = '深圳市南山区科技园南路88号';
  26. final double _gpsLat = 22.5431;
  27. final double _gpsLng = 113.9532;
  28. double _gpsAccuracy = 15.0;
  29. bool _gpsFailed = false;
  30. // 客户联想
  31. final List<String> _mockCustomers = [
  32. '华软科技',
  33. '云创数据',
  34. '数据引力',
  35. '天诚科技',
  36. '博思软件',
  37. '智云科技',
  38. '恒通信息',
  39. '创新无限',
  40. ];
  41. String? _selectedCustomer;
  42. // 客户联系人
  43. final Map<String, List<Map<String, String>>> _mockContacts = {
  44. '华软科技': [
  45. {'name': '赵经理', 'phone': '13800138001', 'position': 'IT经理'},
  46. {'name': '李主管', 'phone': '13800138002', 'position': '采购主管'},
  47. ],
  48. '云创数据': [
  49. {'name': '陈经理', 'phone': '13800138003', 'position': '技术总监'},
  50. ],
  51. '数据引力': [
  52. {'name': '孙总', 'phone': '13800138004', 'position': '总经理'},
  53. ],
  54. '天诚科技': [
  55. {'name': '周主任', 'phone': '13800138005', 'position': '办公室主任'},
  56. ],
  57. };
  58. Map<String, String>? _selectedContact;
  59. // 照片
  60. final List<String> _photos = [];
  61. static const int _maxPhotos = 9;
  62. @override
  63. void initState() {
  64. super.initState();
  65. _summaryFocus.addListener(() => _ensureVisible(_summaryFocus));
  66. }
  67. void _ensureVisible(FocusNode node) {
  68. if (!node.hasFocus) return;
  69. WidgetsBinding.instance.addPostFrameCallback((_) {
  70. if (node.hasFocus && _scrollCtrl.hasClients) {
  71. final ctx = node.context;
  72. if (ctx != null) {
  73. Scrollable.ensureVisible(
  74. ctx,
  75. alignment: 0.3,
  76. duration: const Duration(milliseconds: 300),
  77. );
  78. }
  79. }
  80. });
  81. }
  82. @override
  83. void dispose() {
  84. _customerCtrl.dispose();
  85. _summaryCtrl.dispose();
  86. _planCtrl.dispose();
  87. _summaryFocus.dispose();
  88. _scrollCtrl.dispose();
  89. super.dispose();
  90. }
  91. bool _hasUnsaved() =>
  92. _customerCtrl.text.isNotEmpty ||
  93. _summaryCtrl.text.isNotEmpty ||
  94. _planCtrl.text.isNotEmpty ||
  95. _photos.isNotEmpty;
  96. void _unfocus() => FocusScope.of(context).unfocus();
  97. void _showConfirmDialog(
  98. String title,
  99. String content,
  100. String leftText,
  101. String rightText,
  102. VoidCallback onConfirm,
  103. ) {
  104. _unfocus();
  105. final colors = Theme.of(context).extension<AppColorsExtension>()!;
  106. showDialog(
  107. context: context,
  108. builder: (ctx) => TDAlertDialog(
  109. title: title,
  110. content: content,
  111. buttonStyle: TDDialogButtonStyle.text,
  112. leftBtn: TDDialogButtonOptions(
  113. title: leftText,
  114. titleColor: colors.primary,
  115. action: () => Navigator.pop(ctx),
  116. ),
  117. rightBtn: TDDialogButtonOptions(
  118. title: rightText,
  119. titleColor: colors.danger,
  120. action: () {
  121. Navigator.pop(ctx);
  122. onConfirm();
  123. },
  124. ),
  125. ),
  126. );
  127. }
  128. Future<void> _pickCustomer() async {
  129. final l10n = AppLocalizations.of(context);
  130. final searchCtrl = TextEditingController();
  131. final selected = await showDialog<String>(
  132. context: context,
  133. builder: (ctx) {
  134. String filter = '';
  135. return StatefulBuilder(
  136. builder: (context, setDialogState) {
  137. final query = filter;
  138. final suggestions = query.isEmpty
  139. ? _mockCustomers
  140. : _mockCustomers.where((c) => c.contains(query)).toList();
  141. return AlertDialog(
  142. title: Text(l10n.get('searchCustomer')),
  143. content: SizedBox(
  144. width: double.maxFinite,
  145. child: Column(
  146. mainAxisSize: MainAxisSize.min,
  147. children: [
  148. TDInput(
  149. controller: searchCtrl,
  150. hintText: l10n.get('searchCustomer'),
  151. onChanged: (v) {
  152. filter = v;
  153. setDialogState(() {});
  154. },
  155. ),
  156. const SizedBox(height: 8),
  157. if (suggestions.isEmpty)
  158. Padding(
  159. padding: const EdgeInsets.all(16),
  160. child: Text(
  161. l10n.get('noData'),
  162. style: TextStyle(
  163. fontSize: AppFontSizes.body,
  164. color: Theme.of(context)
  165. .extension<AppColorsExtension>()!
  166. .textPlaceholder,
  167. ),
  168. ),
  169. )
  170. else
  171. SizedBox(
  172. height: 300,
  173. child: ListView.separated(
  174. shrinkWrap: true,
  175. itemCount: suggestions.length,
  176. separatorBuilder: (_, _) => const Divider(height: 1),
  177. itemBuilder: (_, i) => ListTile(
  178. dense: true,
  179. title: Text(suggestions[i]),
  180. onTap: () => Navigator.pop(ctx, suggestions[i]),
  181. ),
  182. ),
  183. ),
  184. ],
  185. ),
  186. ),
  187. actions: [
  188. TextButton(
  189. onPressed: () => Navigator.pop(ctx),
  190. child: Text(l10n.get('cancel')),
  191. ),
  192. ],
  193. );
  194. },
  195. );
  196. },
  197. );
  198. searchCtrl.dispose();
  199. if (selected != null && mounted) {
  200. setState(() {
  201. _selectedCustomer = selected;
  202. _customerCtrl.text = selected;
  203. _selectedContact = null;
  204. });
  205. }
  206. }
  207. Future<void> _pickContact() async {
  208. final l10n = AppLocalizations.of(context);
  209. if (_selectedCustomer == null) {
  210. TDToast.showText(l10n.get('selectCustomerFirst'), context: context);
  211. return;
  212. }
  213. final contacts = _mockContacts[_selectedCustomer];
  214. if (contacts == null || contacts.isEmpty) {
  215. TDToast.showText(l10n.get('noContact'), context: context);
  216. return;
  217. }
  218. final result = await showDialog<Map<String, String>>(
  219. context: context,
  220. builder: (ctx) => TDAlertDialog.vertical(
  221. title: l10n.get('selectContact'),
  222. buttons: contacts
  223. .map(
  224. (c) => TDDialogButtonOptions(
  225. title: '${c['name']} ${c['position']} ${c['phone']}',
  226. action: () => Navigator.pop(ctx, c),
  227. ),
  228. )
  229. .toList(),
  230. ),
  231. );
  232. if (result != null && mounted) {
  233. setState(() => _selectedContact = result);
  234. }
  235. }
  236. Future<void> _takePhoto() async {
  237. final l10n = AppLocalizations.of(context);
  238. if (_photos.length >= _maxPhotos) {
  239. TDToast.showText(l10n.get('maxPhotoCount'), context: context);
  240. return;
  241. }
  242. final idx = _photos.length + 1;
  243. setState(() {
  244. _photos.add('photo_placeholder_$idx');
  245. });
  246. if (context.mounted) {
  247. TDToast.showText(
  248. l10n.getString(
  249. 'mockPhotoTaken',
  250. args: {
  251. 'idx': '$idx',
  252. 'time': DateTime.now().toString().substring(0, 19),
  253. 'lat': '$_gpsLat°N',
  254. 'lng': '$_gpsLng°E',
  255. },
  256. ),
  257. context: context,
  258. );
  259. }
  260. }
  261. void _removePhoto(int index) {
  262. setState(() => _photos.removeAt(index));
  263. }
  264. Future<void> _simulateGps() async {
  265. final l10n = AppLocalizations.of(context);
  266. setState(() {
  267. _gpsFailed = false;
  268. _gpsAddress = '深圳市南山区科技园南路88号';
  269. _gpsAccuracy = 15.0;
  270. });
  271. TDToast.showText(l10n.get('gpsSuccess'), context: context);
  272. }
  273. Future<void> _saveDraft() async {
  274. final l10n = AppLocalizations.of(context);
  275. if (context.mounted) {
  276. TDToast.showText(l10n.get('draftSavedToast'), context: context);
  277. }
  278. }
  279. Future<void> _submit() async {
  280. final l10n = AppLocalizations.of(context);
  281. if (_gpsFailed) {
  282. TDToast.showText(l10n.get('gpsPermission'), context: context);
  283. return;
  284. }
  285. if (_gpsAddress.isEmpty) {
  286. TDToast.showText(l10n.get('gpsLocatingWait'), context: context);
  287. return;
  288. }
  289. if (_photos.isEmpty) {
  290. TDToast.showText(l10n.get('requiredPhotos'), context: context);
  291. return;
  292. }
  293. if (_summaryCtrl.text.trim().isEmpty) {
  294. TDToast.showText(l10n.get('requiredSummary'), context: context);
  295. return;
  296. }
  297. if (context.mounted) {
  298. TDToast.showText(l10n.get('outingLogSubmitted'), context: context);
  299. context.pop();
  300. }
  301. }
  302. // ─────────────────────────────────────────────
  303. // Build
  304. // ─────────────────────────────────────────────
  305. @override
  306. Widget build(BuildContext context) {
  307. final colors = Theme.of(context).extension<AppColorsExtension>()!;
  308. final l10n = AppLocalizations.of(context);
  309. setNavBarTitle(context, ref, NavBarConfig(
  310. title: l10n.get('outingLogCreate'),
  311. showBack: true,
  312. onBack: () {
  313. if (_hasUnsaved()) {
  314. _showConfirmDialog(
  315. l10n.get('confirmExit'),
  316. l10n.get('unsavedContentWarning'),
  317. l10n.get('continueEditing'),
  318. l10n.get('discardAndExit'),
  319. () => context.pop(),
  320. );
  321. } else {
  322. context.pop();
  323. }
  324. },
  325. ));
  326. return PopScope(
  327. canPop: false,
  328. onPopInvokedWithResult: (didPop, _) {
  329. if (!didPop) {
  330. if (_hasUnsaved()) {
  331. _showConfirmDialog(
  332. l10n.get('confirmExit'),
  333. l10n.get('unsavedContentWarning'),
  334. l10n.get('continueEditing'),
  335. l10n.get('discardAndExit'),
  336. () => context.pop(),
  337. );
  338. } else {
  339. context.pop();
  340. }
  341. }
  342. },
  343. child: Column(
  344. children: [
  345. Expanded(
  346. child: GestureDetector(
  347. onTap: () => FocusScope.of(context).unfocus(),
  348. child: SingleChildScrollView(
  349. controller: _scrollCtrl,
  350. padding: const EdgeInsets.all(16),
  351. child: Column(
  352. children: [
  353. _buildGpsSection(),
  354. const SizedBox(height: 16),
  355. _buildCustomerSection(l10n, colors),
  356. const SizedBox(height: 16),
  357. _buildSummarySection(l10n, colors),
  358. const SizedBox(height: 16),
  359. _buildPlanSection(l10n, colors),
  360. const SizedBox(height: 16),
  361. _buildPhotosSection(l10n, colors),
  362. const SizedBox(height: 80),
  363. ],
  364. ),
  365. ),
  366. ),
  367. ),
  368. ActionBar(
  369. centerLabel: l10n.get('saveDraft'),
  370. rightLabel: l10n.get('submit'),
  371. showLeft: false,
  372. onCenterTap: _saveDraft,
  373. onRightTap: _submit,
  374. ),
  375. ],
  376. ),
  377. );
  378. }
  379. // ═══ GPS 定位 ═══
  380. Widget _buildGpsSection() {
  381. final l10n = AppLocalizations.of(context);
  382. final colors = Theme.of(context).extension<AppColorsExtension>()!;
  383. return FormSection(
  384. title: 'GPS定位',
  385. leadingIcon: Icons.location_on_outlined,
  386. children: [
  387. if (_gpsFailed)
  388. Row(
  389. children: [
  390. Icon(Icons.location_off, size: 22, color: colors.statusGray),
  391. const SizedBox(width: 10),
  392. Expanded(
  393. child: Column(
  394. crossAxisAlignment: CrossAxisAlignment.start,
  395. children: [
  396. Text(
  397. l10n.get('gpsFailed'),
  398. style: TextStyle(
  399. fontSize: AppFontSizes.body,
  400. color: colors.textPrimary,
  401. ),
  402. ),
  403. const SizedBox(height: 4),
  404. Text(
  405. l10n.get('gpsFailedHint'),
  406. style: TextStyle(
  407. fontSize: AppFontSizes.caption,
  408. color: colors.textSecondary,
  409. ),
  410. ),
  411. ],
  412. ),
  413. ),
  414. GestureDetector(
  415. onTap: _simulateGps,
  416. child: Container(
  417. padding: const EdgeInsets.symmetric(
  418. horizontal: 12,
  419. vertical: 6,
  420. ),
  421. decoration: BoxDecoration(
  422. color: colors.primaryLight,
  423. borderRadius: BorderRadius.circular(4),
  424. ),
  425. child: Text(
  426. l10n.get('retry'),
  427. style: TextStyle(
  428. fontSize: AppFontSizes.caption,
  429. color: colors.primary,
  430. ),
  431. ),
  432. ),
  433. ),
  434. ],
  435. )
  436. else
  437. _buildGpsSuccess(colors),
  438. ],
  439. );
  440. }
  441. Widget _buildGpsSuccess(AppColorsExtension colors) {
  442. final isWarning = _gpsAccuracy > 100;
  443. return Row(
  444. crossAxisAlignment: CrossAxisAlignment.start,
  445. children: [
  446. Icon(
  447. Icons.shield_outlined,
  448. size: 22,
  449. color: isWarning ? colors.warning : colors.success,
  450. ),
  451. const SizedBox(width: 10),
  452. Expanded(
  453. child: Column(
  454. crossAxisAlignment: CrossAxisAlignment.start,
  455. children: [
  456. Text(
  457. _gpsAddress,
  458. style: TextStyle(
  459. fontSize: AppFontSizes.body,
  460. color: colors.textPrimary,
  461. ),
  462. ),
  463. const SizedBox(height: 4),
  464. Row(
  465. children: [
  466. Text(
  467. '${_gpsLat.toStringAsFixed(4)}°N, ${_gpsLng.toStringAsFixed(4)}°E · 精度 ${_gpsAccuracy.toStringAsFixed(0)}m',
  468. style: TextStyle(
  469. fontSize: AppFontSizes.caption,
  470. color: isWarning ? colors.warning : colors.textSecondary,
  471. ),
  472. ),
  473. if (isWarning) ...[
  474. const SizedBox(width: 6),
  475. Icon(
  476. Icons.warning_amber_rounded,
  477. size: 14,
  478. color: colors.warning,
  479. ),
  480. ],
  481. ],
  482. ),
  483. ],
  484. ),
  485. ),
  486. ],
  487. );
  488. }
  489. // ═══ 客户信息 ═══
  490. Widget _buildCustomerSection(AppLocalizations l10n, AppColorsExtension colors) {
  491. return FormSection(
  492. title: l10n.get('customerInfo'),
  493. leadingIcon: Icons.business_outlined,
  494. children: [
  495. FormFieldRow(
  496. label: l10n.get('customerName'),
  497. value: _selectedCustomer,
  498. hint: l10n.get('searchCustomer'),
  499. onTap: _pickCustomer,
  500. ),
  501. const SizedBox(height: 16),
  502. FormFieldRow(
  503. label: l10n.get('selectContact'),
  504. value: _selectedContact != null
  505. ? '${_selectedContact!['name']} ${_selectedContact!['phone']}'
  506. : null,
  507. hint: l10n.get('selectContactHint'),
  508. onTap: _pickContact,
  509. ),
  510. ],
  511. );
  512. }
  513. // ═══ 工作总结 ═══
  514. Widget _buildSummarySection(AppLocalizations l10n, AppColorsExtension colors) {
  515. return FormSection(
  516. title: l10n.get('workSummary'),
  517. leadingIcon: Icons.description_outlined,
  518. children: [
  519. _label(l10n.get('workSummary'), required: true),
  520. const SizedBox(height: 8),
  521. TDTextarea(
  522. controller: _summaryCtrl,
  523. focusNode: _summaryFocus,
  524. hintText: l10n.get('workSummaryRequiredHint'),
  525. maxLines: 5,
  526. minLines: 1,
  527. maxLength: 500,
  528. indicator: true,
  529. padding: EdgeInsets.zero,
  530. bordered: true,
  531. backgroundColor: colors.bgPage,
  532. ),
  533. ],
  534. );
  535. }
  536. // ═══ 跟进计划 ═══
  537. Widget _buildPlanSection(AppLocalizations l10n, AppColorsExtension colors) {
  538. return FormSection(
  539. title: l10n.get('followUp'),
  540. leadingIcon: Icons.event_note_outlined,
  541. children: [
  542. _label(l10n.get('followUp')),
  543. const SizedBox(height: 8),
  544. TDInput(
  545. controller: _planCtrl,
  546. hintText: l10n.get('followUpOptional'),
  547. decoration: BoxDecoration(
  548. color: colors.bgPage,
  549. borderRadius: BorderRadius.circular(4),
  550. border: Border.all(color: colors.border),
  551. ),
  552. ),
  553. ],
  554. );
  555. }
  556. // ═══ 现场拍照 ═══
  557. Widget _buildPhotosSection(AppLocalizations l10n, AppColorsExtension colors) {
  558. return FormSection(
  559. title: l10n.get('sitePhotos'),
  560. leadingIcon: Icons.camera_alt_outlined,
  561. showAction: _photos.length < _maxPhotos,
  562. actionText: _photos.length >= _maxPhotos
  563. ? l10n.get('limitReached')
  564. : l10n.get('takePhoto'),
  565. onActionTap: _photos.length >= _maxPhotos ? null : _takePhoto,
  566. children: [
  567. if (_photos.isEmpty)
  568. GestureDetector(
  569. onTap: _takePhoto,
  570. child: Container(
  571. height: 100,
  572. decoration: BoxDecoration(
  573. color: colors.bgPage,
  574. borderRadius: BorderRadius.circular(4),
  575. border: Border.all(color: colors.border, width: 1),
  576. ),
  577. child: Center(
  578. child: Column(
  579. mainAxisAlignment: MainAxisAlignment.center,
  580. children: [
  581. Icon(
  582. Icons.camera_alt_outlined,
  583. size: 32,
  584. color: colors.primary,
  585. ),
  586. const SizedBox(height: 4),
  587. Text(
  588. l10n.get('tapToTakePhoto'),
  589. style: TextStyle(
  590. fontSize: AppFontSizes.caption,
  591. color: colors.textPlaceholder,
  592. ),
  593. ),
  594. ],
  595. ),
  596. ),
  597. ),
  598. )
  599. else
  600. Wrap(
  601. spacing: 8,
  602. runSpacing: 8,
  603. children: [
  604. ..._photos.asMap().entries.map(
  605. (entry) => _buildPhotoThumbnail(entry.key, entry.value),
  606. ),
  607. if (_photos.length < _maxPhotos)
  608. GestureDetector(
  609. onTap: _takePhoto,
  610. child: Container(
  611. width: 80,
  612. height: 80,
  613. decoration: BoxDecoration(
  614. color: colors.bgPage,
  615. borderRadius: BorderRadius.circular(4),
  616. border: Border.all(color: colors.border),
  617. ),
  618. child: Icon(
  619. Icons.add,
  620. size: 28,
  621. color: colors.primary,
  622. ),
  623. ),
  624. ),
  625. ],
  626. ),
  627. const SizedBox(height: 8),
  628. Container(
  629. padding: const EdgeInsets.all(8),
  630. decoration: BoxDecoration(
  631. color: colors.primaryLight,
  632. borderRadius: BorderRadius.circular(4),
  633. ),
  634. child: Row(
  635. children: [
  636. Icon(
  637. Icons.info_outline,
  638. size: 14,
  639. color: colors.primary,
  640. ),
  641. const SizedBox(width: 6),
  642. Expanded(
  643. child: Text(
  644. l10n.getString(
  645. 'watermarkHintDynamic',
  646. args: {
  647. 'lat': _gpsLat.toStringAsFixed(4),
  648. 'lng': _gpsLng.toStringAsFixed(4),
  649. },
  650. ),
  651. style: TextStyle(
  652. fontSize: AppFontSizes.caption,
  653. color: colors.textSecondary,
  654. ),
  655. ),
  656. ),
  657. ],
  658. ),
  659. ),
  660. ],
  661. );
  662. }
  663. Widget _buildPhotoThumbnail(int index, String photo) {
  664. final colors = Theme.of(context).extension<AppColorsExtension>()!;
  665. return Stack(
  666. children: [
  667. Container(
  668. width: 80,
  669. height: 80,
  670. decoration: BoxDecoration(
  671. color: colors.infoBorder,
  672. borderRadius: BorderRadius.circular(4),
  673. ),
  674. child: Center(
  675. child: Icon(Icons.image_outlined, size: 32, color: colors.primary),
  676. ),
  677. ),
  678. Positioned(
  679. top: -4,
  680. right: -4,
  681. child: GestureDetector(
  682. onTap: () => _removePhoto(index),
  683. child: Container(
  684. padding: const EdgeInsets.all(2),
  685. decoration: BoxDecoration(
  686. color: colors.danger,
  687. shape: BoxShape.circle,
  688. ),
  689. child: const Icon(Icons.close, size: 14, color: Colors.white),
  690. ),
  691. ),
  692. ),
  693. Positioned(
  694. bottom: 2,
  695. left: 2,
  696. right: 2,
  697. child: Container(
  698. padding: const EdgeInsets.symmetric(horizontal: 2),
  699. color: Colors.black54,
  700. child: Text(
  701. '${DateTime.now().hour.toString().padLeft(2, '0')}:${DateTime.now().minute.toString().padLeft(2, '0')} ${_gpsLat.toStringAsFixed(2)},${_gpsLng.toStringAsFixed(2)}',
  702. style: const TextStyle(fontSize: 8, color: Colors.white),
  703. maxLines: 1,
  704. overflow: TextOverflow.ellipsis,
  705. ),
  706. ),
  707. ),
  708. ],
  709. );
  710. }
  711. Widget _label(String t, {bool required = false}) {
  712. final colors = Theme.of(context).extension<AppColorsExtension>()!;
  713. return Text.rich(
  714. TextSpan(
  715. children: [
  716. TextSpan(
  717. text: t,
  718. style: TextStyle(
  719. fontSize: AppFontSizes.subtitle,
  720. color: colors.textSecondary,
  721. ),
  722. ),
  723. if (required)
  724. TextSpan(
  725. text: ' *',
  726. style: TextStyle(
  727. fontSize: AppFontSizes.subtitle,
  728. color: colors.danger,
  729. ),
  730. ),
  731. ],
  732. ),
  733. );
  734. }
  735. }