周睿 il y a 2 ans
Parent
commit
f856be5d09

+ 1 - 3
android/app/build.gradle

@@ -28,7 +28,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
 android {
     namespace "com.beswell.track_offical"
     compileSdkVersion flutter.compileSdkVersion
-    ndkVersion flutter.ndkVersion
+    ndkVersion "25.1.8937393"
 
     compileOptions {
         sourceCompatibility JavaVersion.VERSION_1_8
@@ -44,7 +44,6 @@ android {
     }
 
     defaultConfig {
-        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
         applicationId "com.beswell.track_offical"
         // You can update the following values to match your application needs.
         // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
@@ -56,7 +55,6 @@ android {
 
     buildTypes {
         release {
-            // TODO: Add your own signing config for the release build.
             // Signing with the debug keys for now, so `flutter run --release` works.
             signingConfig signingConfigs.debug
         }

+ 1 - 1
android/build.gradle

@@ -1,5 +1,5 @@
 buildscript {
-    ext.kotlin_version = '1.8.22'
+    ext.kotlin_version = '1.9.10'
     repositories {
         maven { url 'https://maven.aliyun.com/repository/google' }
         maven { url 'https://maven.aliyun.com/repository/public' }

BIN
assets/images/ic_location.png


BIN
assets/images/ic_map_scale.png


+ 2 - 0
lib/generated/assets.dart

@@ -6,7 +6,9 @@ class Assets {
   static const String imagesBkCommonPage = 'assets/images/bk_common_page.png';
   static const String imagesBkLogin = 'assets/images/bk_login.png';
   static const String imagesBkLoginRight = 'assets/images/bk_login_right.png';
+  static const String imagesIcLocation = 'assets/images/ic_location.png';
   static const String imagesIcLoginLogo = 'assets/images/ic_login_logo.png';
+  static const String imagesIcMapScale = 'assets/images/ic_map_scale.png';
   static const String imagesImCompassNoMap = 'assets/images/im_compass_no_map.png';
 
 }

+ 1 - 1
lib/view/home/home_view.dart

@@ -19,7 +19,7 @@ class HomeView extends GetView<HomeController> {
   @override
   Widget build(BuildContext context) {
     return DefaultTabController(
-        initialIndex: 0,
+        initialIndex: 1,
         length: _tabElems.length,
         child: Scaffold(
           appBar: HomeAppBar(

+ 186 - 7
lib/view/home/map/map_page.dart

@@ -1,26 +1,205 @@
+import 'package:common_pub/model/distance.dart';
 import 'package:flutter/material.dart';
 import 'package:get/get.dart';
+import 'package:track_offical/service/api.dart' as api;
+import 'package:track_offical/utils.dart';
+import 'package:common_pub/model/position.dart' as m;
+import '../../../generated/assets.dart';
 
-class MapPageController extends GetxController{
+typedef MapInfo = api.ToMapSimpleV2;
 
-}
+class MapPageController extends GetxController {
+  @override
+  void onInit() {
+    super.onInit();
+    mapGetMore();
+  }
 
+  Future<void> mapGetMore() async {
+    if (isMapGetMoreLoading.value) {
+      return;
+    }
+    isMapGetMoreLoading.value = true;
+    await tryApi(() async {
+      final r = await api.ApiService.to.stub.toMapListV2(api.MapListRequestV2()
+        ..limit = 20
+        ..offset = mapList.length);
 
-class MapPage extends StatelessWidget{
-  const MapPage({super.key});
+      mapList.addAll(r.list);
+      return;
+    }, onFinally: () {
+      isMapGetMoreLoading.value = false;
+    });
 
+    mapListScrollController.addListener(() {
+      if (mapListScrollController.position.pixels ==
+          mapListScrollController.position.maxScrollExtent) {
+        //达到最大滚动位置
+        mapGetMore();
+      }
+    });
+  }
 
+  final mapList = <MapInfo>[].obs;
+  final isMapGetMoreLoading = false.obs;
+  final mapListScrollController = ScrollController();
+  final Rx<m.Position?> position = Rx(null);
+}
+
+class MapPage extends StatelessWidget {
+  const MapPage({super.key});
 
   @override
   Widget build(BuildContext context) {
     return GetBuilder(
         init: MapPageController(),
-        builder: (c){
+        builder: (c) {
           return Container(
+            width: double.infinity,
+            height: double.infinity,
             margin: const EdgeInsets.all(20),
-            decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(16)),
+            padding: const EdgeInsets.fromLTRB(58, 28, 58, 28),
+            decoration: BoxDecoration(
+                color: Colors.white, borderRadius: BorderRadius.circular(16)),
+            child: Column(
+              children: [
+                Row(
+                  children: [
+                    Container(
+                      width: 14,
+                      height: 14,
+                      decoration: const BoxDecoration(
+                          shape: BoxShape.circle, color: Colors.blue),
+                    ),
+                    const Text('地图列表'),
+                  ],
+                ),
+                Expanded(
+                    child: Obx(() => GridView.builder(
+                        itemCount: c.mapList.length,
+                        controller: c.mapListScrollController,
+                        scrollDirection: Axis.horizontal,
+                        gridDelegate:
+                            const SliverGridDelegateWithFixedCrossAxisCount(
+                                //设置列数
+                                crossAxisCount: 2,
+                                //设置横向间距
+                                crossAxisSpacing: 10,
+                                //设置主轴间距
+                                mainAxisSpacing: 10,
+                                childAspectRatio: 0.66),
+                        itemBuilder: (context, i) {
+                          return GalleryCardWidget(data: c.mapList[i], position: c.position.value);
+                        })))
+              ],
+            ),
           );
         });
   }
+}
+
+class GalleryCardWidget extends StatelessWidget {
+  final MapInfo data;
+  final m.Position? position;
+
+  const GalleryCardWidget({
+    super.key,
+    required this.data,
+    required this.position});
 
-}
+  void onTap() async {
+  }
+
+  @override
+  Widget build(BuildContext context) {
+    var distance = '--';
+
+    if ( data.hasDistance()) {
+      distance = Distance(m: data.distance).toString();
+    }
+
+    return GestureDetector(
+      onTap: onTap,
+      child: Card(
+        color: Colors.white,
+        surfaceTintColor: Colors.white,
+        shape: const RoundedRectangleBorder(
+            borderRadius: BorderRadius.all(Radius.circular(5.44))),
+        clipBehavior: Clip.antiAlias,
+        child: Column(
+          crossAxisAlignment: CrossAxisAlignment.start,
+          children: [
+            AspectRatio(aspectRatio: 1, child: wImage()),
+            Expanded(
+                child: Padding(
+                    padding: const EdgeInsets.all(6),
+                    child: Column(
+                      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
+                      crossAxisAlignment: CrossAxisAlignment.start,
+                      children: [
+                        Text(
+                          data.name,
+                          style: const TextStyle(
+                            fontSize: 15.24,
+                            fontWeight: FontWeight.w500,
+                          ),
+                          textAlign: TextAlign.start,
+                          maxLines: 1,
+                          overflow: TextOverflow.ellipsis,
+                        ),
+                        Text(
+                          data.description,
+                          style: const TextStyle(
+                            fontSize: 19,
+                            color: Color(0xffc6c6c6),
+                          ),
+                          textAlign: TextAlign.start,
+                          maxLines: 1,
+                          overflow: TextOverflow.ellipsis,
+                        ),
+                        const Spacer(),
+                        DefaultTextStyle(
+                            style: const TextStyle(
+                                color: Colors.black, fontSize: 14),
+                            child: Row(
+                              crossAxisAlignment: CrossAxisAlignment.end,
+                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
+                              children: [
+                                Image.asset(Assets.imagesIcMapScale,
+                                    height: 14),
+                                Text(' 1:${data.mapScaleNumber}'),
+                                const Spacer(),
+                                Image.asset(Assets.imagesIcLocation,
+                                    height: 14),
+                                Text(' $distance'),
+                              ],
+                            ))
+                      ],
+                    ))),
+          ],
+        ),
+      ),
+    );
+  }
+
+  Widget wImage() {
+    return Stack(
+      children: [
+        SizedBox(
+            height: double.infinity,
+            // child: AppNetImage(netImage: data.image, fit: BoxFit.fitHeight)
+        ),
+        Container(
+                width: double.infinity,
+                height: double.infinity,
+                color: Colors.white.withAlpha(178),
+                alignment: Alignment.center,
+                child: const Text(
+                  '待开放',
+                  style: TextStyle(color: Color(0xffff6203), fontSize: 15.24),
+                ),
+              )
+      ],
+    );
+  }
+}