| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import 'package:app_business/service/abase.dart';
- import 'package:app_business/service/api.dart';
- import 'package:app_business/service/app.dart';
- import 'package:flutter/material.dart';
- import 'package:track_common/service/map_watch.dart';
- import 'package:track_common/view.dart';
- class SettingsPage extends StatelessWidget {
- const SettingsPage({super.key});
- ApiService get api => Get.find();
- AppService get app => Get.find();
- @override
- Widget build(BuildContext context) {
- return Center(
- child: SizedBox(
- width: 320,
- child: Card(
- margin: const EdgeInsets.symmetric(vertical: 24),
- child: ListView(
- children: [
- _SettingsElem(
- title: '软件版本', onTap: () {}, tail: Text(app.appVersion)),
- _SettingsElem(title: '退出登录', onTap: onSignOut)
- ],
- ),
- )));
- }
- Widget divider() {
- return const Divider(color: Colors.grey);
- }
- Future<void> onSignOut() async {
- final mapWatchService = Get.find<MapWatchService>();
- mapWatchService.setMap(null);
- api.signOut();
- LoginView.to(
- canBack: false, thenToPageCall: () => Get.offAllNamed(HomeView.name));
- }
- }
- class _SettingsElem extends StatelessWidget {
- const _SettingsElem({required this.onTap, required this.title, this.tail});
- final VoidCallback onTap;
- final String title;
- final Widget? tail;
- @override
- Widget build(BuildContext context) {
- return GestureDetector(
- onTap: onTap,
- child: Container(
- height: 60,
- color: Colors.transparent,
- padding: const EdgeInsets.symmetric(horizontal: 24),
- child: Row(
- children: [
- Text(title),
- const Spacer(),
- tail ?? const Icon(Icons.chevron_right)
- ],
- ),
- ));
- }
- }
|