123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- import 'package:flutter/material.dart';
- import 'package:flutter_timeline/flutter_timeline.dart';
- import 'package:flutter_timeline/indicator_position.dart';
- import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
- import 'package:sport/bean/jog/sum.dart';
- import 'package:sport/pages/run/run_detail_page.dart';
- import 'package:sport/pages/run/run_page.dart';
- import 'package:sport/router/navigator_util.dart';
- import 'package:sport/services/api/inject_api.dart';
- import 'package:sport/services/api/resp.dart';
- import 'package:sport/services/app_lifecycle_state.dart';
- import 'package:sport/utils/DateFormat.dart';
- import 'package:sport/utils/sport_utils.dart';
- import 'package:sport/widgets/appbar.dart';
- import 'package:sport/widgets/button_primary.dart';
- import 'package:sport/widgets/decoration.dart';
- import 'package:sport/widgets/error.dart';
- import 'package:sport/widgets/image.dart';
- import 'package:sport/widgets/loading.dart';
- class RunFinishPage extends StatefulWidget {
- final List<Map<String, num>> items;
- final int type;
- const RunFinishPage({Key? key, required this.items, required this.type}) : super(key: key);
- @override
- State<StatefulWidget> createState() => _PageState();
- }
- class _PageState extends LifecycleState<RunFinishPage> {
- int _index = 0;
- @override
- void initState() {
- super.initState();
- }
- @override
- void dispose() {
- super.dispose();
- }
- @override
- Widget build(BuildContext context) {
- return Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 20.0),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- ListView.separated(
- shrinkWrap: true,
- itemBuilder: (BuildContext context, int index) {
- var map = widget.items[index];
- bool type = widget.type == 2;
- String label = index ==0?"目标":"实际";
- return GestureDetector(
- onTap: () {
- setState(() {
- _index = index;
- });
- },
- behavior: HitTestBehavior.opaque,
- child: Container(
- decoration: _index == index ? BoxDecoration(color: Theme.of(context).accentColor.withOpacity(0.06)) : null,
- child: Row(
- children: [
- Expanded(
- child: Padding(
- padding: const EdgeInsets.all(12.0),
- child: Column(
- children: [
- Text(
- type ? "以$label距离 (${formatNum((map["distance"] ?? 0) / 1000, 2)}公里) 保存" : "以$label时间 (${(map["duration"] ?? 0).toInt() ~/ 60}分钟) 保存",
- style: Theme.of(context).textTheme.headline1!,
- ),
- const SizedBox(
- height: 8.0,
- ),
- Row(
- children: [
- Text("时长 ${DateFormat.toTime((map["duration"] ?? 0).toInt())}", style: Theme.of(context).textTheme.bodyText1!),
- const SizedBox(
- width: 16.0,
- ),
- Text("配速 ${SportUtils.pace4((map["duration"] ?? 0).toInt(), ((map["distance"] ?? 0)).toInt())}", style: Theme.of(context).textTheme.bodyText1!),
- ],
- )
- ],
- crossAxisAlignment: CrossAxisAlignment.start,
- ),
- ),
- ),
- Padding(
- padding: const EdgeInsets.all(8.0),
- child: Image.asset("lib/assets/img/${_index == index ? "pop_icon_conneted" : "pop_icon_choose_normal"}.png"),
- )
- ],
- ),
- ),
- );
- },
- separatorBuilder: (BuildContext context, int index) {
- return Divider(height: 1,);
- },
- itemCount: widget.items.length,
- ),
- const SizedBox(
- height: 16.0,
- ),
- PrimaryButton(
- callback: () {
- Navigator.pop(context, _index);
- },
- content: "确定",
- height: 35,
- )
- ],
- ),
- );
- }
- }
|