76f266645d
含 Phase 1.1 IM seq 排序、断线重连、多端已读同步与微信式语音转文字 UI。 排除 node_modules、构建产物、安装包与 .env 密钥。 Co-authored-by: Cursor <cursoragent@cursor.com>
75 lines
2.2 KiB
Dart
75 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../api/oa_client.dart';
|
|
import '../device/device_bridge.dart';
|
|
import '../theme.dart';
|
|
import 'tencent_map_thumb.dart';
|
|
|
|
class LocationViewPage extends StatelessWidget {
|
|
const LocationViewPage({
|
|
super.key,
|
|
required this.api,
|
|
required this.title,
|
|
required this.address,
|
|
this.lat,
|
|
this.lng,
|
|
});
|
|
|
|
final OaClient api;
|
|
final String title;
|
|
final String address;
|
|
final double? lat;
|
|
final double? lng;
|
|
|
|
Future<void> _openMaps(BuildContext context) async {
|
|
if (lat == null || lng == null) return;
|
|
final la = lat!;
|
|
final ln = lng!;
|
|
final q = Uri.encodeComponent(title.isNotEmpty ? title : '$la,$ln');
|
|
final urls = [
|
|
'https://uri.amap.com/marker?position=$ln,$la&name=$q',
|
|
'geo:$la,$ln?q=$la,$ln($q)',
|
|
];
|
|
for (final u in urls) {
|
|
try {
|
|
await DeviceBridge.openUrl(u);
|
|
return;
|
|
} catch (_) {}
|
|
}
|
|
if (context.mounted) {
|
|
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('无法打开地图')));
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.white,
|
|
appBar: AppBar(title: const Text('位置')),
|
|
body: ListView(
|
|
children: [
|
|
if (lat != null && lng != null)
|
|
TencentMapThumb(api: api, lat: lat!, lng: lng!, width: MediaQuery.sizeOf(context).width, height: 220),
|
|
Padding(
|
|
padding: const EdgeInsets.fromLTRB(16, 16, 16, 8),
|
|
child: Text(title.isEmpty ? '位置' : title, style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w600)),
|
|
),
|
|
if (address.isNotEmpty)
|
|
Padding(
|
|
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
|
|
child: Text(address, style: const TextStyle(fontSize: 14, color: kMute)),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: FilledButton.icon(
|
|
onPressed: lat == null ? null : () => _openMaps(context),
|
|
icon: const Icon(Icons.map_outlined),
|
|
label: const Text('用地图打开'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|