周睿 2 lat temu
rodzic
commit
7380c053f2

+ 0 - 1
lib/service/app.dart

@@ -12,7 +12,6 @@ class AppService extends GetxService{
   final _serverTime = _ServerTime();
   DateTime get now=>_serverTime.now();
 
-
   Future<AppService> init()async{
     await GetStorage.init();
     final packageInfo = await PackageInfo.fromPlatform();

+ 27 - 0
lib/service/map_watch.dart

@@ -0,0 +1,27 @@
+import 'package:common_pub/service/service.dart';
+import '../service/api.dart';
+import 'package:fixnum/fixnum.dart';
+
+typedef MapId = Int64;
+
+class MapWatchService extends PlugService{
+  static final Rx<MapWatchService?> _instance = Rx(null);
+  static MapWatchService? get instance => _instance.value;
+
+  static Future<void> setMapById(MapId id)async{
+    final info = await ApiService.to.stub.toMapDetailV2(IdRequest()
+      ..id = id);
+
+    final thisInstance = MapWatchService(
+        id: id)
+      ..name = info.mapName;
+
+    _instance.value = thisInstance;
+    thisInstance.init();
+  }
+
+  MapWatchService({required this.id});
+
+  final MapId id;
+  String name= '';
+}

+ 5 - 4
lib/view/home/data_detail/data_detail.dart

@@ -1,5 +1,4 @@
 import 'package:application/widget.dart';
-import 'package:application/model/game_map.dart';
 import 'data_detail_controller.dart';
 
 
@@ -16,8 +15,10 @@ class DataDetailPage extends StatelessWidget{
             width: double.infinity,
             color: const Color(0xffc9c0c0),
             alignment: Alignment.center,
-            child: Obx(() => c.gameMap != null? content(context, c.gameMap!): noData(),
-          ));
+            child: Obx((){
+              final mapWatch = c.mapWatch;
+              return mapWatch != null? content(context, mapWatch): noData();
+            }));
     });
   }
 
@@ -36,7 +37,7 @@ class DataDetailPage extends StatelessWidget{
     );
   }
 
-  Widget content(BuildContext context, GameMap gameMap){
+  Widget content(BuildContext context, MapWatchService gameMap){
     return Container();
   }
 }

+ 4 - 3
lib/view/home/data_detail/data_detail_controller.dart

@@ -1,9 +1,10 @@
+import 'package:application/service/map_watch.dart';
 import 'package:get/get.dart';
 import '../home_controller.dart';
+export 'package:application/service/map_watch.dart';
+
 
 class DataDetailController extends GetxController{
   HomeController get _home => Get.find();
-
-  GameMap? get gameMap => _home.gameMap.value;
-
+  MapWatchService? get mapWatch => MapWatchService.instance;
 }

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

@@ -3,5 +3,5 @@ import '../../model/game_map.dart';
 export '../../model/game_map.dart';
 
 class HomeController extends GetxController{
-  final Rx<GameMap?> gameMap = Rx(null);
+
 }

+ 14 - 6
lib/view/home/map/map_page.dart

@@ -1,3 +1,4 @@
+import 'package:application/service/map_watch.dart';
 import 'package:common_pub/model/distance.dart';
 import 'package:flutter/material.dart';
 import 'package:get/get.dart';
@@ -90,7 +91,12 @@ class MapPage extends StatelessWidget {
                                 mainAxisSpacing: 10,
                                 childAspectRatio: 1.3),
                         itemBuilder: (context, i) {
-                          return GalleryCardWidget(data: c.mapList[i], position: c.position.value);
+                          return Obx((){
+                            final data = c.mapList[i];
+                            final id = MapWatchService.instance?.id;
+                            final s = id == MapId(data.mapId);
+                            return GalleryCardWidget(data: data, position: c.position.value, isSelected: s);
+                          }) ;
                         })))
               ],
             ),
@@ -102,32 +108,34 @@ class MapPage extends StatelessWidget {
 class GalleryCardWidget extends StatelessWidget {
   final MapInfo data;
   final m.Position? position;
+  final bool isSelected;
 
   const GalleryCardWidget({
     super.key,
     required this.data,
-    required this.position});
+    required this.position, required this.isSelected});
 
-  void onTap() async {
+  void onTap(int id) async {
+    await MapWatchService.setMapById(MapId(id));
   }
 
   @override
   Widget build(BuildContext context) {
     var distance = '--';
-
     if ( data.hasDistance()) {
       distance = Distance(m: data.distance).toString();
     }
 
     return GestureDetector(
-      onTap: onTap,
+      onTap: ()=>onTap(data.mapId),
       child: Card(
         color: Colors.white,
+        shadowColor: isSelected? Colors.red: null,
         surfaceTintColor: Colors.white,
         shape: const RoundedRectangleBorder(
             borderRadius: BorderRadius.all(Radius.circular(5.44))),
         clipBehavior: Clip.antiAlias,
-        elevation: 2,
+        elevation: isSelected?8:4,
         child: Column(
           crossAxisAlignment: CrossAxisAlignment.start,
           children: [

+ 1 - 1
third_party/common_pub

@@ -1 +1 @@
-Subproject commit dbc409dcd8cb310fed35e733ea61887fcd5d30d2
+Subproject commit 97389f7507892dd78ff50f981a65c9fd0d2aadc8