import 'package:application/widget.dart';
import 'package:common_pub/ui/map_view/map_view.dart';
import 'package:common_pub/ui/map_view/view_map_image.dart';
import 'package:common_pub/ui/map_view/view_map_touch.dart';
import 'package:common_pub/ui/map_view/view_plug_loading.dart';
import 'data_detail_controller.dart';


class DataDetailPage extends StatelessWidget{
  const DataDetailPage({super.key});

  @override
  Widget build(BuildContext context) {
    return GetBuilder(
        init: DataDetailController(),
        builder: (c){
          return Container(
            height: double.infinity,
            width: double.infinity,
            color: const Color(0xffc9c0c0),
            alignment: Alignment.center,
            child: Obx((){
              final mapWatch = c.mapWatch;
              return mapWatch != null? content(context, mapWatch): noData();
            }));
    });
  }


  Widget noData(){
    return Center(
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          Image.asset(Assets.imagesIcNoData, height: 64),
          const SizedBox(height: 25),
          const Text('没有数据, 请选择地图',
              style: TextStyle(color: Color(0xff707070), fontSize: 18.5)),
        ],
      ),
    );
  }

  Widget content(BuildContext context, MapWatchService map){
    return ViewMapStack(plug: map.plugMap, children: [
      ViewPlugLoading(map.plugMap),
      ViewMapImage(map.plugMap),
      ViewMapTouch(map.plugMap)
    ]);
  }
}