Compare commits
5 Commits
dev_map
...
756bf53cf5
| Author | SHA1 | Date | |
|---|---|---|---|
| 756bf53cf5 | |||
| f68c2d0938 | |||
| 211d0225e4 | |||
| 7d9b4d99e8 | |||
| 3dd583a278 |
@@ -68,8 +68,3 @@ android {
|
|||||||
flutter {
|
flutter {
|
||||||
source = "../.."
|
source = "../.."
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation("com.amap.api:navi-3dmap-location-search:10.0.700_3dmap10.0.700_loc6.4.5_sea9.7.2")
|
|
||||||
implementation("com.squareup.okhttp3:okhttp:4.12.0")
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -14,12 +14,7 @@
|
|||||||
<!--定位权限-->
|
<!--定位权限-->
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
||||||
<!--用于申请调用A-GPS模块-->
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION"/>
|
||||||
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"></uses-permission>
|
|
||||||
<!--如果设置了target >= 28 如果需要启动后台定位则必须声明这个权限-->
|
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
|
|
||||||
<!--如果您的应用需要后台定位权限,且有可能运行在Android Q设备上,并且设置了target>28,必须增加这个权限声明-->
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
|
|
||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
||||||
|
|
||||||
|
|
||||||
@@ -27,19 +22,6 @@
|
|||||||
android:label="小羚羚"
|
android:label="小羚羚"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:icon="@mipmap/logo">
|
android:icon="@mipmap/logo">
|
||||||
|
|
||||||
<!-- 高德地图Key -->
|
|
||||||
<meta-data
|
|
||||||
android:name="com.amap.api.v2.apikey"
|
|
||||||
android:value="92495660f7bc990cb475426c47c03b65" />
|
|
||||||
|
|
||||||
<!-- 高德地图定位服务 -->
|
|
||||||
<service android:name="com.amap.api.location.APSService" />
|
|
||||||
<!--高德导航-->
|
|
||||||
<activity
|
|
||||||
android:name="com.amap.api.navi.AmapRouteActivity"
|
|
||||||
android:theme="@android:style/Theme.NoTitleBar"
|
|
||||||
android:configChanges="orientation|keyboardHidden|screenSize|navigation" />
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
|||||||
@@ -1,195 +1,6 @@
|
|||||||
package com.lnkj.ln_jq_app;
|
package com.lnkj.ln_jq_app;
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.core.app.ActivityCompat;
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
import io.flutter.embedding.android.FlutterActivity;
|
import io.flutter.embedding.android.FlutterActivity;
|
||||||
import io.flutter.embedding.engine.FlutterEngine;
|
|
||||||
import io.flutter.plugin.common.MethodChannel;
|
|
||||||
|
|
||||||
public class MainActivity extends FlutterActivity {
|
public class MainActivity extends FlutterActivity {
|
||||||
|
|
||||||
private static final String CHANNEL = "com.lnkj.ln_jq_app/map";
|
|
||||||
private static final String TAG = "MainActivity";
|
|
||||||
|
|
||||||
// 权限请求码
|
|
||||||
private static final int PERMISSION_REQUEST_CODE = 1001;
|
|
||||||
|
|
||||||
private NativeMapView mapView;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
|
|
||||||
super.configureFlutterEngine(flutterEngine);
|
|
||||||
|
|
||||||
// 注册高德地图导航Platform View
|
|
||||||
flutterEngine
|
|
||||||
.getPlatformViewsController()
|
|
||||||
.getRegistry()
|
|
||||||
.registerViewFactory(
|
|
||||||
"NativeFirstPage",
|
|
||||||
new NativeMapFactory(this)
|
|
||||||
);
|
|
||||||
|
|
||||||
// 注册方法通道用于地图控制
|
|
||||||
new MethodChannel(flutterEngine.getDartExecutor().getBinaryMessenger(), CHANNEL)
|
|
||||||
.setMethodCallHandler((call, result) -> {
|
|
||||||
switch (call.method) {
|
|
||||||
case "requestPermissions":
|
|
||||||
requestPermissions();
|
|
||||||
result.success(null);
|
|
||||||
break;
|
|
||||||
case "onResume":
|
|
||||||
if (mapView != null) {
|
|
||||||
mapView.onResume();
|
|
||||||
}
|
|
||||||
result.success(null);
|
|
||||||
break;
|
|
||||||
case "onPause":
|
|
||||||
if (mapView != null) {
|
|
||||||
mapView.onPause();
|
|
||||||
}
|
|
||||||
result.success(null);
|
|
||||||
break;
|
|
||||||
case "onDestroy":
|
|
||||||
if (mapView != null) {
|
|
||||||
mapView.dispose();
|
|
||||||
mapView = null;
|
|
||||||
}
|
|
||||||
result.success(null);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
result.notImplemented();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取当前系统版本需要申请的权限列表
|
|
||||||
*/
|
|
||||||
private String[] getRequiredPermissions() {
|
|
||||||
List<String> permissions = new ArrayList<>();
|
|
||||||
// 定位权限是必须的
|
|
||||||
permissions.add(Manifest.permission.ACCESS_FINE_LOCATION);
|
|
||||||
permissions.add(Manifest.permission.ACCESS_COARSE_LOCATION);
|
|
||||||
|
|
||||||
// 存储权限处理:Android 13 (API 33) 以下才需要申请 legacy 存储权限
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
|
|
||||||
permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
|
||||||
permissions.add(Manifest.permission.READ_EXTERNAL_STORAGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return permissions.toArray(new String[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查并申请权限
|
|
||||||
*/
|
|
||||||
private void checkAndRequestPermissions() {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
String[] requiredPermissions = getRequiredPermissions();
|
|
||||||
List<String> deniedPermissions = new ArrayList<>();
|
|
||||||
|
|
||||||
for (String permission : requiredPermissions) {
|
|
||||||
if (ContextCompat.checkSelfPermission(this, permission) != PackageManager.PERMISSION_GRANTED) {
|
|
||||||
deniedPermissions.add(permission);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!deniedPermissions.isEmpty()) {
|
|
||||||
ActivityCompat.requestPermissions(
|
|
||||||
this,
|
|
||||||
deniedPermissions.toArray(new String[0]),
|
|
||||||
PERMISSION_REQUEST_CODE
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
Log.d(TAG, "所有必要权限已授予");
|
|
||||||
if (mapView != null) {
|
|
||||||
mapView.startLocation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (mapView != null) {
|
|
||||||
mapView.startLocation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void requestPermissions() {
|
|
||||||
checkAndRequestPermissions();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMapView(NativeMapView mapView) {
|
|
||||||
this.mapView = mapView;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
// 注意:高德SDK合规检查通过后再进行定位相关操作
|
|
||||||
// 这里仅保留地图生命周期调用,权限建议在Flutter端或按需触发
|
|
||||||
if (mapView != null) {
|
|
||||||
mapView.onResume();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
if (mapView != null) {
|
|
||||||
mapView.onPause();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
if (mapView != null) {
|
|
||||||
mapView.dispose();
|
|
||||||
mapView = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
|
||||||
super.onSaveInstanceState(outState);
|
|
||||||
if (mapView != null) {
|
|
||||||
mapView.onSaveInstanceState(outState);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
||||||
|
|
||||||
if (requestCode == PERMISSION_REQUEST_CODE) {
|
|
||||||
boolean locationGranted = false;
|
|
||||||
for (int i = 0; i < permissions.length; i++) {
|
|
||||||
if (Manifest.permission.ACCESS_FINE_LOCATION.equals(permissions[i])
|
|
||||||
&& grantResults[i] == PackageManager.PERMISSION_GRANTED) {
|
|
||||||
locationGranted = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (locationGranted) {
|
|
||||||
if (mapView != null) {
|
|
||||||
mapView.startLocation();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 只有在定位权限确实被拒绝时才弹出提示
|
|
||||||
Toast.makeText(this, "请授予应用定位权限以正常使用地图功能", Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
package com.lnkj.ln_jq_app;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import io.flutter.plugin.common.MessageCodec;
|
|
||||||
import io.flutter.plugin.common.StandardMessageCodec;
|
|
||||||
import io.flutter.plugin.platform.PlatformView;
|
|
||||||
import io.flutter.plugin.platform.PlatformViewFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 高德地图导航 Platform View Factory
|
|
||||||
* 对应iOS的NativeViewFactory
|
|
||||||
*/
|
|
||||||
public class NativeMapFactory extends PlatformViewFactory {
|
|
||||||
|
|
||||||
private static final String VIEW_TYPE_ID = "NativeFirstPage";
|
|
||||||
private static NativeMapView mapViewInstance = null;
|
|
||||||
private final Context context;
|
|
||||||
|
|
||||||
public NativeMapFactory(Context context) {
|
|
||||||
super(StandardMessageCodec.INSTANCE);
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PlatformView create(Context context, int viewId, Object args) {
|
|
||||||
mapViewInstance = new NativeMapView(context, viewId, args);
|
|
||||||
return mapViewInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取地图实例,供MainActivity使用
|
|
||||||
*/
|
|
||||||
public static NativeMapView getMapView() {
|
|
||||||
return mapViewInstance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,511 +0,0 @@
|
|||||||
package com.lnkj.ln_jq_app;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.Typeface;
|
|
||||||
import android.graphics.drawable.GradientDrawable;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Looper;
|
|
||||||
import android.text.Editable;
|
|
||||||
import android.text.TextWatcher;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.util.TypedValue;
|
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.view.inputmethod.EditorInfo;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.amap.api.location.AMapLocation;
|
|
||||||
import com.amap.api.location.AMapLocationClient;
|
|
||||||
import com.amap.api.location.AMapLocationClientOption;
|
|
||||||
import com.amap.api.location.AMapLocationListener;
|
|
||||||
import com.amap.api.maps.AMap;
|
|
||||||
import com.amap.api.maps.AMapOptions;
|
|
||||||
import com.amap.api.maps.CameraUpdateFactory;
|
|
||||||
import com.amap.api.maps.LocationSource;
|
|
||||||
import com.amap.api.maps.MapView;
|
|
||||||
import com.amap.api.maps.MapsInitializer;
|
|
||||||
import com.amap.api.maps.model.BitmapDescriptorFactory;
|
|
||||||
import com.amap.api.maps.model.LatLng;
|
|
||||||
import com.amap.api.maps.model.Marker;
|
|
||||||
import com.amap.api.maps.model.MarkerOptions;
|
|
||||||
import com.amap.api.maps.model.MyLocationStyle;
|
|
||||||
import com.amap.api.maps.model.Poi;
|
|
||||||
import com.amap.api.navi.AMapNavi;
|
|
||||||
import com.amap.api.navi.AmapNaviPage;
|
|
||||||
import com.amap.api.navi.AmapNaviParams;
|
|
||||||
import com.amap.api.navi.AmapNaviType;
|
|
||||||
import com.amap.api.navi.AmapPageType;
|
|
||||||
import com.amap.api.navi.model.AMapCarInfo;
|
|
||||||
import com.amap.api.services.core.AMapException;
|
|
||||||
import com.amap.api.services.core.LatLonPoint;
|
|
||||||
import com.amap.api.services.geocoder.GeocodeResult;
|
|
||||||
import com.amap.api.services.geocoder.GeocodeSearch;
|
|
||||||
import com.amap.api.services.geocoder.RegeocodeAddress;
|
|
||||||
import com.amap.api.services.geocoder.RegeocodeQuery;
|
|
||||||
import com.amap.api.services.geocoder.RegeocodeResult;
|
|
||||||
import com.amap.api.services.help.Inputtips;
|
|
||||||
import com.amap.api.services.help.InputtipsQuery;
|
|
||||||
import com.amap.api.services.help.Tip;
|
|
||||||
import com.amap.api.services.route.BusRouteResult;
|
|
||||||
import com.amap.api.services.route.DrivePath;
|
|
||||||
import com.amap.api.services.route.DriveRouteResult;
|
|
||||||
import com.amap.api.services.route.RideRouteResult;
|
|
||||||
import com.amap.api.services.route.RouteSearch;
|
|
||||||
import com.amap.api.services.route.WalkRouteResult;
|
|
||||||
|
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import io.flutter.plugin.platform.PlatformView;
|
|
||||||
import okhttp3.Call;
|
|
||||||
import okhttp3.Callback;
|
|
||||||
import okhttp3.MediaType;
|
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
import okhttp3.Request;
|
|
||||||
import okhttp3.RequestBody;
|
|
||||||
import okhttp3.Response;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 高德地图导航 Native View - 底部精简交互优化版
|
|
||||||
*/
|
|
||||||
public class NativeMapView implements PlatformView, LocationSource, AMapLocationListener,
|
|
||||||
GeocodeSearch.OnGeocodeSearchListener, RouteSearch.OnRouteSearchListener, AMap.OnMarkerClickListener, Inputtips.InputtipsListener {
|
|
||||||
|
|
||||||
private static final String TAG = "NativeMapView";
|
|
||||||
private final FrameLayout container;
|
|
||||||
private MapView mapView;
|
|
||||||
private AMap aMap;
|
|
||||||
private OnLocationChangedListener mListener;
|
|
||||||
|
|
||||||
private AMapLocationClient mlocationClient;
|
|
||||||
private final Context mContext;
|
|
||||||
private Activity mActivity;
|
|
||||||
private GeocodeSearch geocoderSearch;
|
|
||||||
private RouteSearch routeSearch;
|
|
||||||
private final OkHttpClient httpClient = new OkHttpClient();
|
|
||||||
|
|
||||||
// UI组件
|
|
||||||
private EditText endInput;
|
|
||||||
private LinearLayout searchArea; // 规划路线面板
|
|
||||||
private LinearLayout detailPanel; // 详情面板
|
|
||||||
private TextView tvStationName, tvStationAddr, tvRouteInfo;
|
|
||||||
|
|
||||||
private LatLng currentLatLng;
|
|
||||||
private String startName = "我的位置";
|
|
||||||
private String endName = "";
|
|
||||||
private LatLng startPoint;
|
|
||||||
private LatLng endPoint;
|
|
||||||
private boolean isFirstLocation = true;
|
|
||||||
private final List<Marker> stationMarkers = new ArrayList<>();
|
|
||||||
|
|
||||||
public NativeMapView(Context context, int id, Object args) {
|
|
||||||
this.mContext = context;
|
|
||||||
mActivity = getActivityFromContext(context);
|
|
||||||
|
|
||||||
MapsInitializer.updatePrivacyShow(context, true, true);
|
|
||||||
MapsInitializer.updatePrivacyAgree(context, true);
|
|
||||||
|
|
||||||
container = new FrameLayout(context);
|
|
||||||
container.setClickable(true);
|
|
||||||
container.setFocusable(true);
|
|
||||||
|
|
||||||
mapView = new MapView(context);
|
|
||||||
mapView.onCreate(null);
|
|
||||||
aMap = mapView.getMap();
|
|
||||||
|
|
||||||
container.addView(mapView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
|
||||||
|
|
||||||
initServices(context);
|
|
||||||
initOverlays(context);
|
|
||||||
setupMapUi();
|
|
||||||
|
|
||||||
if (context instanceof MainActivity) {
|
|
||||||
((MainActivity) context).setMapView(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initServices(Context context) {
|
|
||||||
try {
|
|
||||||
geocoderSearch = new GeocodeSearch(context);
|
|
||||||
geocoderSearch.setOnGeocodeSearchListener(this);
|
|
||||||
routeSearch = new RouteSearch(context);
|
|
||||||
routeSearch.setRouteSearchListener(this);
|
|
||||||
} catch (AMapException e) {
|
|
||||||
Log.e(TAG, "服务初始化失败", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initOverlays(Context context) {
|
|
||||||
// --- 底部主容器 (包含两个互斥显示的面板) ---
|
|
||||||
LinearLayout bottomContainer = new LinearLayout(context);
|
|
||||||
bottomContainer.setOrientation(LinearLayout.VERTICAL);
|
|
||||||
bottomContainer.setGravity(Gravity.BOTTOM);
|
|
||||||
|
|
||||||
// 1. 详情面板 (用于显示加氢站详细信息,初始隐藏)
|
|
||||||
detailPanel = createDetailPanel(context);
|
|
||||||
detailPanel.setVisibility(View.GONE);
|
|
||||||
bottomContainer.addView(detailPanel);
|
|
||||||
|
|
||||||
// 2. 搜索规划面板 (初始显示)
|
|
||||||
searchArea = new LinearLayout(context);
|
|
||||||
searchArea.setOrientation(LinearLayout.VERTICAL);
|
|
||||||
searchArea.setBackground(getRoundedDrawable(Color.WHITE, 16));
|
|
||||||
searchArea.setElevation(dp2px(10));
|
|
||||||
int p = dp2px(15);
|
|
||||||
searchArea.setPadding(p, p, p, p);
|
|
||||||
|
|
||||||
endInput = new EditText(context);
|
|
||||||
endInput.setHint("请输入目的地,不输入则自动匹配推荐加氢站");
|
|
||||||
endInput.setTextSize(13);
|
|
||||||
endInput.setHintTextColor(Color.LTGRAY);
|
|
||||||
endInput.setPadding(dp2px(12), dp2px(12), dp2px(12), dp2px(12));
|
|
||||||
endInput.setBackground(getRoundedDrawable(Color.parseColor("#F8F8F8"), 8));
|
|
||||||
endInput.setSingleLine(true);
|
|
||||||
endInput.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
|
|
||||||
endInput.addTextChangedListener(new TextWatcher() {
|
|
||||||
@Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
|
||||||
@Override public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
||||||
if (s.length() > 1) {
|
|
||||||
InputtipsQuery query = new InputtipsQuery(s.toString(), "");
|
|
||||||
query.setCityLimit(true);
|
|
||||||
Inputtips inputtips = new Inputtips(mContext, query);
|
|
||||||
inputtips.setInputtipsListener(NativeMapView.this);
|
|
||||||
inputtips.requestInputtipsAsyn();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override public void afterTextChanged(Editable s) {}
|
|
||||||
});
|
|
||||||
searchArea.addView(endInput);
|
|
||||||
|
|
||||||
View vSpace = new View(context);
|
|
||||||
searchArea.addView(vSpace, new LinearLayout.LayoutParams(1, dp2px(12)));
|
|
||||||
|
|
||||||
Button planBtn = new Button(context);
|
|
||||||
planBtn.setText("规划路线");
|
|
||||||
planBtn.setTextColor(Color.WHITE);
|
|
||||||
planBtn.setTypeface(Typeface.DEFAULT_BOLD);
|
|
||||||
planBtn.setBackground(getRoundedDrawable(Color.parseColor("#017143"), 10));
|
|
||||||
planBtn.setOnClickListener(v -> calculateRouteBeforeNavi());
|
|
||||||
searchArea.addView(planBtn, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp2px(48)));
|
|
||||||
|
|
||||||
bottomContainer.addView(searchArea);
|
|
||||||
|
|
||||||
// 设置统一的底部间距
|
|
||||||
FrameLayout.LayoutParams bottomParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
||||||
bottomParams.gravity = Gravity.BOTTOM;
|
|
||||||
bottomParams.setMargins(dp2px(12), 0, dp2px(12), dp2px(65));
|
|
||||||
container.addView(bottomContainer, bottomParams);
|
|
||||||
|
|
||||||
// --- 右下角定位按钮 ---
|
|
||||||
ImageButton locBtn = new ImageButton(context);
|
|
||||||
locBtn.setImageResource(android.R.drawable.ic_menu_mylocation);
|
|
||||||
locBtn.setBackground(getRoundedDrawable(Color.WHITE, 25));
|
|
||||||
locBtn.setElevation(dp2px(4));
|
|
||||||
locBtn.setOnClickListener(v -> {
|
|
||||||
if (currentLatLng != null) aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(currentLatLng, 15f));
|
|
||||||
});
|
|
||||||
FrameLayout.LayoutParams locParams = new FrameLayout.LayoutParams(dp2px(44), dp2px(44));
|
|
||||||
locParams.setMargins(0, 0, dp2px(15), dp2px(250)); // 调高一点,避开底部的面板
|
|
||||||
locParams.gravity = Gravity.BOTTOM | Gravity.END;
|
|
||||||
container.addView(locBtn, locParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
private LinearLayout createDetailPanel(Context context) {
|
|
||||||
LinearLayout panel = new LinearLayout(context);
|
|
||||||
panel.setOrientation(LinearLayout.VERTICAL);
|
|
||||||
panel.setBackground(getRoundedDrawable(Color.WHITE, 16));
|
|
||||||
panel.setPadding(dp2px(20), dp2px(20), dp2px(20), dp2px(20));
|
|
||||||
panel.setElevation(dp2px(12));
|
|
||||||
|
|
||||||
tvStationName = new TextView(context);
|
|
||||||
tvStationName.setTextSize(18);
|
|
||||||
tvStationName.setTextColor(Color.BLACK);
|
|
||||||
tvStationName.setTypeface(Typeface.DEFAULT_BOLD);
|
|
||||||
panel.addView(tvStationName);
|
|
||||||
|
|
||||||
tvStationAddr = new TextView(context);
|
|
||||||
tvStationAddr.setTextSize(13);
|
|
||||||
tvStationAddr.setPadding(0, dp2px(4), 0, dp2px(10));
|
|
||||||
tvStationAddr.setTextColor(Color.GRAY);
|
|
||||||
panel.addView(tvStationAddr);
|
|
||||||
|
|
||||||
tvRouteInfo = new TextView(context);
|
|
||||||
tvRouteInfo.setTextSize(14);
|
|
||||||
tvRouteInfo.setTextColor(Color.parseColor("#333333"));
|
|
||||||
panel.addView(tvRouteInfo);
|
|
||||||
|
|
||||||
Button startNaviBtn = new Button(context);
|
|
||||||
startNaviBtn.setText("开始导航");
|
|
||||||
startNaviBtn.setTextColor(Color.WHITE);
|
|
||||||
startNaviBtn.setBackground(getRoundedDrawable(Color.parseColor("#017143"), 10));
|
|
||||||
startNaviBtn.setOnClickListener(v -> startRouteSearch());
|
|
||||||
|
|
||||||
LinearLayout.LayoutParams btnParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp2px(48));
|
|
||||||
btnParams.topMargin = dp2px(15);
|
|
||||||
panel.addView(startNaviBtn, btnParams);
|
|
||||||
|
|
||||||
return panel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void calculateRouteBeforeNavi() {
|
|
||||||
if (startPoint == null) {
|
|
||||||
Toast.makeText(mContext, "正在定位...", Toast.LENGTH_SHORT).show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (endPoint == null) {
|
|
||||||
Toast.makeText(mContext, "请先选择目的地", Toast.LENGTH_SHORT).show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 开始规划前隐藏输入框面板
|
|
||||||
searchArea.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
RouteSearch.FromAndTo fromAndTo = new RouteSearch.FromAndTo(
|
|
||||||
new LatLonPoint(startPoint.latitude, startPoint.longitude),
|
|
||||||
new LatLonPoint(endPoint.latitude, endPoint.longitude));
|
|
||||||
RouteSearch.DriveRouteQuery query = new RouteSearch.DriveRouteQuery(fromAndTo, RouteSearch.DRIVING_SINGLE_DEFAULT, null, null, "");
|
|
||||||
routeSearch.calculateDriveRouteAsyn(query);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onGetInputtips(List<Tip> tipList, int rCode) {
|
|
||||||
if (rCode == 1000 && tipList != null && !tipList.isEmpty()) {
|
|
||||||
Tip tip = tipList.get(0);
|
|
||||||
if (tip.getPoint() != null) {
|
|
||||||
endPoint = new LatLng(tip.getPoint().getLatitude(), tip.getPoint().getLongitude());
|
|
||||||
endName = tip.getName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDriveRouteSearched(DriveRouteResult result, int rCode) {
|
|
||||||
if (rCode == AMapException.CODE_AMAP_SUCCESS && result != null && !result.getPaths().isEmpty()) {
|
|
||||||
DrivePath path = result.getPaths().get(0);
|
|
||||||
|
|
||||||
// 规划成功,显示详情面板
|
|
||||||
detailPanel.setVisibility(View.VISIBLE);
|
|
||||||
tvStationName.setText(endName);
|
|
||||||
tvStationAddr.setText(endInput.getText().toString());
|
|
||||||
|
|
||||||
String info = String.format("预计时间:%d分钟 | 行驶里程:%.1f公里 | 预计路费:%.0f元",
|
|
||||||
path.getDuration() / 60, path.getDistance() / 1000f, path.getTolls());
|
|
||||||
tvRouteInfo.setText(info);
|
|
||||||
|
|
||||||
aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(endPoint, 13f));
|
|
||||||
} else {
|
|
||||||
// 规划失败回退面板
|
|
||||||
searchArea.setVisibility(View.VISIBLE);
|
|
||||||
Toast.makeText(mContext, "路径规划失败: " + rCode, Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startRouteSearch() {
|
|
||||||
if (mActivity == null || startPoint == null || endPoint == null) return;
|
|
||||||
|
|
||||||
Poi start = new Poi(startName, startPoint, "");
|
|
||||||
Poi end = new Poi(endName, endPoint, "");
|
|
||||||
AmapNaviParams params = new AmapNaviParams(start, null, end, AmapNaviType.DRIVER, AmapPageType.ROUTE);
|
|
||||||
|
|
||||||
try {
|
|
||||||
AMapNavi mAMapNavi = AMapNavi.getInstance(mContext);
|
|
||||||
AMapCarInfo carInfo = new AMapCarInfo();
|
|
||||||
carInfo.setCarNumber("沪AGK2267");
|
|
||||||
carInfo.setCarType("1");
|
|
||||||
mAMapNavi.setCarInfo(carInfo);
|
|
||||||
} catch (Exception e) { e.printStackTrace(); }
|
|
||||||
|
|
||||||
AmapNaviPage.getInstance().showRouteActivity(mActivity, params, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupMapUi() {
|
|
||||||
aMap.setLocationSource(this);
|
|
||||||
aMap.setMyLocationEnabled(true);
|
|
||||||
aMap.setOnMarkerClickListener(this);
|
|
||||||
|
|
||||||
MyLocationStyle myLocationStyle = new MyLocationStyle();
|
|
||||||
try {
|
|
||||||
Bitmap carBitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.car);
|
|
||||||
if (carBitmap != null) {
|
|
||||||
Bitmap scaledBitmap = Bitmap.createScaledBitmap(carBitmap, dp2px(30), dp2px(30), true);
|
|
||||||
myLocationStyle.myLocationIcon(BitmapDescriptorFactory.fromBitmap(scaledBitmap));
|
|
||||||
}
|
|
||||||
} catch (Exception e) { e.printStackTrace(); }
|
|
||||||
|
|
||||||
myLocationStyle.anchor(0.5f, 0.5f);
|
|
||||||
myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER);
|
|
||||||
aMap.setMyLocationStyle(myLocationStyle);
|
|
||||||
aMap.getUiSettings().setZoomControlsEnabled(false);
|
|
||||||
aMap.getUiSettings().setLogoPosition(AMapOptions.LOGO_POSITION_BOTTOM_LEFT);
|
|
||||||
}
|
|
||||||
|
|
||||||
private GradientDrawable getRoundedDrawable(int color, int radiusDp) {
|
|
||||||
GradientDrawable shape = new GradientDrawable();
|
|
||||||
shape.setShape(GradientDrawable.RECTANGLE);
|
|
||||||
shape.setCornerRadius(dp2px(radiusDp));
|
|
||||||
shape.setColor(color);
|
|
||||||
return shape;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int dp2px(float dp) {
|
|
||||||
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, mContext.getResources().getDisplayMetrics());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void activate(OnLocationChangedListener listener) { mListener = listener; startLocation(); }
|
|
||||||
@Override public void deactivate() { mListener = null; if (mlocationClient != null) mlocationClient.stopLocation(); }
|
|
||||||
|
|
||||||
public void startLocation() {
|
|
||||||
if (mlocationClient == null) {
|
|
||||||
try {
|
|
||||||
mlocationClient = new AMapLocationClient(mContext);
|
|
||||||
AMapLocationClientOption option = new AMapLocationClientOption();
|
|
||||||
mlocationClient.setLocationListener(this);
|
|
||||||
option.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
|
|
||||||
mlocationClient.setLocationOption(option);
|
|
||||||
mlocationClient.startLocation();
|
|
||||||
} catch (Exception e) { e.printStackTrace(); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLocationChanged(AMapLocation loc) {
|
|
||||||
if (loc != null && loc.getErrorCode() == 0) {
|
|
||||||
currentLatLng = new LatLng(loc.getLatitude(), loc.getLongitude());
|
|
||||||
if (mListener != null) mListener.onLocationChanged(loc);
|
|
||||||
if (isFirstLocation) {
|
|
||||||
isFirstLocation = false;
|
|
||||||
startPoint = currentLatLng;
|
|
||||||
aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(currentLatLng, 14f));
|
|
||||||
getAddressByLatlng(currentLatLng);
|
|
||||||
fetchRecommendStation(loc);
|
|
||||||
fetchNearbyStations(loc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void getAddressByLatlng(LatLng latLng) {
|
|
||||||
geocoderSearch.getFromLocationAsyn(new RegeocodeQuery(new LatLonPoint(latLng.latitude, latLng.longitude), 200, GeocodeSearch.AMAP));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRegeocodeSearched(RegeocodeResult result, int rCode) {
|
|
||||||
if (rCode == 1000 && result != null) {
|
|
||||||
RegeocodeAddress addr = result.getRegeocodeAddress();
|
|
||||||
startName = addr.getStreetNumber() != null ? addr.getStreetNumber().getStreet() : addr.getDistrict();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fetchRecommendStation(AMapLocation loc) {
|
|
||||||
try {
|
|
||||||
JSONObject json = new JSONObject();
|
|
||||||
json.put("province", loc.getProvince());
|
|
||||||
json.put("city", loc.getCity().isEmpty() ? loc.getProvince() : loc.getCity());
|
|
||||||
json.put("longitude", loc.getLongitude());
|
|
||||||
json.put("latitude", loc.getLatitude());
|
|
||||||
|
|
||||||
httpClient.newCall(new Request.Builder().url("https://beta-esg.api.lnh2e.com/appointment/station/getStationInfoByArea").post(RequestBody.create(json.toString(), MediaType.parse("application/json"))).build()).enqueue(new Callback() {
|
|
||||||
@Override public void onFailure(@NonNull Call call, @NonNull IOException e) {}
|
|
||||||
@Override public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
|
|
||||||
if (response.isSuccessful() && response.body() != null) {
|
|
||||||
try {
|
|
||||||
JSONObject res = new JSONObject(response.body().string());
|
|
||||||
if (res.getInt("code") == 0 && !res.isNull("data")) {
|
|
||||||
JSONObject data = res.getJSONObject("data");
|
|
||||||
endPoint = new LatLng(data.getDouble("latitude"), data.getDouble("longitude"));
|
|
||||||
endName = data.getString("name");
|
|
||||||
String addr = data.optString("address", "");
|
|
||||||
new Handler(Looper.getMainLooper()).post(() -> {
|
|
||||||
endInput.setText(addr);
|
|
||||||
markStation(endPoint, endName, true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (Exception e) { e.printStackTrace(); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (Exception e) { e.printStackTrace(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fetchNearbyStations(AMapLocation loc) {
|
|
||||||
try {
|
|
||||||
JSONObject json = new JSONObject();
|
|
||||||
json.put("longitude", loc.getLongitude());
|
|
||||||
json.put("latitude", loc.getLatitude());
|
|
||||||
|
|
||||||
httpClient.newCall(new Request.Builder().url("https://beta-esg.api.lnh2e.com/appointment/station/getNearbyHydrogenStationsByLocation").post(RequestBody.create(json.toString(), MediaType.parse("application/json"))).build()).enqueue(new Callback() {
|
|
||||||
@Override public void onFailure(@NonNull Call call, @NonNull IOException e) {}
|
|
||||||
@Override public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
|
|
||||||
if (response.isSuccessful() && response.body() != null) {
|
|
||||||
try {
|
|
||||||
JSONObject res = new JSONObject(response.body().string());
|
|
||||||
JSONArray array = res.getJSONArray("data");
|
|
||||||
new Handler(Looper.getMainLooper()).post(() -> {
|
|
||||||
for (int i = 0; i < array.length(); i++) {
|
|
||||||
try {
|
|
||||||
JSONObject item = array.getJSONObject(i);
|
|
||||||
markStation(new LatLng(item.getDouble("latitude"), item.getDouble("longitude")), item.getString("name"), false);
|
|
||||||
} catch (Exception ignored) {}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (Exception e) { e.printStackTrace(); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (Exception e) { e.printStackTrace(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
private void markStation(LatLng latLng, String name, boolean isRecommend) {
|
|
||||||
Marker m = aMap.addMarker(new MarkerOptions().position(latLng).title(name).icon(BitmapDescriptorFactory.defaultMarker(isRecommend ? BitmapDescriptorFactory.HUE_RED : BitmapDescriptorFactory.HUE_GREEN)));
|
|
||||||
m.setObject(latLng);
|
|
||||||
stationMarkers.add(m);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onMarkerClick(Marker marker) {
|
|
||||||
if (marker.getObject() instanceof LatLng) {
|
|
||||||
endPoint = (LatLng) marker.getObject();
|
|
||||||
endName = marker.getTitle();
|
|
||||||
endInput.setText(endName);
|
|
||||||
calculateRouteBeforeNavi();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void onGeocodeSearched(GeocodeResult r, int c) {}
|
|
||||||
@Override public void onBusRouteSearched(BusRouteResult r, int c) {}
|
|
||||||
@Override public void onWalkRouteSearched(WalkRouteResult r, int c) {}
|
|
||||||
@Override public void onRideRouteSearched(RideRouteResult r, int c) {}
|
|
||||||
|
|
||||||
private Activity getActivityFromContext(Context context) {
|
|
||||||
if (context instanceof Activity) return (Activity) context;
|
|
||||||
if (context instanceof android.content.ContextWrapper) return getActivityFromContext(((android.content.ContextWrapper) context).getBaseContext());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onResume() { mapView.onResume(); }
|
|
||||||
public void onPause() { mapView.onPause(); }
|
|
||||||
public void onSaveInstanceState(Bundle out) { mapView.onSaveInstanceState(out); }
|
|
||||||
@Override public View getView() { return container; }
|
|
||||||
@Override public void dispose() {
|
|
||||||
if (mlocationClient != null) { mlocationClient.stopLocation(); mlocationClient.onDestroy(); }
|
|
||||||
mapView.onDestroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 3.4 KiB |
BIN
ln_jq_app/android/app/src/main/res/mipmap-xhdpi/logo.jpg
Normal file
|
After Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 112 KiB After Width: | Height: | Size: 545 KiB |
@@ -1,50 +0,0 @@
|
|||||||
#
|
|
||||||
# Be sure to run `pod lib lint AMapNavIOSSDK.podspec' to ensure this is a
|
|
||||||
# valid spec before submitting.
|
|
||||||
#
|
|
||||||
# Any lines starting with a # are optional, but their use is encouraged
|
|
||||||
# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
|
|
||||||
#
|
|
||||||
|
|
||||||
Pod::Spec.new do |s|
|
|
||||||
s.name = 'AMapNavIOSSDK'
|
|
||||||
s.version = '0.1.0'
|
|
||||||
s.summary = 'A short description of AMapNavIOSSDK.'
|
|
||||||
|
|
||||||
# This description is used to generate tags and improve search results.
|
|
||||||
# * Think: What does it do? Why did you write it? What is the focus?
|
|
||||||
# * Try to keep it short, snappy and to the point.
|
|
||||||
# * Write the description between the DESC delimiters below.
|
|
||||||
# * Finally, don't worry about the indent, CocoaPods strips it!
|
|
||||||
|
|
||||||
s.description = <<-DESC
|
|
||||||
TODO: Add long description of the pod here.
|
|
||||||
DESC
|
|
||||||
|
|
||||||
s.homepage = 'https://github.com/xiaoshuai/AMapNavIOSSDK'
|
|
||||||
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
|
|
||||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
|
||||||
s.author = { 'xiaoshuai' => 'xiaoshuai@net.cn' }
|
|
||||||
s.source = { :git => 'https://github.com/xiaoshuai/AMapNavIOSSDK.git', :tag => s.version.to_s }
|
|
||||||
# s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
|
|
||||||
|
|
||||||
s.ios.deployment_target = '12.0'
|
|
||||||
|
|
||||||
s.source_files = 'AMapNavIOSSDK/Classes/**/*'
|
|
||||||
s.resource = 'AMapNavIOSSDK/**/*.bundle'
|
|
||||||
s.resource_bundles = {
|
|
||||||
'AMapNavIOSSDKPrivacyInfo' => ['AMapNavIOSSDK/**/PrivacyInfo.xcprivacy']
|
|
||||||
}
|
|
||||||
|
|
||||||
# s.public_header_files = 'Pod/Classes/**/*.h'
|
|
||||||
# s.frameworks = 'UIKit', 'MapKit'
|
|
||||||
# s.dependency 'AFNetworking', '~> 2.3'
|
|
||||||
|
|
||||||
s.dependency 'Masonry'
|
|
||||||
s.dependency 'MJExtension'
|
|
||||||
|
|
||||||
s.dependency 'AMapNavi-NO-IDFA'
|
|
||||||
s.dependency 'AMapLocation-NO-IDFA'
|
|
||||||
s.dependency 'AMapSearch-NO-IDFA'
|
|
||||||
|
|
||||||
end
|
|
||||||
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 840 B |
@@ -1,31 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
||||||
<plist version="1.0">
|
|
||||||
<dict>
|
|
||||||
<key>NSPrivacyTracking</key>
|
|
||||||
<false/>
|
|
||||||
<key>NSPrivacyTrackingDomains</key>
|
|
||||||
<array/>
|
|
||||||
<key>NSPrivacyAccessedAPITypes</key>
|
|
||||||
<array>
|
|
||||||
<dict>
|
|
||||||
<key>NSPrivacyAccessedAPIType</key>
|
|
||||||
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
|
|
||||||
<key>NSPrivacyAccessedAPITypeReasons</key>
|
|
||||||
<array>
|
|
||||||
<string>0A2A.1</string>
|
|
||||||
</array>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>NSPrivacyAccessedAPIType</key>
|
|
||||||
<string>NSPrivacyAccessedAPICategoryDiskSpace</string>
|
|
||||||
<key>NSPrivacyAccessedAPITypeReasons</key>
|
|
||||||
<array>
|
|
||||||
<string>85F4.1</string>
|
|
||||||
</array>
|
|
||||||
</dict>
|
|
||||||
</array>
|
|
||||||
<key>NSPrivacyCollectedDataTypes</key>
|
|
||||||
<array/>
|
|
||||||
</dict>
|
|
||||||
</plist>
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
//
|
|
||||||
// ABaseViewController.h
|
|
||||||
// ANavDemo
|
|
||||||
//
|
|
||||||
// Created by admin on 2026/2/5.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
#import <Masonry/Masonry.h>
|
|
||||||
#import "AMapNavCommonUtil.h"
|
|
||||||
|
|
||||||
#define kRoutePlanBarHeight (self.navigationController.navigationBar.frame.size.height + UIApplication.sharedApplication.statusBarFrame.size.height + 0)
|
|
||||||
|
|
||||||
#define kRoutePlanStatusBarHeight (UIApplication.sharedApplication.statusBarFrame.size.height + 0)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
|
||||||
|
|
||||||
@interface ABaseViewController : UIViewController
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
//
|
|
||||||
// ABaseViewController.m
|
|
||||||
// ANavDemo
|
|
||||||
//
|
|
||||||
// Created by admin on 2026/2/5.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import "ABaseViewController.h"
|
|
||||||
|
|
||||||
@interface ABaseViewController ()
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation ABaseViewController
|
|
||||||
|
|
||||||
- (void)viewDidLoad {
|
|
||||||
[super viewDidLoad];
|
|
||||||
// Do any additional setup after loading the view.
|
|
||||||
|
|
||||||
self.view.backgroundColor = [UIColor whiteColor];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
#pragma mark - Navigation
|
|
||||||
|
|
||||||
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
|
||||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
|
||||||
// Get the new view controller using [segue destinationViewController].
|
|
||||||
// Pass the selected object to the new view controller.
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
//
|
|
||||||
// AMapHyStationModel.h
|
|
||||||
// AMapNavIOSSDK
|
|
||||||
//
|
|
||||||
// Created by admin on 2026/2/11.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
#import <MJExtension/MJExtension.h>
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
|
||||||
|
|
||||||
/**
|
|
||||||
{
|
|
||||||
"name": "嘉兴经开站",
|
|
||||||
"shortName": null,
|
|
||||||
"siteNo": null,
|
|
||||||
"city": null,
|
|
||||||
"address": "嘉兴市秀洲区岗山路272号",
|
|
||||||
"contact": "龚明伟",
|
|
||||||
"phone": "18888888888",
|
|
||||||
"type": null,
|
|
||||||
"coOpMode": null,
|
|
||||||
"booking": null,
|
|
||||||
"siteStatus": 0,
|
|
||||||
"startBusiness": "06:00:00",
|
|
||||||
"endBusiness": "22:00:00",
|
|
||||||
"billingMethod": null,
|
|
||||||
"term": null,
|
|
||||||
"remark": null,
|
|
||||||
"longitude": "120.75972800",
|
|
||||||
"latitude": "30.79962800"
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
@interface AMapHyStationModel : NSObject
|
|
||||||
|
|
||||||
@property (nonatomic, copy) NSString *name;
|
|
||||||
@property (nonatomic, copy, nullable) NSString *shortName;
|
|
||||||
@property (nonatomic, copy, nullable) NSString *siteNo;
|
|
||||||
@property (nonatomic, copy, nullable) NSString *city;
|
|
||||||
@property (nonatomic, copy, nullable) NSString *address;
|
|
||||||
@property (nonatomic, copy, nullable) NSString *contact;
|
|
||||||
@property (nonatomic, copy, nullable) NSString *phone;
|
|
||||||
@property (nonatomic, copy, nullable) NSString *type;
|
|
||||||
@property (nonatomic, copy, nullable) NSString *coOpMode;
|
|
||||||
@property (nonatomic, strong, nullable) NSString * booking;
|
|
||||||
@property (nonatomic, assign) NSInteger siteStatus;
|
|
||||||
@property (nonatomic, copy, nullable) NSString *startBusiness;
|
|
||||||
@property (nonatomic, copy, nullable) NSString *endBusiness;
|
|
||||||
@property (nonatomic, copy, nullable) NSString *billingMethod;
|
|
||||||
@property (nonatomic, copy, nullable) NSString *term;
|
|
||||||
@property (nonatomic, copy, nullable) NSString *remark;
|
|
||||||
@property (nonatomic, copy, nullable) NSString *longitude;
|
|
||||||
@property (nonatomic, copy, nullable) NSString *latitude;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
/**
|
|
||||||
{
|
|
||||||
"code": 0,
|
|
||||||
"status": true,
|
|
||||||
"message": "success",
|
|
||||||
"data": [],
|
|
||||||
"time": "1770800256408",
|
|
||||||
"error": null
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
@interface AMapHyResponse : NSObject
|
|
||||||
@property (nonatomic, assign) NSInteger code;
|
|
||||||
@property (nonatomic, assign) NSInteger status;
|
|
||||||
@property (nonatomic, copy, nullable) NSString *message;
|
|
||||||
@property (nonatomic, copy, nullable) NSString *time;
|
|
||||||
@property (nonatomic, copy, nullable) NSString *error;
|
|
||||||
|
|
||||||
@property(nonatomic , strong)NSArray <AMapHyStationModel * > * data;
|
|
||||||
|
|
||||||
@end
|
|
||||||
NS_ASSUME_NONNULL_END
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
//
|
|
||||||
// AMapHyStationModel.m
|
|
||||||
// AMapNavIOSSDK
|
|
||||||
//
|
|
||||||
// Created by admin on 2026/2/11.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import "AMapHyStationModel.h"
|
|
||||||
|
|
||||||
@implementation AMapHyStationModel
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
|
|
||||||
@implementation AMapHyResponse
|
|
||||||
|
|
||||||
+ (NSDictionary *)mj_objectClassInArray {
|
|
||||||
return @{@"data" : AMapHyStationModel.class};
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
//
|
|
||||||
// AMapNavSDKHeader.h
|
|
||||||
// Pods
|
|
||||||
//
|
|
||||||
// Created by admin on 2026/2/10.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef AMapNavSDKHeader_h
|
|
||||||
#define AMapNavSDKHeader_h
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* AMapNavSDKHeader_h */
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
//
|
|
||||||
// AMapNavSDKManager.h
|
|
||||||
// Pods
|
|
||||||
//
|
|
||||||
// Created by admin on 2026/2/10.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
|
|
||||||
#import "ARoutePlaneController.h"
|
|
||||||
|
|
||||||
#define kAMapSDKDebugFlag
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
|
||||||
|
|
||||||
@interface AMapNavSDKManager : NSObject
|
|
||||||
|
|
||||||
@property (strong, nonatomic) UIWindow *window;
|
|
||||||
|
|
||||||
@property (nonatomic , strong) NSString * localCity;
|
|
||||||
@property (nonatomic, copy) NSString * locationAddressDetail;
|
|
||||||
|
|
||||||
@property (nonatomic , strong , readonly) UIViewController * targetVC;
|
|
||||||
|
|
||||||
+ (instancetype)sharedManager;
|
|
||||||
- (void)configWithKey:(NSString*)key;
|
|
||||||
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
//
|
|
||||||
// AMapNavSDKManager.m
|
|
||||||
// Pods
|
|
||||||
//
|
|
||||||
// Created by admin on 2026/2/10.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import "AMapNavSDKManager.h"
|
|
||||||
#import "AMapPrivacyUtility.h"
|
|
||||||
|
|
||||||
#import <AMapFoundationKit/AMapFoundationKit.h>
|
|
||||||
|
|
||||||
@interface AMapNavSDKManager ()
|
|
||||||
@property (nonatomic , strong , readwrite) UIViewController * targetVC;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation AMapNavSDKManager
|
|
||||||
|
|
||||||
+ (instancetype)sharedManager {
|
|
||||||
static AMapNavSDKManager *manager = nil;
|
|
||||||
static dispatch_once_t onceToken;
|
|
||||||
dispatch_once(&onceToken, ^{
|
|
||||||
manager = [[AMapNavSDKManager alloc] init];
|
|
||||||
});
|
|
||||||
return manager;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (instancetype)init {
|
|
||||||
self = [super init];
|
|
||||||
if (self) {
|
|
||||||
_targetVC = [ARoutePlaneController new];
|
|
||||||
}
|
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- (void)configWithKey:(NSString*)key {
|
|
||||||
if (1) {
|
|
||||||
/*
|
|
||||||
* 调用隐私合规处理方法
|
|
||||||
*/
|
|
||||||
// [AMapPrivacyUtility handlePrivacyAgreeStatusIn:_targetVC];
|
|
||||||
//
|
|
||||||
// 初始化高德导航SDK
|
|
||||||
[self configureAPIKey:key];
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (UIViewController *)targetVC {
|
|
||||||
return _targetVC;
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - private
|
|
||||||
- (void)configureAPIKey:(NSString*)key {
|
|
||||||
if ([key length] == 0)
|
|
||||||
{
|
|
||||||
NSString *reason = [NSString stringWithFormat:@"apiKey为空,请检查key是否正确设置。"];
|
|
||||||
|
|
||||||
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:reason delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
|
|
||||||
|
|
||||||
[alert show];
|
|
||||||
}
|
|
||||||
[AMapServices sharedServices].enableHTTPS = YES;
|
|
||||||
[AMapServices sharedServices].apiKey = (NSString *)key;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
//
|
|
||||||
// ARoutePlaneController.h
|
|
||||||
// ANavDemo
|
|
||||||
//
|
|
||||||
// Created by admin on 2026/2/5.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
#import "ABaseViewController.h"
|
|
||||||
|
|
||||||
#import "SelectableOverlay.h"
|
|
||||||
#import "NaviPointAnnotation.h"
|
|
||||||
|
|
||||||
#import <AMapNaviKit/AMapNaviKit.h>
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
|
||||||
|
|
||||||
@interface ARoutePlaneController : ABaseViewController
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
|
||||||
@@ -1,930 +0,0 @@
|
|||||||
//
|
|
||||||
// ARoutePlaneController.m
|
|
||||||
// ANavDemo
|
|
||||||
//
|
|
||||||
// Created by admin on 2026/2/5.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import "ARoutePlaneController.h"
|
|
||||||
|
|
||||||
#import <AMapNaviKit/MAMapKit.h>
|
|
||||||
#import <AMapNaviKit/AMapNaviKit.h>
|
|
||||||
#import <AMapLocationKit/AMapLocationKit.h>
|
|
||||||
#import <AMapSearchKit/AMapSearchAPI.h>
|
|
||||||
|
|
||||||
#import "ASearchAddressController.h"
|
|
||||||
|
|
||||||
#import "AMapNavSDKManager.h"
|
|
||||||
|
|
||||||
#import "AMapPrivacyUtility.h"
|
|
||||||
|
|
||||||
#define kRouteIndicatorViewHeight 64.f
|
|
||||||
|
|
||||||
#import "AMapHyStationModel.h"
|
|
||||||
#import "AMapNavHttpUtil.h"
|
|
||||||
|
|
||||||
@interface ARoutePlaneController ()<MAMapViewDelegate, AMapNaviDriveManagerDelegate,AMapNaviCompositeManagerDelegate , AMapLocationManagerDelegate , UITextFieldDelegate >
|
|
||||||
@property (nonatomic, strong) UITextField *textField;
|
|
||||||
|
|
||||||
@property (nonatomic, strong) MAMapView *mapView;
|
|
||||||
@property (nonatomic,strong) AMapLocationManager *locationService; //定位服务
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 经纬度
|
|
||||||
*/
|
|
||||||
@property (nonatomic, assign) double latitude;
|
|
||||||
@property (nonatomic, assign) double longitude;
|
|
||||||
|
|
||||||
|
|
||||||
@property (nonatomic, strong) UITextField *startTf;
|
|
||||||
@property (nonatomic, strong) UITextField *dstTf;
|
|
||||||
@property (nonatomic, strong) UIButton *navBtn;
|
|
||||||
|
|
||||||
@property (nonatomic, strong) AMapPOI *startPoi;
|
|
||||||
@property (nonatomic, strong) AMapPOI *dstPoi;
|
|
||||||
|
|
||||||
@property (nonatomic, strong) AMapNaviCompositeManager *compositeManager;//nav
|
|
||||||
@property (nonatomic, assign) BOOL calRouteSuccess;
|
|
||||||
|
|
||||||
@property (nonatomic, strong) NSDictionary * currentCalRoutePaths;//当前规划的路线
|
|
||||||
@property (nonatomic , assign)BOOL isStartNav;//开始导航
|
|
||||||
@property (nonatomic, strong) NSArray * lastOverLays;
|
|
||||||
|
|
||||||
|
|
||||||
@property (nonatomic , strong)NSArray * hyStationArr;//站点数据
|
|
||||||
@property (nonatomic , assign)BOOL startQueryCurrnetNodeFlag;//开始查询当前节点;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation ARoutePlaneController
|
|
||||||
|
|
||||||
- (void)viewDidLoad {
|
|
||||||
[super viewDidLoad];
|
|
||||||
_startQueryCurrnetNodeFlag = NO;
|
|
||||||
|
|
||||||
[self observePrivacyStatus];
|
|
||||||
[self checkPrivacyStatus];
|
|
||||||
|
|
||||||
////
|
|
||||||
// [self.naviManager independentCalculateDriveRouteWithStartPOIInfo:startPOIInfo
|
|
||||||
// endPOIInfo:endPOIInfo
|
|
||||||
// wayPOIInfos:wayPOIInfos
|
|
||||||
// strategy:AMapNaviDrivingStrategyMultipleDefault
|
|
||||||
// callback:^(AMapNaviRouteGroup *routeGroup, NSError *error) {
|
|
||||||
// if (error == nil) {
|
|
||||||
// // 算路成功,routeGroup 包含路线数据
|
|
||||||
// [self startNaviWithRoute:routeGroup];
|
|
||||||
// }
|
|
||||||
// }];
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)viewDidAppear:(BOOL)animated {
|
|
||||||
[super viewDidAppear:animated];
|
|
||||||
|
|
||||||
|
|
||||||
[AMapPrivacyUtility handlePrivacyAgreeStatusIn:self];
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - request
|
|
||||||
-(void)requestHyListWithParms:(NSDictionary*)dic {
|
|
||||||
NSString * url = @"https://beta-esg.api.lnh2e.com/appointment/station/getNearbyHydrogenStationsByLocation";
|
|
||||||
|
|
||||||
/**
|
|
||||||
//汽车公园有数据
|
|
||||||
"longitude": "121.30461400",
|
|
||||||
"latitude": "31.17321100"
|
|
||||||
*/
|
|
||||||
// NSDictionary * dic = @{@"longitude":@"121.16661700" , @"latitude":@"31.27981600"};
|
|
||||||
|
|
||||||
|
|
||||||
[AMapNavHttpUtil postRequestWithURL:url parameters:dic requestHeader:@{@"Content-Type":@"application/json; charset=UTF-8"} successHandler:^(NSDictionary * _Nonnull data, NSURLResponse * _Nonnull response) {
|
|
||||||
AMapHyResponse * resp = [AMapHyResponse mj_objectWithKeyValues:data];
|
|
||||||
if (resp.code == 0 && resp.data) {
|
|
||||||
NSArray * allData = resp.data;
|
|
||||||
NSArray * dst = allData;
|
|
||||||
NSInteger len = allData.count;
|
|
||||||
if (allData.count > len) {
|
|
||||||
dst = [resp.data subarrayWithRange:NSMakeRange(0, len)];
|
|
||||||
}
|
|
||||||
|
|
||||||
[self updateMapAnnotationWithData:dst];
|
|
||||||
}else {
|
|
||||||
NSLog(@">>>>>>>请求站点:%@" ,resp.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
} failureHandler:^(NSError * _Nonnull error) {
|
|
||||||
NSLog(@">>>>>>>请求站点err:%@" ,error.debugDescription);
|
|
||||||
}];
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)requestHyDetailWithParms:(NSDictionary*)dic {
|
|
||||||
NSString * url = @"https://beta-esg.api.lnh2e.com/appointment/station/getStationInfoByArea";
|
|
||||||
|
|
||||||
[AMapNavHttpUtil postRequestWithURL:url parameters:dic requestHeader:@{@"Content-Type":@"application/json; charset=UTF-8"} successHandler:^(NSDictionary * _Nonnull data, NSURLResponse * _Nonnull response) {
|
|
||||||
AMapHyResponse * resp = [AMapHyResponse mj_objectWithKeyValues:data];
|
|
||||||
if (resp.code == 0) {
|
|
||||||
NSDictionary * resData = data[@"data"];
|
|
||||||
AMapHyStationModel * station = [AMapHyStationModel mj_objectWithKeyValues:resData];
|
|
||||||
[self updateHeadAddressWithStation:station];
|
|
||||||
}else {
|
|
||||||
NSLog(@">>>>>>>请求站点detail:%@" ,resp.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
} failureHandler:^(NSError * _Nonnull error) {
|
|
||||||
NSLog(@">>>>>>>请求站点err:%@" ,error.debugDescription);
|
|
||||||
}];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
-(void)updateHeadAddressWithStation:(AMapHyStationModel*)model {
|
|
||||||
|
|
||||||
AMapPOI * aoi = [[AMapPOI alloc] init];
|
|
||||||
|
|
||||||
aoi.location = [AMapGeoPoint locationWithLatitude:[model.latitude doubleValue] longitude:[model.longitude doubleValue]];
|
|
||||||
|
|
||||||
aoi.name = model.name;
|
|
||||||
|
|
||||||
self.dstPoi = aoi;
|
|
||||||
|
|
||||||
///地址栏
|
|
||||||
[self updateUIWithData:aoi textField:self.dstTf];
|
|
||||||
|
|
||||||
|
|
||||||
///地图显示
|
|
||||||
[self updateMapAnnotationWithData:@[model]];
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)updateMapAnnotationWithData:(NSArray *)dataArr {
|
|
||||||
self.hyStationArr = dataArr;
|
|
||||||
if (!(dataArr && dataArr.count > 0)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
///添加标注
|
|
||||||
NSMutableArray * points = [NSMutableArray arrayWithCapacity:dataArr.count];
|
|
||||||
for (AMapHyStationModel * model in dataArr) {
|
|
||||||
MAPointAnnotation *pointAnnotation = [[MAPointAnnotation alloc] init];
|
|
||||||
if (!(model.latitude && model.longitude)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
pointAnnotation.coordinate = CLLocationCoordinate2DMake([model.latitude doubleValue], [model.longitude doubleValue]);
|
|
||||||
pointAnnotation.title = model.name;
|
|
||||||
[points addObject:pointAnnotation];
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1. 先获取当前地图区域
|
|
||||||
// MACoordinateRegion currentRegion = self.mapView.region;
|
|
||||||
|
|
||||||
// 2. 添加标注但不改变地图显示
|
|
||||||
[self.mapView addAnnotations:points];
|
|
||||||
|
|
||||||
// 保持地图中心点为当前位置
|
|
||||||
if (self.latitude && self.longitude) {
|
|
||||||
[self.mapView setCenterCoordinate: CLLocationCoordinate2DMake(self.latitude, self.longitude) animated:YES];
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. 保持当前区域不变
|
|
||||||
// [self.mapView setRegion:currentRegion animated:NO];
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark -
|
|
||||||
-(void)initSubview {
|
|
||||||
UITextField * startTf = [[UITextField alloc] init];
|
|
||||||
startTf.borderStyle = UITextBorderStyleRoundedRect;
|
|
||||||
startTf.placeholder = @"起点";
|
|
||||||
startTf.tag = 100;
|
|
||||||
startTf.delegate = self;
|
|
||||||
startTf.font = [UIFont systemFontOfSize:13];
|
|
||||||
[self.view addSubview:startTf];
|
|
||||||
|
|
||||||
[startTf mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
||||||
make.top.mas_equalTo(self.view).offset(kRoutePlanStatusBarHeight + 35);
|
|
||||||
make.left.mas_equalTo(self.view).offset(5);
|
|
||||||
make.width.mas_equalTo(@120);
|
|
||||||
make.height.mas_equalTo(@32);
|
|
||||||
}];
|
|
||||||
|
|
||||||
self.startTf = startTf;
|
|
||||||
|
|
||||||
UITextField * dstTf = [[UITextField alloc] init];
|
|
||||||
dstTf.borderStyle = UITextBorderStyleRoundedRect;
|
|
||||||
dstTf.placeholder = @"终点";
|
|
||||||
dstTf.tag = 200;
|
|
||||||
dstTf.delegate = self;
|
|
||||||
dstTf.font = [UIFont systemFontOfSize:13];
|
|
||||||
|
|
||||||
[self.view addSubview:dstTf];
|
|
||||||
|
|
||||||
[dstTf mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
||||||
make.centerY.mas_equalTo(startTf);
|
|
||||||
make.left.mas_equalTo(startTf.mas_right).offset(15);
|
|
||||||
// make.right.mas_equalTo(self.view).offset(-5);
|
|
||||||
make.width.height.mas_equalTo(startTf);
|
|
||||||
}];
|
|
||||||
self.dstTf = dstTf;
|
|
||||||
|
|
||||||
UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
||||||
[btn setTitle:@"规划线路" forState:UIControlStateNormal];
|
|
||||||
btn.backgroundColor = [UIColor whiteColor];
|
|
||||||
btn.titleLabel.font = [UIFont systemFontOfSize:14];
|
|
||||||
|
|
||||||
btn.layer.borderColor = [UIColor blueColor].CGColor;
|
|
||||||
btn.layer.borderWidth = 1;
|
|
||||||
btn.layer.cornerRadius = 5;
|
|
||||||
|
|
||||||
[btn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
|
|
||||||
[btn addTarget:self action:@selector(calRoutePath) forControlEvents:UIControlEventTouchUpInside];
|
|
||||||
[self.view addSubview:btn];
|
|
||||||
[btn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
||||||
make.left.equalTo(dstTf.mas_right).offset(12);
|
|
||||||
make.top.mas_equalTo(startTf);
|
|
||||||
make.right.mas_equalTo(self.view).offset(-5);
|
|
||||||
make.height.mas_equalTo(@30);
|
|
||||||
}];
|
|
||||||
|
|
||||||
|
|
||||||
UIButton * navBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
||||||
[navBtn setTitle:@"导航>" forState:UIControlStateNormal];
|
|
||||||
navBtn.backgroundColor = [UIColor whiteColor];
|
|
||||||
navBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
|
||||||
|
|
||||||
navBtn.layer.borderColor = [UIColor blueColor].CGColor;
|
|
||||||
navBtn.layer.borderWidth = 1;
|
|
||||||
navBtn.layer.cornerRadius = 6;
|
|
||||||
|
|
||||||
[navBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
|
|
||||||
[navBtn addTarget:self action:@selector(navAction) forControlEvents:UIControlEventTouchUpInside];
|
|
||||||
[self.view addSubview:navBtn];
|
|
||||||
[navBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
||||||
// make.left.equalTo(self.view).offset(12);
|
|
||||||
// make.centerX.equalTo(self.view);
|
|
||||||
make.right.equalTo(self.view).offset(-15);
|
|
||||||
make.bottom.equalTo(self.view).offset(-118);
|
|
||||||
make.height.mas_equalTo(@30);
|
|
||||||
make.width.mas_equalTo(@60);
|
|
||||||
}];
|
|
||||||
|
|
||||||
|
|
||||||
[self.mapView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
||||||
make.left.right.equalTo(self.view);
|
|
||||||
// make.top.equalTo(startTf.mas_bottom).offset(5);
|
|
||||||
make.top.equalTo(self.view).offset(0);
|
|
||||||
// make.bottom.equalTo(navBtn.mas_top).offset(-3);
|
|
||||||
make.bottom.equalTo(self.view).offset(0);
|
|
||||||
}];
|
|
||||||
|
|
||||||
[self.view bringSubviewToFront:navBtn];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)initDriveManager
|
|
||||||
{
|
|
||||||
//请在 dealloc 函数中执行 [AMapNaviDriveManager destroyInstance] 来销毁单例
|
|
||||||
[[AMapNaviDriveManager sharedInstance] setDelegate:self];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
- (void)initMapView
|
|
||||||
{
|
|
||||||
if (self.mapView == nil)
|
|
||||||
{
|
|
||||||
self.mapView = [[MAMapView alloc] initWithFrame:CGRectZero];
|
|
||||||
[self.mapView setDelegate:self];
|
|
||||||
self.mapView.showsUserLocation = YES;
|
|
||||||
self.mapView.userTrackingMode = MAUserTrackingModeFollowWithHeading;
|
|
||||||
self.mapView.desiredAccuracy = kCLLocationAccuracyNearestTenMeters; // 定位精度
|
|
||||||
_mapView.showsScale= YES;
|
|
||||||
|
|
||||||
CGFloat ze = self.mapView.zoomLevel;
|
|
||||||
self.mapView.zoomLevel = 9;
|
|
||||||
|
|
||||||
// 2. 禁用所有不必要的动画和自动调整
|
|
||||||
// self.mapView.autoresizesSubviews = NO;
|
|
||||||
// [self.mapView setShowsWorldMap:NO]; // 不显示世界地图
|
|
||||||
|
|
||||||
// 3. 固定缩放级别
|
|
||||||
// [self.mapView setMinZoomLevel:6.0];
|
|
||||||
// [self.mapView setMaxZoomLevel:20.0];
|
|
||||||
// [self.mapView setZoomLevel:10.0 animated:NO];
|
|
||||||
|
|
||||||
|
|
||||||
// 4. 禁用自动调整
|
|
||||||
// [self.mapView setAutoCheckMapBoundary:NO];
|
|
||||||
|
|
||||||
[self.view addSubview:self.mapView];
|
|
||||||
|
|
||||||
if (@available(iOS 14.0, *)) {
|
|
||||||
// iOS14+ 需要额外处理
|
|
||||||
CLAuthorizationStatus status = [[[CLLocationManager alloc] init] authorizationStatus];
|
|
||||||
if (status == kCLAuthorizationStatusNotDetermined) {
|
|
||||||
[[[CLLocationManager alloc] init] requestWhenInUseAuthorization];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
///TEST
|
|
||||||
// MAPointAnnotation *pointAnnotation = [[MAPointAnnotation alloc] init];
|
|
||||||
// pointAnnotation.coordinate = CLLocationCoordinate2DMake(31.19, 121.32);
|
|
||||||
// pointAnnotation.title = @"嘉兴经开站";
|
|
||||||
// [_mapView addAnnotation:pointAnnotation];
|
|
||||||
//
|
|
||||||
// MAPointAnnotation *pointAnnotation2 = [[MAPointAnnotation alloc] init];
|
|
||||||
// pointAnnotation2.coordinate = CLLocationCoordinate2DMake(30.81669400, 120.94291800);
|
|
||||||
// pointAnnotation2.title = @"测试站点1";
|
|
||||||
// [_mapView addAnnotation:pointAnnotation2];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
||||||
[btn setImage:[AMapNavCommonUtil imageWithName:@"icon_local"] forState:UIControlStateNormal];
|
|
||||||
btn.backgroundColor = [UIColor lightGrayColor];
|
|
||||||
btn.titleLabel.font = [UIFont systemFontOfSize:14];
|
|
||||||
btn.layer.cornerRadius = 20;
|
|
||||||
|
|
||||||
[btn addTarget:self action:@selector(updateUserLocalAction) forControlEvents:UIControlEventTouchUpInside];
|
|
||||||
|
|
||||||
[self.view addSubview:btn];
|
|
||||||
[btn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
||||||
make.right.equalTo(self.view).offset(-10);
|
|
||||||
make.width.height.equalTo(@40);
|
|
||||||
make.top.equalTo(self.view).offset(150);
|
|
||||||
}];
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)updateUserLocalAction {
|
|
||||||
// 如果已经有位置,直接移动视角
|
|
||||||
if (_mapView.userLocation.location) {
|
|
||||||
CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(self.latitude, self.longitude);
|
|
||||||
|
|
||||||
[_mapView setCenterCoordinate:coord animated:YES];
|
|
||||||
// [_mapView setZoomLevel:10 animated:YES];
|
|
||||||
} else {
|
|
||||||
// 如果尚未获取到位置,进入跟踪模式等待回调
|
|
||||||
[_mapView setUserTrackingMode:MAUserTrackingModeFollow animated:YES];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)initAnnotations
|
|
||||||
{
|
|
||||||
NaviPointAnnotation *beginAnnotation = [[NaviPointAnnotation alloc] init];
|
|
||||||
[beginAnnotation setCoordinate:CLLocationCoordinate2DMake(self.startPoi.location.latitude, self.startPoi.location.longitude)];
|
|
||||||
beginAnnotation.title = @"起始点";
|
|
||||||
beginAnnotation.navPointType = NaviPointAnnotationStart;
|
|
||||||
|
|
||||||
[self.mapView addAnnotation:beginAnnotation];
|
|
||||||
|
|
||||||
// NaviPointAnnotation *endAnnotation = [[NaviPointAnnotation alloc] init];
|
|
||||||
// [endAnnotation setCoordinate:CLLocationCoordinate2DMake(self.dstPoi.location.latitude, self.dstPoi.location.longitude)];
|
|
||||||
// endAnnotation.title = @"终点";
|
|
||||||
// endAnnotation.navPointType = NaviPointAnnotationEnd;
|
|
||||||
//
|
|
||||||
// [self.mapView addAnnotation:endAnnotation];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- (AMapLocationManager *)locationService {
|
|
||||||
if (!_locationService) {
|
|
||||||
_locationService = [[AMapLocationManager alloc] init];
|
|
||||||
_locationService.delegate = self;
|
|
||||||
_locationService.desiredAccuracy = kCLLocationAccuracyBest; // 最高精度模式
|
|
||||||
_locationService.distanceFilter = 5;
|
|
||||||
_locationService.locatingWithReGeocode = YES;
|
|
||||||
}
|
|
||||||
return _locationService;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- (void)dealloc {
|
|
||||||
[self.locationService stopUpdatingLocation];
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
- (AMapNaviCompositeManager *)compositeManager {
|
|
||||||
|
|
||||||
if (!_compositeManager) {
|
|
||||||
_compositeManager = [[AMapNaviCompositeManager alloc] init]; // 初始化
|
|
||||||
_compositeManager.delegate = self; // 如果需要使用AMapNaviCompositeManagerDelegate的相关回调(如自定义语音、获取实时位置等),需要设置delegate
|
|
||||||
}
|
|
||||||
return _compositeManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 监听隐私状态变化
|
|
||||||
- (void)observePrivacyStatus {
|
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
||||||
selector:@selector(handlePrivacyUpdate)
|
|
||||||
name:@"ksAMapPrivacyDidUpdateNotification" // 自定义通知
|
|
||||||
object:nil];
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)handlePrivacyUpdate {
|
|
||||||
[self checkPrivacyStatus];
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查当前隐私状态
|
|
||||||
- (void)checkPrivacyStatus {
|
|
||||||
BOOL hasAgreed = [[NSUserDefaults standardUserDefaults] boolForKey:@"usragreeStatus"];
|
|
||||||
|
|
||||||
if (hasAgreed) {
|
|
||||||
|
|
||||||
/// 开启定位
|
|
||||||
[self.locationService startUpdatingLocation];
|
|
||||||
// [self.mapView reloadMap];
|
|
||||||
|
|
||||||
[self initMapView];
|
|
||||||
[self initSubview];
|
|
||||||
|
|
||||||
[self initDriveManager];
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - Action
|
|
||||||
///选择方式
|
|
||||||
-(void)navAction {
|
|
||||||
[self showSelectNavType];
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)showSelectNavType {
|
|
||||||
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"选择导航类型" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
|
|
||||||
UIAlertAction *sure = [UIAlertAction actionWithTitle:@"SDK导航" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
||||||
[self navigationType_sdk];
|
|
||||||
}];
|
|
||||||
UIAlertAction *sure2 = [UIAlertAction actionWithTitle:@"高德地图导航" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
||||||
|
|
||||||
[self navigationType_app];
|
|
||||||
}];
|
|
||||||
|
|
||||||
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
|
|
||||||
}];
|
|
||||||
|
|
||||||
[alert addAction:sure];
|
|
||||||
[alert addAction:sure2];
|
|
||||||
[alert addAction:cancel];
|
|
||||||
|
|
||||||
[self presentViewController:alert animated:YES completion:nil];
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)navigationType_app {
|
|
||||||
|
|
||||||
NSURL* scheme = [NSURL URLWithString:@"iosamap://"];
|
|
||||||
BOOL canOpen = [[UIApplication sharedApplication] canOpenURL:scheme];
|
|
||||||
if (!canOpen) {
|
|
||||||
[self showAlertWithMessage:@"请先安装高德地图客户端"]; return;
|
|
||||||
}
|
|
||||||
|
|
||||||
NSString *myLocationScheme = [NSString stringWithFormat:@"iosamap://navi?sourceApplication=ANavDemo&lat=31.2304&lon=121.4737&t=0&dev=1"];
|
|
||||||
|
|
||||||
NSString *encodedUrlString = [myLocationScheme stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
|
|
||||||
|
|
||||||
NSURL *gaodeUrl = [NSURL URLWithString:encodedUrlString];
|
|
||||||
|
|
||||||
|
|
||||||
[[UIApplication sharedApplication] openURL:gaodeUrl options:@{} completionHandler:^(BOOL res) {
|
|
||||||
|
|
||||||
}];
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)navigationType_sdk {
|
|
||||||
id delegate = [AMapNaviDriveManager sharedInstance].delegate;
|
|
||||||
if (!delegate) {
|
|
||||||
[AMapNaviDriveManager sharedInstance].delegate = self;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
NSDictionary * routes = [AMapNaviDriveManager sharedInstance].naviRoutes;
|
|
||||||
if (!routes) {
|
|
||||||
NSLog(@"暂无路线信息!!!!!!!!!");
|
|
||||||
self.isStartNav = YES;
|
|
||||||
[self calRoutePath];
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
AMapNaviCompositeUserConfig *config = [[AMapNaviCompositeUserConfig alloc] init];
|
|
||||||
|
|
||||||
// [config setRoutePlanPOIType:AMapNaviRoutePlanPOITypeEnd location:[AMapNaviPoint locationWithLatitude:32.21 longitude:121.34] name:@"故宫22" POIId:nil];
|
|
||||||
|
|
||||||
[config setStartNaviDirectly:YES]; //直接进入导航界面
|
|
||||||
[config setNeedCalculateRouteWhenPresent:NO];//不在算路
|
|
||||||
[config setMultipleRouteNaviMode:NO];//直接单线路径导航
|
|
||||||
// [config setNeedDestoryDriveManagerInstanceWhenDismiss:NO];
|
|
||||||
|
|
||||||
self.isStartNav = NO;
|
|
||||||
|
|
||||||
[self.compositeManager presentRoutePlanViewControllerWithOptions:config];
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#pragma mark - 计算线路
|
|
||||||
///计算线路
|
|
||||||
-(void)calRoutePath {
|
|
||||||
// [self.mapView removeOverlays:self.mapView.overlays];
|
|
||||||
// self.startTf.text = @"click calpath";
|
|
||||||
// return;
|
|
||||||
|
|
||||||
[self initAnnotations];
|
|
||||||
|
|
||||||
AMapNaviPoint * startPoint = [AMapNaviPoint locationWithLatitude:self.startPoi.location.latitude longitude:self.startPoi.location.longitude];
|
|
||||||
|
|
||||||
AMapNaviPoint * endPoint = [AMapNaviPoint locationWithLatitude:self.dstPoi.location.latitude longitude:self.dstPoi.location.longitude];
|
|
||||||
|
|
||||||
AMapNaviDrivingStrategy strategy = ConvertDrivingPreferenceToDrivingStrategy(0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0);
|
|
||||||
|
|
||||||
id delegate = [AMapNaviDriveManager sharedInstance].delegate;
|
|
||||||
if (!delegate) {
|
|
||||||
[AMapNaviDriveManager sharedInstance].delegate = self;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[AMapNaviDriveManager sharedInstance] calculateDriveRouteWithStartPoints:@[startPoint]
|
|
||||||
endPoints:@[endPoint]
|
|
||||||
wayPoints:nil
|
|
||||||
drivingStrategy:strategy];
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
- (void)driveManagerOnCalculateRouteSuccess:(AMapNaviDriveManager *)driveManager
|
|
||||||
{
|
|
||||||
NSLog(@"onCalculateRouteSuccess");
|
|
||||||
//算路成功后显示路径
|
|
||||||
[self showNaviRoutes];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)showNaviRoutes
|
|
||||||
{
|
|
||||||
if ([[AMapNaviDriveManager sharedInstance].naviRoutes count] <= 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.lastOverLays = self.mapView.overlays;
|
|
||||||
[self.mapView removeOverlays:self.mapView.overlays];
|
|
||||||
// [self.routeIndicatorInfoArray removeAllObjects];
|
|
||||||
|
|
||||||
self.currentCalRoutePaths = [AMapNaviDriveManager sharedInstance].naviRoutes;
|
|
||||||
|
|
||||||
|
|
||||||
NSInteger routeId = 0;
|
|
||||||
|
|
||||||
//将路径显示到地图上
|
|
||||||
for (NSNumber *aRouteID in [[AMapNaviDriveManager sharedInstance].naviRoutes allKeys])
|
|
||||||
{
|
|
||||||
AMapNaviRoute *aRoute = [[[AMapNaviDriveManager sharedInstance] naviRoutes] objectForKey:aRouteID];
|
|
||||||
int count = (int)[[aRoute routeCoordinates] count];
|
|
||||||
|
|
||||||
//添加路径Polyline
|
|
||||||
CLLocationCoordinate2D *coords = (CLLocationCoordinate2D *)malloc(count * sizeof(CLLocationCoordinate2D));
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
AMapNaviPoint *coordinate = [[aRoute routeCoordinates] objectAtIndex:i];
|
|
||||||
coords[i].latitude = [coordinate latitude];
|
|
||||||
coords[i].longitude = [coordinate longitude];
|
|
||||||
}
|
|
||||||
|
|
||||||
MAPolyline *polyline = [MAPolyline polylineWithCoordinates:coords count:count];
|
|
||||||
|
|
||||||
SelectableOverlay *selectablePolyline = [[SelectableOverlay alloc] initWithOverlay:polyline];
|
|
||||||
[selectablePolyline setRouteID:[aRouteID integerValue]];
|
|
||||||
|
|
||||||
[self.mapView addOverlay:selectablePolyline];
|
|
||||||
free(coords);
|
|
||||||
|
|
||||||
routeId = [aRouteID integerValue];
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1. 先获取当前地图区域
|
|
||||||
MACoordinateRegion currentRegion = self.mapView.region;
|
|
||||||
|
|
||||||
[self.mapView showAnnotations:self.mapView.annotations animated:NO];
|
|
||||||
|
|
||||||
// 3. 保持当前区域不变
|
|
||||||
[self.mapView setRegion:currentRegion animated:NO];
|
|
||||||
|
|
||||||
[self selectNaviRouteWithID:routeId];
|
|
||||||
|
|
||||||
///如果已开始导航,直接进入导航
|
|
||||||
if (self.isStartNav) {
|
|
||||||
[self navigationType_sdk];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)selectNaviRouteWithID:(NSInteger)routeID
|
|
||||||
{
|
|
||||||
//在开始导航前进行路径选择
|
|
||||||
if ([[AMapNaviDriveManager sharedInstance] selectNaviRouteWithRouteID:routeID])
|
|
||||||
{
|
|
||||||
[self selecteOverlayWithRouteID:routeID];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NSLog(@"路径选择失败!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)selecteOverlayWithRouteID:(NSInteger)routeID
|
|
||||||
{
|
|
||||||
[self.mapView.overlays enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(id<MAOverlay> overlay, NSUInteger idx, BOOL *stop)
|
|
||||||
{
|
|
||||||
if ([overlay isKindOfClass:[SelectableOverlay class]])
|
|
||||||
{
|
|
||||||
SelectableOverlay *selectableOverlay = overlay;
|
|
||||||
|
|
||||||
/* 获取overlay对应的renderer. */
|
|
||||||
MAPolylineRenderer * overlayRenderer = (MAPolylineRenderer *)[self.mapView rendererForOverlay:selectableOverlay];
|
|
||||||
|
|
||||||
if (selectableOverlay.routeID == routeID)
|
|
||||||
{
|
|
||||||
/* 设置选中状态. */
|
|
||||||
selectableOverlay.selected = YES;
|
|
||||||
|
|
||||||
/* 修改renderer选中颜色. */
|
|
||||||
overlayRenderer.fillColor = selectableOverlay.selectedColor;
|
|
||||||
overlayRenderer.strokeColor = selectableOverlay.selectedColor;
|
|
||||||
|
|
||||||
/* 修改overlay覆盖的顺序. */
|
|
||||||
[self.mapView exchangeOverlayAtIndex:idx withOverlayAtIndex:self.mapView.overlays.count - 1];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* 设置选中状态. */
|
|
||||||
selectableOverlay.selected = NO;
|
|
||||||
|
|
||||||
/* 修改renderer选中颜色. */
|
|
||||||
overlayRenderer.fillColor = selectableOverlay.regularColor;
|
|
||||||
overlayRenderer.strokeColor = selectableOverlay.regularColor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}];
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - AMapLocationManagerDelegate
|
|
||||||
- (void)amapLocationManager:(AMapLocationManager *)manager didUpdateLocation:(CLLocation *)location reGeocode:(AMapLocationReGeocode *)reGeocode
|
|
||||||
{
|
|
||||||
if (!location) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
self.latitude = location.coordinate.latitude;
|
|
||||||
self.longitude = location.coordinate.longitude;
|
|
||||||
|
|
||||||
AMapNavSDKManager * sdk = [AMapNavSDKManager sharedManager];
|
|
||||||
sdk.localCity = reGeocode.city;
|
|
||||||
sdk.locationAddressDetail = reGeocode.POIName;
|
|
||||||
|
|
||||||
// 设置地图中心为用户位置
|
|
||||||
// MACoordinateRegion region = MACoordinateRegionMake(location.coordinate,
|
|
||||||
// MACoordinateSpanMake(0.1, 0.1));
|
|
||||||
// [self.mapView setRegion:region animated:YES];
|
|
||||||
|
|
||||||
|
|
||||||
//更新出发点
|
|
||||||
AMapPOI * aoi = [[AMapPOI alloc] init];
|
|
||||||
#ifdef kAMapSDKDebugFlag
|
|
||||||
aoi.location = [AMapGeoPoint locationWithLatitude:31.23 longitude:121.48 ];
|
|
||||||
aoi.name =@"人民大道185号";
|
|
||||||
#else
|
|
||||||
aoi.location = [AMapGeoPoint locationWithLatitude:self.latitude longitude:self.longitude ];
|
|
||||||
aoi.name = reGeocode.POIName;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
self.startPoi = aoi;
|
|
||||||
[self updateUIWithData:aoi textField:self.startTf];
|
|
||||||
|
|
||||||
//获取附近站点
|
|
||||||
if (!self.startQueryCurrnetNodeFlag && reGeocode) {
|
|
||||||
self.startQueryCurrnetNodeFlag = YES;
|
|
||||||
NSString * province = reGeocode.province;
|
|
||||||
NSString * city = reGeocode.city;
|
|
||||||
NSString * district = reGeocode.district;
|
|
||||||
NSString * longitude = [NSString stringWithFormat:@"%f",self.longitude];
|
|
||||||
NSString * latitude = [NSString stringWithFormat:@"%f",self.latitude];
|
|
||||||
|
|
||||||
if (province && city && district) {
|
|
||||||
NSDictionary * dic = @{@"province":province , @"city":city , @"district":district , @"longitude":longitude , @"latitude":latitude};
|
|
||||||
|
|
||||||
[self requestHyDetailWithParms:dic];
|
|
||||||
}
|
|
||||||
|
|
||||||
[self requestHyListWithParms:@{@"longitude":longitude , @"latitude":latitude}];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - MAMapView 渲染
|
|
||||||
|
|
||||||
- (MAAnnotationView *)mapView:(MAMapView *)mapView viewForAnnotation:(id<MAAnnotation>)annotation
|
|
||||||
{
|
|
||||||
if ([annotation isKindOfClass:[NaviPointAnnotation class]])
|
|
||||||
{
|
|
||||||
static NSString *annotationIdentifier = @"NaviPointAnnotationIdentifier";
|
|
||||||
|
|
||||||
MAPinAnnotationView *pointAnnotationView = (MAPinAnnotationView*)[self.mapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
|
|
||||||
if (pointAnnotationView == nil)
|
|
||||||
{
|
|
||||||
pointAnnotationView = [[MAPinAnnotationView alloc] initWithAnnotation:annotation
|
|
||||||
reuseIdentifier:annotationIdentifier];
|
|
||||||
}
|
|
||||||
|
|
||||||
pointAnnotationView.animatesDrop = NO;
|
|
||||||
pointAnnotationView.canShowCallout = YES;
|
|
||||||
pointAnnotationView.draggable = NO;
|
|
||||||
|
|
||||||
NaviPointAnnotation *navAnnotation = (NaviPointAnnotation *)annotation;
|
|
||||||
|
|
||||||
if (navAnnotation.navPointType == NaviPointAnnotationStart)
|
|
||||||
{
|
|
||||||
[pointAnnotationView setPinColor:MAPinAnnotationColorGreen];
|
|
||||||
}
|
|
||||||
else if (navAnnotation.navPointType == NaviPointAnnotationEnd)
|
|
||||||
{
|
|
||||||
[pointAnnotationView setPinColor:MAPinAnnotationColorRed];
|
|
||||||
}
|
|
||||||
|
|
||||||
return pointAnnotationView;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( [annotation isMemberOfClass:[MAPointAnnotation class]])
|
|
||||||
{
|
|
||||||
MAUserLocation *user = (MAUserLocation *)annotation;
|
|
||||||
|
|
||||||
static NSString *pointReuseIndentifier = @"pointReuseIndentifier";
|
|
||||||
MAPinAnnotationView*annotationView = (MAPinAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:pointReuseIndentifier];
|
|
||||||
if (annotationView == nil)
|
|
||||||
{
|
|
||||||
annotationView = [[MAPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:pointReuseIndentifier];
|
|
||||||
}
|
|
||||||
annotationView.canShowCallout= YES; //设置气泡可以弹出,默认为NO
|
|
||||||
annotationView.animatesDrop = NO; //设置标注动画显示,默认为NO
|
|
||||||
annotationView.draggable = NO; //设置标注可以拖动,默认为NO
|
|
||||||
annotationView.pinColor = MAPinAnnotationColorPurple;
|
|
||||||
|
|
||||||
// 设置自定义的气泡背景色
|
|
||||||
if (@available(iOS 14.0, *)) {
|
|
||||||
// iOS 14+ 可以使用 tintColor
|
|
||||||
annotationView.tintColor = [UIColor systemBlueColor];
|
|
||||||
} else {
|
|
||||||
// iOS 13 及以下
|
|
||||||
annotationView.tintColor = [UIColor colorWithRed:0.1 green:0.6 blue:0.9 alpha:1.0];
|
|
||||||
}
|
|
||||||
|
|
||||||
return annotationView;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (MAOverlayRenderer *)mapView:(MAMapView *)mapView rendererForOverlay:(id<MAOverlay>)overlay
|
|
||||||
{
|
|
||||||
if ([overlay isKindOfClass:[SelectableOverlay class]])
|
|
||||||
{
|
|
||||||
SelectableOverlay * selectableOverlay = (SelectableOverlay *)overlay;
|
|
||||||
id<MAOverlay> actualOverlay = selectableOverlay.overlay;
|
|
||||||
|
|
||||||
MAPolylineRenderer *polylineRenderer = [[MAPolylineRenderer alloc] initWithPolyline:actualOverlay];
|
|
||||||
|
|
||||||
polylineRenderer.lineWidth = 8.f;
|
|
||||||
polylineRenderer.strokeColor = selectableOverlay.isSelected ? selectableOverlay.selectedColor : selectableOverlay.regularColor;
|
|
||||||
|
|
||||||
return polylineRenderer;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 当地图添加完标注视图后调用
|
|
||||||
- (void)mapView:(MAMapView *)mapView didAddAnnotationViews:(NSArray *)views {
|
|
||||||
// 遍历所有被添加的标注视图
|
|
||||||
# if 0
|
|
||||||
for (MAAnnotationView *view in views) {
|
|
||||||
// 检查是否为需要的标注类型,例如大头针标注
|
|
||||||
if ([view.annotation isMemberOfClass:[MAPointAnnotation class]]) {
|
|
||||||
// 延迟零点几秒执行,以确保视图添加动画完成(可选,但可使效果更平滑)
|
|
||||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
||||||
// 选中该标注,从而使其气泡弹出
|
|
||||||
[mapView selectAnnotation:view.annotation animated:YES];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)mapView:(MAMapView *)mapView didSelectAnnotationView:(MAAnnotationView *)view {
|
|
||||||
NSLog(@"didSelectAnnotationView: %s" , __func__);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 当标注被取消选中时调用
|
|
||||||
- (void)mapView:(MAMapView *)mapView didDeselectAnnotationView:(MAAnnotationView *)view {
|
|
||||||
if ([view.annotation isMemberOfClass:[MAPointAnnotation class]]) {
|
|
||||||
// 可以立即或稍作延迟后重新选中
|
|
||||||
// [mapView selectAnnotation:view.annotation animated:NO];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//选中一个点
|
|
||||||
- (void)mapView:(MAMapView *)mapView didAnnotationViewCalloutTapped:(MAAnnotationView *)view {
|
|
||||||
id pointAnnotation = view.annotation;
|
|
||||||
if ([pointAnnotation isMemberOfClass:MAPointAnnotation.class]) {
|
|
||||||
MAPointAnnotation *point = (MAPointAnnotation *)view.annotation;
|
|
||||||
|
|
||||||
|
|
||||||
NSLog(@"point: %@" , point.title);
|
|
||||||
|
|
||||||
AMapPOI * aoi = [[AMapPOI alloc] init];
|
|
||||||
|
|
||||||
aoi.location = [AMapGeoPoint locationWithLatitude:point.coordinate.latitude longitude:point.coordinate.longitude];
|
|
||||||
|
|
||||||
aoi.name = point.title;
|
|
||||||
|
|
||||||
self.dstPoi = aoi;
|
|
||||||
|
|
||||||
[self updateUIWithData:aoi textField:self.dstTf];
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
NSLog(@"didSelectAnnotationView: %s" , __func__);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - AMapNaviCompositeManagerDelegate
|
|
||||||
- (void)compositeManager:(AMapNaviCompositeManager *)compositeManager didStartNavi:(AMapNaviMode)naviMode {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)compositeManager:(AMapNaviCompositeManager *)compositeManager onDriveStrategyChanged:(AMapNaviDrivingStrategy)driveStrategy {
|
|
||||||
NSLog(@"%s" , __func__ );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - UITextFieldDelegate
|
|
||||||
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
|
|
||||||
|
|
||||||
ASearchAddressController * vc = [[ASearchAddressController alloc] init];
|
|
||||||
|
|
||||||
UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:vc];
|
|
||||||
//UIModalPresentationOverFullScreen/UIModalPresentationFullScreen触发离开
|
|
||||||
nav.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
|
||||||
nav.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
|
|
||||||
|
|
||||||
__weak typeof(self)weakSelf = self;
|
|
||||||
vc.selectAddressBlk = ^(AMapPOI * _Nonnull poi) {
|
|
||||||
[weakSelf updateUIWithData:poi textField:textField];
|
|
||||||
};
|
|
||||||
|
|
||||||
[self presentViewController:nav animated:YES completion:^{
|
|
||||||
|
|
||||||
}];
|
|
||||||
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)updateUIWithData: (AMapPOI*)poi textField: (UITextField*)tf {
|
|
||||||
BOOL isStart = tf.tag == 100;
|
|
||||||
tf.text = poi.name;
|
|
||||||
|
|
||||||
if (isStart) {
|
|
||||||
self.startPoi = poi;
|
|
||||||
}else {
|
|
||||||
self.dstPoi = poi;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - tool
|
|
||||||
|
|
||||||
-(void)showAlertWithMessage:(NSString *)msg {
|
|
||||||
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:msg preferredStyle:UIAlertControllerStyleAlert];
|
|
||||||
UIAlertAction *sure = [UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
||||||
}];
|
|
||||||
|
|
||||||
[alert addAction:sure];
|
|
||||||
|
|
||||||
[self.navigationController presentViewController:alert animated:YES completion:nil];
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
//
|
|
||||||
// ASearchAddressController.h
|
|
||||||
// ANavDemo
|
|
||||||
//
|
|
||||||
// Created by admin on 2026/2/6.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import "ABaseViewController.h"
|
|
||||||
|
|
||||||
#import <AMapSearchKit/AMapSearchKit.h>
|
|
||||||
#import <AMapLocationKit/AMapLocationKit.h>
|
|
||||||
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
|
||||||
|
|
||||||
@interface ASearchAddressController : ABaseViewController
|
|
||||||
|
|
||||||
@property (nonatomic , copy) void(^selectAddressBlk)(AMapPOI * poi);
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
|
||||||
@@ -1,232 +0,0 @@
|
|||||||
//
|
|
||||||
// ASearchAddressController.m
|
|
||||||
// ANavDemo
|
|
||||||
//
|
|
||||||
// Created by admin on 2026/2/6.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import "ASearchAddressController.h"
|
|
||||||
#import "AMapNavSDKManager.h"
|
|
||||||
|
|
||||||
#import <AMapFoundationKit/AMapFoundationKit.h>
|
|
||||||
|
|
||||||
#import "AMapNavCommonUtil.h"
|
|
||||||
|
|
||||||
@interface ASearchAddressController ()<UITextFieldDelegate , AMapSearchDelegate,UITableViewDelegate , UITableViewDataSource>
|
|
||||||
|
|
||||||
@property (nonatomic , strong) UITableView *tableView;
|
|
||||||
@property (nonatomic , strong) UIBarButtonItem *rightItem;
|
|
||||||
@property (nonatomic ,strong)UIButton * backBtn;
|
|
||||||
|
|
||||||
@property (nonatomic , strong) NSArray *dataArr;
|
|
||||||
|
|
||||||
@property (nonatomic, strong) UITextField *inputAddressTf;
|
|
||||||
@property (nonatomic, strong) AMapSearchAPI *search;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation ASearchAddressController
|
|
||||||
|
|
||||||
- (void)viewDidLoad {
|
|
||||||
[super viewDidLoad];
|
|
||||||
// Do any additional setup after loading the view.
|
|
||||||
self.title = @"选择地点";
|
|
||||||
|
|
||||||
[self initSubview];
|
|
||||||
|
|
||||||
self.search = [[AMapSearchAPI alloc] init];
|
|
||||||
self.search.delegate = self;
|
|
||||||
|
|
||||||
#ifdef kAMapSDKDebugFlag
|
|
||||||
self.inputAddressTf.text = @"人民广场";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)viewDidAppear:(BOOL)animated {
|
|
||||||
[super viewDidAppear:animated];
|
|
||||||
|
|
||||||
[self.inputAddressTf becomeFirstResponder];
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)initSubview {
|
|
||||||
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:self.backBtn];
|
|
||||||
|
|
||||||
UITextField * inputAddressTf = [[UITextField alloc] init];
|
|
||||||
inputAddressTf.borderStyle = UITextBorderStyleRoundedRect;
|
|
||||||
inputAddressTf.placeholder = @"输入地址";
|
|
||||||
inputAddressTf.returnKeyType = UIReturnKeySearch;
|
|
||||||
inputAddressTf.tag = 100;
|
|
||||||
inputAddressTf.delegate = self;
|
|
||||||
|
|
||||||
[self.view addSubview:inputAddressTf];
|
|
||||||
|
|
||||||
[inputAddressTf mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
||||||
make.left.mas_equalTo(self.view).offset(10);
|
|
||||||
make.top.mas_equalTo(self.view).offset(kRoutePlanBarHeight + 10);
|
|
||||||
make.height.mas_equalTo(@30);
|
|
||||||
}];
|
|
||||||
|
|
||||||
self.inputAddressTf = inputAddressTf;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
||||||
[btn setTitle:@"当前位置" forState:UIControlStateNormal];
|
|
||||||
btn.backgroundColor = [UIColor whiteColor];
|
|
||||||
btn.layer.borderColor = [UIColor blueColor].CGColor;
|
|
||||||
btn.layer.borderWidth = 1;
|
|
||||||
btn.layer.cornerRadius = 5;
|
|
||||||
btn.titleLabel.font = [UIFont systemFontOfSize:12];
|
|
||||||
|
|
||||||
[btn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
|
|
||||||
[btn addTarget:self action:@selector(searchBtnAction) forControlEvents:UIControlEventTouchUpInside];
|
|
||||||
[self.view addSubview:btn];
|
|
||||||
[btn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
||||||
make.left.equalTo(inputAddressTf.mas_right).offset(12);
|
|
||||||
make.top.mas_equalTo(inputAddressTf);
|
|
||||||
make.right.mas_equalTo(self.view).offset(-10);
|
|
||||||
make.height.mas_equalTo(@30);
|
|
||||||
make.width.mas_equalTo(70);
|
|
||||||
}];
|
|
||||||
|
|
||||||
|
|
||||||
[self.view addSubview:self.tableView];
|
|
||||||
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
||||||
make.top.mas_equalTo(inputAddressTf.mas_bottom).offset(5);
|
|
||||||
make.left.equalTo(self.view);
|
|
||||||
make.bottom.equalTo(self.view);
|
|
||||||
make.centerX.equalTo(self.view);
|
|
||||||
|
|
||||||
}];
|
|
||||||
|
|
||||||
[self.tableView reloadData];
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark -
|
|
||||||
- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
|
|
||||||
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
|
|
||||||
if (!cell) {
|
|
||||||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"];
|
|
||||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
||||||
}
|
|
||||||
|
|
||||||
AMapPOI * m = self.dataArr[indexPath.row];
|
|
||||||
cell.textLabel.text = [NSString stringWithFormat:@"%@" , m.name ];
|
|
||||||
|
|
||||||
return cell;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
||||||
return self.dataArr.count;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
||||||
AMapPOI * m = self.dataArr[indexPath.row];
|
|
||||||
|
|
||||||
if (self.selectAddressBlk) {
|
|
||||||
self.selectAddressBlk(m);
|
|
||||||
}
|
|
||||||
|
|
||||||
[self backBtnAction];
|
|
||||||
// [self.navigationController popViewControllerAnimated:YES];
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark -
|
|
||||||
- (UITableView *)tableView {
|
|
||||||
if (!_tableView) {
|
|
||||||
_tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
|
|
||||||
_tableView.delegate = self;
|
|
||||||
_tableView.dataSource = self;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _tableView;
|
|
||||||
}
|
|
||||||
|
|
||||||
-(UIButton *)backBtn{
|
|
||||||
if (!_backBtn) {
|
|
||||||
_backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
||||||
_backBtn.frame = CGRectMake(0, 0, 40, 30);
|
|
||||||
_backBtn.imageEdgeInsets = UIEdgeInsetsMake(2, -5, 2, 5);
|
|
||||||
|
|
||||||
// _backBtn.backgroundColor = UIColor.redColor;
|
|
||||||
[_backBtn setImage:[AMapNavCommonUtil imageWithName:@"icon_fanhui"] forState:UIControlStateNormal];
|
|
||||||
[_backBtn addTarget:self action:@selector(backBtnAction) forControlEvents:UIControlEventTouchUpInside];
|
|
||||||
}
|
|
||||||
return _backBtn;
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)backBtnAction {
|
|
||||||
[self dismissViewControllerAnimated:YES completion:^{
|
|
||||||
|
|
||||||
}];
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - Action
|
|
||||||
-(void)searchBtnAction {
|
|
||||||
AMapNavSDKManager * sdk = [AMapNavSDKManager sharedManager];
|
|
||||||
self.inputAddressTf.text = sdk.locationAddressDetail;
|
|
||||||
|
|
||||||
[self startSearchWithAddress:self.inputAddressTf.text];
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)startSearchWithAddress:(NSString *)addr {
|
|
||||||
if (!addr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
AMapPOIKeywordsSearchRequest *request = [[AMapPOIKeywordsSearchRequest alloc] init];
|
|
||||||
|
|
||||||
request.keywords = addr;
|
|
||||||
|
|
||||||
AMapNavSDKManager * sdk = [AMapNavSDKManager sharedManager];
|
|
||||||
request.city = sdk.localCity;
|
|
||||||
|
|
||||||
|
|
||||||
// request.types = @"高等院校";
|
|
||||||
// request.requireExtension = YES;
|
|
||||||
request.offset =20;
|
|
||||||
|
|
||||||
/* 搜索SDK 3.2.0 中新增加的功能,只搜索本城市的POI。*/
|
|
||||||
request.cityLimit = YES;
|
|
||||||
// request.requireSubPOIs = YES;
|
|
||||||
|
|
||||||
|
|
||||||
[self.search AMapPOIKeywordsSearch:request];
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
|
||||||
/* POI 搜索回调. */
|
|
||||||
- (void)onPOISearchDone:(AMapPOISearchBaseRequest *)request response:(AMapPOISearchResponse *)response
|
|
||||||
{
|
|
||||||
NSArray * pois = response.pois;
|
|
||||||
if (pois.count == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//解析response获取POI信息,具体解析见 Demo
|
|
||||||
|
|
||||||
self.dataArr = [NSArray arrayWithArray:pois];
|
|
||||||
[self.tableView reloadData];
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
|
|
||||||
[textField resignFirstResponder];
|
|
||||||
|
|
||||||
[self startSearchWithAddress:textField.text];
|
|
||||||
|
|
||||||
return YES;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
|
||||||
[self.inputAddressTf resignFirstResponder];
|
|
||||||
}
|
|
||||||
@end
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
//
|
|
||||||
// AMapNavCommonUtil.h
|
|
||||||
// Pods
|
|
||||||
//
|
|
||||||
// Created by admin on 2026/2/11.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
|
||||||
|
|
||||||
@interface AMapNavCommonUtil : NSObject
|
|
||||||
|
|
||||||
+(UIImage *)imageWithName:(NSString *)name;
|
|
||||||
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
//
|
|
||||||
// AMapNavCommonUtil.m
|
|
||||||
// Pods
|
|
||||||
//
|
|
||||||
// Created by admin on 2026/2/11.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import "AMapNavCommonUtil.h"
|
|
||||||
|
|
||||||
@implementation AMapNavCommonUtil
|
|
||||||
|
|
||||||
|
|
||||||
#pragma mark - 获取图片
|
|
||||||
+(UIImage *)imageWithName:(NSString *)name {
|
|
||||||
NSURL * url = [[NSBundle mainBundle] URLForResource:@"AMapNavIOSSDK" withExtension:@"bundle"];
|
|
||||||
NSBundle *containnerBundle = [NSBundle bundleWithURL:url];
|
|
||||||
|
|
||||||
NSString * path = [containnerBundle pathForResource:[NSString stringWithFormat:@"%@@2x.png" , name] ofType:nil];
|
|
||||||
|
|
||||||
UIImage * arrowImage = [[UIImage imageWithContentsOfFile:path] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
|
|
||||||
|
|
||||||
return arrowImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
//
|
|
||||||
// AMapNavHttpUtil.h
|
|
||||||
// AMapNavIOSSDK
|
|
||||||
//
|
|
||||||
// Created by admin on 2026/2/11.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
|
||||||
|
|
||||||
@interface AMapNavHttpUtil : NSObject
|
|
||||||
|
|
||||||
+ (void)postRequestWithURL:(NSString *)urlString parameters:(id)parameters requestHeader:(NSDictionary *)headParam successHandler:(void (^)(NSDictionary *data, NSURLResponse *response))successHandler failureHandler:(void ( ^)(NSError *error))failureHandler;
|
|
||||||
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
//
|
|
||||||
// AMapNavHttpUtil.m
|
|
||||||
// AMapNavIOSSDK
|
|
||||||
//
|
|
||||||
// Created by admin on 2026/2/11.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import "AMapNavHttpUtil.h"
|
|
||||||
|
|
||||||
#define AMapRequestMethod_POST @"POST"
|
|
||||||
|
|
||||||
@interface AMapNavHttpUtil ()
|
|
||||||
@property (nonatomic , copy) NSString * baseURL;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation AMapNavHttpUtil
|
|
||||||
|
|
||||||
+ (instancetype)sharedInstance {
|
|
||||||
static AMapNavHttpUtil *sharedInstance = nil;
|
|
||||||
static dispatch_once_t onceToken;
|
|
||||||
|
|
||||||
// dispatch_once确保下面的代码块只被执行一次
|
|
||||||
dispatch_once(&onceToken, ^{
|
|
||||||
sharedInstance = [[self alloc] init];
|
|
||||||
// 可以在这里进行一些初始化操作
|
|
||||||
|
|
||||||
});
|
|
||||||
return sharedInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (instancetype)init {
|
|
||||||
self = [super init];
|
|
||||||
if (self) {
|
|
||||||
|
|
||||||
// if (sdk.config.developmentModel) {
|
|
||||||
// _baseURL = kYTOTPAnalyticsSDKTestHost;
|
|
||||||
// }else {
|
|
||||||
// _baseURL = kYTOTPAnalyticsSDKProductionHost;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
+ (void)postRequestWithURL:(NSString *)urlString parameters:(id)parameters requestHeader:(NSDictionary *)headParam successHandler:(void (^)(NSDictionary *data, NSURLResponse *response))successHandler failureHandler:(void ( ^)(NSError *error))failureHandler {
|
|
||||||
[self requestWithMethod:AMapRequestMethod_POST URL:urlString parameters:parameters requestHeader:headParam successHandler:successHandler failureHandler:failureHandler];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 使用NSURLSession发起网络请求
|
|
||||||
+ (void)requestWithMethod:(NSString *)method URL:(NSString *)urlString parameters:(id)parameters requestHeader:(NSDictionary *)headParam successHandler:(void (^)(NSDictionary *data, NSURLResponse *response))successHandler failureHandler:(void (^)(NSError *error))failureHandler {
|
|
||||||
if (!urlString) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建URL
|
|
||||||
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@" , urlString]];
|
|
||||||
|
|
||||||
// 创建请求
|
|
||||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
|
|
||||||
request.HTTPMethod = method;
|
|
||||||
request.timeoutInterval = 30.0;
|
|
||||||
|
|
||||||
// 设置请求头,指定数据通讯格式为json
|
|
||||||
if (headParam) {
|
|
||||||
for (NSString *key in headParam.allKeys) {
|
|
||||||
if (headParam[key]) {
|
|
||||||
[request setValue:[NSString stringWithFormat:@"%@",headParam[key]] forHTTPHeaderField:key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 将参数转换为JSON数据
|
|
||||||
NSError *error;
|
|
||||||
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:&error];
|
|
||||||
if (!jsonData) {}
|
|
||||||
|
|
||||||
if ([method isEqualToString: AMapRequestMethod_POST]) {
|
|
||||||
// 设置请求体
|
|
||||||
request.HTTPBody = jsonData;
|
|
||||||
}
|
|
||||||
|
|
||||||
__block NSURLSession *session = [NSURLSession sharedSession];
|
|
||||||
NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
|
||||||
if (error) {
|
|
||||||
NSLog(@"request error:%@" , error);
|
|
||||||
if (failureHandler) {
|
|
||||||
failureHandler(error);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (successHandler) {
|
|
||||||
NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
|
|
||||||
if(dic){
|
|
||||||
NSLog(@"url: %@ , response data:%@", url , dic);
|
|
||||||
}
|
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
|
||||||
successHandler(dic, response);
|
|
||||||
});
|
|
||||||
// successHandler(dic, response);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[session finishTasksAndInvalidate];
|
|
||||||
session = nil;
|
|
||||||
}];
|
|
||||||
|
|
||||||
// 开始任务
|
|
||||||
[task resume];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
//
|
|
||||||
// AMapPrivacyUtility.h
|
|
||||||
// officialDemoNavi
|
|
||||||
//
|
|
||||||
// Created by menglong on 2021/10/29.
|
|
||||||
// Copyright © 2021 AutoNavi. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 隐私合规使用demo 工具类
|
|
||||||
*/
|
|
||||||
@interface AMapPrivacyUtility : NSObject
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 通过这个方法来判断是否同意隐私合规
|
|
||||||
* 1.如果没有同意隐私合规,则创建的SDK manager 实例返回 为nil, 无法使用SDK提供的功能
|
|
||||||
* 2.如果同意了下次启动不提示 的授权,则不会弹框给用户
|
|
||||||
* 3.如果只同意了,则下次启动还要给用户弹框提示
|
|
||||||
*/
|
|
||||||
|
|
||||||
+ (void)handlePrivacyAgreeStatus;
|
|
||||||
|
|
||||||
+ (void)handlePrivacyAgreeStatusIn:(UIViewController*)targetVC;
|
|
||||||
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
|
||||||
@@ -1,137 +0,0 @@
|
|||||||
//
|
|
||||||
// AMapPrivacyUtility.m
|
|
||||||
// officialDemoNavi
|
|
||||||
//
|
|
||||||
// Created by menglong on 2021/10/29.
|
|
||||||
// Copyright © 2021 AutoNavi. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import "AMapPrivacyUtility.h"
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
#import <AMapNavikit/AMapNaviManagerConfig.h>
|
|
||||||
@implementation AMapPrivacyUtility
|
|
||||||
|
|
||||||
+ (void)showPrivacyInfoInWindow:(UIWindow *)window {
|
|
||||||
|
|
||||||
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
|
|
||||||
|
|
||||||
paragraphStyle.alignment = NSTextAlignmentLeft;
|
|
||||||
|
|
||||||
NSMutableAttributedString *privacyInfo = [[NSMutableAttributedString alloc] initWithString:@"\n亲,感谢您对XXX一直以来的信任!我们依据最新的监管要求更新了XXX《隐私权政策》,特向您说明如下\n1.为向您提供交易相关基本功能,我们会收集、使用必要的信息;\n2.基于您的明示授权,我们可能会获取您的位置(为您提供附近的商品、店铺及优惠资讯等)等信息,您有权拒绝或取消授权;\n3.我们会采取业界先进的安全措施保护您的信息安全;\n4.未经您同意,我们不会从第三方处获取、共享或向提供您的信息;" attributes:@{
|
|
||||||
NSParagraphStyleAttributeName:paragraphStyle,
|
|
||||||
}];
|
|
||||||
|
|
||||||
[privacyInfo addAttribute:NSLinkAttributeName
|
|
||||||
value:@"《隐私权政策》"
|
|
||||||
range:[[privacyInfo string] rangeOfString:@"《隐私权政策》"]];
|
|
||||||
|
|
||||||
UIAlertController *privacyInfoController = [UIAlertController alertControllerWithTitle:@"温馨提示(隐私合规示例)" message:@"" preferredStyle:UIAlertControllerStyleAlert];
|
|
||||||
|
|
||||||
[privacyInfoController setValue:privacyInfo forKey:@"attributedMessage"];
|
|
||||||
|
|
||||||
|
|
||||||
UIAlertAction *agreeAllAction = [UIAlertAction actionWithTitle:@"同意(下次不提示)" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
||||||
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"agreeStatus"];
|
|
||||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
||||||
//更新用户授权高德SDK隐私协议状态. since 8.1.0
|
|
||||||
[[AMapNaviManagerConfig sharedConfig] updatePrivacyAgree:AMapPrivacyAgreeStatusDidAgree];
|
|
||||||
}];
|
|
||||||
|
|
||||||
|
|
||||||
UIAlertAction *agreeAction = [UIAlertAction actionWithTitle:@"同意" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
||||||
//更新用户授权高德SDK隐私协议状态. since 8.1.0
|
|
||||||
[[AMapNaviManagerConfig sharedConfig] updatePrivacyAgree:AMapPrivacyAgreeStatusDidAgree];
|
|
||||||
}];
|
|
||||||
|
|
||||||
UIAlertAction *notAgreeAction = [UIAlertAction actionWithTitle:@"不同意" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
|
|
||||||
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"agreeStatus"];
|
|
||||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
||||||
//更新用户授权高德SDK隐私协议状态. since 8.1.0
|
|
||||||
[[AMapNaviManagerConfig sharedConfig] updatePrivacyAgree:AMapPrivacyAgreeStatusNotAgree];
|
|
||||||
}];
|
|
||||||
|
|
||||||
[privacyInfoController addAction:agreeAllAction];
|
|
||||||
[privacyInfoController addAction:agreeAction];
|
|
||||||
[privacyInfoController addAction:notAgreeAction];
|
|
||||||
|
|
||||||
[window.rootViewController presentViewController:privacyInfoController animated:YES completion:^{
|
|
||||||
//更新App是否显示隐私弹窗的状态,隐私弹窗是否包含高德SDK隐私协议内容的状态. since 8.1.0
|
|
||||||
[[AMapNaviManagerConfig sharedConfig] updatePrivacyShow:AMapPrivacyShowStatusDidShow privacyInfo:AMapPrivacyInfoStatusDidContain];
|
|
||||||
}];
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (void)handlePrivacyAgreeStatus {
|
|
||||||
//判断是否同意了隐私协议下次不提示
|
|
||||||
// if(![[NSUserDefaults standardUserDefaults] boolForKey:@"agreeStatus"]){
|
|
||||||
//添加隐私合规弹窗
|
|
||||||
[self showPrivacyInfoInWindow:[UIApplication sharedApplication].delegate.window];
|
|
||||||
|
|
||||||
// [[AMapNaviManagerConfig sharedConfig] updatePrivacyAgree:AMapPrivacyAgreeStatusDidAgree];
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (void)handlePrivacyAgreeStatusIn:(UIViewController*)targetVC {
|
|
||||||
if(![[NSUserDefaults standardUserDefaults] boolForKey:@"agreeStatus"]){
|
|
||||||
[self showPrivacyInfoInWindowWithVC:targetVC];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (void)showPrivacyInfoInWindowWithVC:(UIViewController *)window {
|
|
||||||
|
|
||||||
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
|
|
||||||
|
|
||||||
paragraphStyle.alignment = NSTextAlignmentLeft;
|
|
||||||
|
|
||||||
NSMutableAttributedString *privacyInfo = [[NSMutableAttributedString alloc] initWithString:@"\n感谢您一直以来的信任!我们依据最新的监管要求更新了《隐私权政策》,特向您说明如下\n1.为向您提供交易相关基本功能,我们会收集、使用必要的信息;\n2.基于您的明示授权,我们可能会获取您的位置(为您提供附近的店铺及优惠资讯等)等信息,您有权拒绝或取消授权;\n3.我们会采取业界先进的安全措施保护您的信息安全;\n4.未经您同意,我们不会从第三方处获取、共享或向提供您的信息;" attributes:@{
|
|
||||||
NSParagraphStyleAttributeName:paragraphStyle,
|
|
||||||
}];
|
|
||||||
|
|
||||||
[privacyInfo addAttribute:NSLinkAttributeName
|
|
||||||
value:@"《隐私权政策》"
|
|
||||||
range:[[privacyInfo string] rangeOfString:@"《隐私权政策》"]];
|
|
||||||
|
|
||||||
UIAlertController *privacyInfoController = [UIAlertController alertControllerWithTitle:@"温馨提示(隐私合规示例)" message:@"" preferredStyle:UIAlertControllerStyleAlert];
|
|
||||||
|
|
||||||
[privacyInfoController setValue:privacyInfo forKey:@"attributedMessage"];
|
|
||||||
|
|
||||||
|
|
||||||
UIAlertAction *agreeAllAction = [UIAlertAction actionWithTitle:@"同意(下次不提示)" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
||||||
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"agreeStatus"];
|
|
||||||
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"usragreeStatus"];
|
|
||||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
||||||
//更新用户授权高德SDK隐私协议状态. since 8.1.0
|
|
||||||
[[AMapNaviManagerConfig sharedConfig] updatePrivacyAgree:AMapPrivacyAgreeStatusDidAgree];
|
|
||||||
|
|
||||||
[NSNotificationCenter.defaultCenter postNotificationName:@"ksAMapPrivacyDidUpdateNotification" object:nil];
|
|
||||||
}];
|
|
||||||
|
|
||||||
|
|
||||||
UIAlertAction *agreeAction = [UIAlertAction actionWithTitle:@"同意" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
||||||
//更新用户授权高德SDK隐私协议状态. since 8.1.0
|
|
||||||
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"usragreeStatus"];
|
|
||||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
||||||
|
|
||||||
[[AMapNaviManagerConfig sharedConfig] updatePrivacyAgree:AMapPrivacyAgreeStatusDidAgree];
|
|
||||||
[NSNotificationCenter.defaultCenter postNotificationName:@"ksAMapPrivacyDidUpdateNotification" object:nil];
|
|
||||||
}];
|
|
||||||
|
|
||||||
UIAlertAction *notAgreeAction = [UIAlertAction actionWithTitle:@"不同意" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
|
|
||||||
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"agreeStatus"];
|
|
||||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
||||||
//更新用户授权高德SDK隐私协议状态. since 8.1.0
|
|
||||||
[[AMapNaviManagerConfig sharedConfig] updatePrivacyAgree:AMapPrivacyAgreeStatusNotAgree];
|
|
||||||
}];
|
|
||||||
|
|
||||||
[privacyInfoController addAction:agreeAllAction];
|
|
||||||
[privacyInfoController addAction:agreeAction];
|
|
||||||
[privacyInfoController addAction:notAgreeAction];
|
|
||||||
|
|
||||||
[window presentViewController:privacyInfoController animated:YES completion:^{
|
|
||||||
//更新App是否显示隐私弹窗的状态,隐私弹窗是否包含高德SDK隐私协议内容的状态. since 8.1.0
|
|
||||||
[[AMapNaviManagerConfig sharedConfig] updatePrivacyShow:AMapPrivacyShowStatusDidShow privacyInfo:AMapPrivacyInfoStatusDidContain];
|
|
||||||
}];
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
//
|
|
||||||
// NaviPointAnnotation.h
|
|
||||||
// AMapNaviKit
|
|
||||||
//
|
|
||||||
// Created by 刘博 on 16/3/8.
|
|
||||||
// Copyright © 2016年 AutoNavi. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import <AMapNaviKit/MAMapKit.h>
|
|
||||||
|
|
||||||
typedef NS_ENUM(NSInteger, NaviPointAnnotationType)
|
|
||||||
{
|
|
||||||
NaviPointAnnotationStart,
|
|
||||||
NaviPointAnnotationWay,
|
|
||||||
NaviPointAnnotationEnd
|
|
||||||
};
|
|
||||||
|
|
||||||
@interface NaviPointAnnotation : MAPointAnnotation
|
|
||||||
|
|
||||||
@property (nonatomic, assign) NaviPointAnnotationType navPointType;
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
//
|
|
||||||
// NaviPointAnnotation.m
|
|
||||||
// AMapNaviKit
|
|
||||||
//
|
|
||||||
// Created by 刘博 on 16/3/8.
|
|
||||||
// Copyright © 2016年 AutoNavi. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import "NaviPointAnnotation.h"
|
|
||||||
|
|
||||||
@implementation NaviPointAnnotation
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
//
|
|
||||||
// SelectableOverlay.h
|
|
||||||
// officialDemo2D
|
|
||||||
//
|
|
||||||
// Created by yi chen on 14-5-8.
|
|
||||||
// Copyright (c) 2014年 AutoNavi. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
#import <AMapNaviKit/MAMapKit.h>
|
|
||||||
|
|
||||||
@interface SelectableOverlay : MABaseOverlay
|
|
||||||
|
|
||||||
@property (nonatomic, assign) NSInteger routeID;
|
|
||||||
|
|
||||||
@property (nonatomic, assign, getter = isSelected) BOOL selected;
|
|
||||||
@property (nonatomic, strong) UIColor * selectedColor;
|
|
||||||
@property (nonatomic, strong) UIColor * regularColor;
|
|
||||||
|
|
||||||
@property (nonatomic, strong) id<MAOverlay> overlay;
|
|
||||||
|
|
||||||
- (id)initWithOverlay:(id<MAOverlay>) overlay;
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
//
|
|
||||||
// SelectableOverlay.m
|
|
||||||
// officialDemo2D
|
|
||||||
//
|
|
||||||
// Created by yi chen on 14-5-8.
|
|
||||||
// Copyright (c) 2014年 AutoNavi. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import "SelectableOverlay.h"
|
|
||||||
|
|
||||||
@implementation SelectableOverlay
|
|
||||||
|
|
||||||
#pragma mark - MAOverlay Protocol
|
|
||||||
|
|
||||||
- (CLLocationCoordinate2D)coordinate
|
|
||||||
{
|
|
||||||
return [self.overlay coordinate];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (MAMapRect)boundingMapRect
|
|
||||||
{
|
|
||||||
return [self.overlay boundingMapRect];
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - Life Cycle
|
|
||||||
|
|
||||||
- (id)initWithOverlay:(id<MAOverlay>)overlay
|
|
||||||
{
|
|
||||||
self = [super init];
|
|
||||||
if (self)
|
|
||||||
{
|
|
||||||
self.overlay = overlay;
|
|
||||||
self.selected = NO;
|
|
||||||
self.selectedColor = [UIColor colorWithRed:0.05 green:0.39 blue:0.9 alpha:0.8];
|
|
||||||
self.regularColor = [UIColor colorWithRed:0.5 green:0.6 blue:0.9 alpha:0.8];
|
|
||||||
}
|
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -31,12 +31,8 @@ require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelpe
|
|||||||
flutter_ios_podfile_setup
|
flutter_ios_podfile_setup
|
||||||
|
|
||||||
target 'Runner' do
|
target 'Runner' do
|
||||||
# use_frameworks!
|
use_frameworks!
|
||||||
use_frameworks! :linkage => :static
|
|
||||||
|
|
||||||
pod 'AMapNavIOSSDK' , :path => './AMapNavIOSSDK'
|
|
||||||
|
|
||||||
|
|
||||||
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
|
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
|
||||||
target 'RunnerTests' do
|
target 'RunnerTests' do
|
||||||
inherit! :search_paths
|
inherit! :search_paths
|
||||||
|
|||||||
@@ -1,30 +1,19 @@
|
|||||||
PODS:
|
PODS:
|
||||||
- AlicloudELS (1.0.3)
|
- AlicloudELS (1.0.3)
|
||||||
- AlicloudPush (3.2.3):
|
- AlicloudPush (3.2.3):
|
||||||
- AlicloudELS (~> 1.0.3)
|
- AlicloudELS (= 1.0.3)
|
||||||
- AlicloudUTDID (~> 1.0)
|
- AlicloudUTDID (~> 1.0)
|
||||||
- AlicloudUTDID (1.6.1)
|
- AlicloudUTDID (1.6.1)
|
||||||
- aliyun_push_flutter (0.0.1):
|
- aliyun_push_flutter (0.0.1):
|
||||||
- AlicloudPush (< 4.0, >= 3.2.3)
|
- AlicloudPush (< 4.0, >= 3.2.3)
|
||||||
- Flutter
|
- Flutter
|
||||||
- AMapFoundation-NO-IDFA (1.8.2)
|
|
||||||
- AMapLocation-NO-IDFA (2.11.0):
|
|
||||||
- AMapFoundation-NO-IDFA (>= 1.8.0)
|
|
||||||
- AMapNavi-NO-IDFA (10.1.600):
|
|
||||||
- AMapFoundation-NO-IDFA (>= 1.8.2)
|
|
||||||
- AMapNavIOSSDK (0.1.0):
|
|
||||||
- AMapLocation-NO-IDFA
|
|
||||||
- AMapNavi-NO-IDFA
|
|
||||||
- AMapSearch-NO-IDFA
|
|
||||||
- Masonry
|
|
||||||
- MJExtension
|
|
||||||
- AMapSearch-NO-IDFA (9.7.4):
|
|
||||||
- AMapFoundation-NO-IDFA (>= 1.8.0)
|
|
||||||
- connectivity_plus (0.0.1):
|
- connectivity_plus (0.0.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
- device_info_plus (0.0.1):
|
- device_info_plus (0.0.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
- Flutter (1.0.0)
|
- Flutter (1.0.0)
|
||||||
|
- flutter_app_update (0.0.1):
|
||||||
|
- Flutter
|
||||||
- flutter_inappwebview_ios (0.0.1):
|
- flutter_inappwebview_ios (0.0.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
- flutter_inappwebview_ios/Core (= 0.0.1)
|
- flutter_inappwebview_ios/Core (= 0.0.1)
|
||||||
@@ -41,8 +30,6 @@ PODS:
|
|||||||
- FlutterMacOS
|
- FlutterMacOS
|
||||||
- image_picker_ios (0.0.1):
|
- image_picker_ios (0.0.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
- Masonry (1.1.0)
|
|
||||||
- MJExtension (3.4.2)
|
|
||||||
- mobile_scanner (7.0.0):
|
- mobile_scanner (7.0.0):
|
||||||
- Flutter
|
- Flutter
|
||||||
- FlutterMacOS
|
- FlutterMacOS
|
||||||
@@ -62,10 +49,10 @@ PODS:
|
|||||||
|
|
||||||
DEPENDENCIES:
|
DEPENDENCIES:
|
||||||
- aliyun_push_flutter (from `.symlinks/plugins/aliyun_push_flutter/ios`)
|
- aliyun_push_flutter (from `.symlinks/plugins/aliyun_push_flutter/ios`)
|
||||||
- AMapNavIOSSDK (from `./AMapNavIOSSDK`)
|
|
||||||
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`)
|
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`)
|
||||||
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
|
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
|
||||||
- Flutter (from `Flutter`)
|
- Flutter (from `Flutter`)
|
||||||
|
- flutter_app_update (from `.symlinks/plugins/flutter_app_update/ios`)
|
||||||
- flutter_inappwebview_ios (from `.symlinks/plugins/flutter_inappwebview_ios/ios`)
|
- flutter_inappwebview_ios (from `.symlinks/plugins/flutter_inappwebview_ios/ios`)
|
||||||
- flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`)
|
- flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`)
|
||||||
- flutter_pdfview (from `.symlinks/plugins/flutter_pdfview/ios`)
|
- flutter_pdfview (from `.symlinks/plugins/flutter_pdfview/ios`)
|
||||||
@@ -85,25 +72,19 @@ SPEC REPOS:
|
|||||||
- AlicloudELS
|
- AlicloudELS
|
||||||
- AlicloudPush
|
- AlicloudPush
|
||||||
trunk:
|
trunk:
|
||||||
- AMapFoundation-NO-IDFA
|
|
||||||
- AMapLocation-NO-IDFA
|
|
||||||
- AMapNavi-NO-IDFA
|
|
||||||
- AMapSearch-NO-IDFA
|
|
||||||
- Masonry
|
|
||||||
- MJExtension
|
|
||||||
- OrderedSet
|
- OrderedSet
|
||||||
|
|
||||||
EXTERNAL SOURCES:
|
EXTERNAL SOURCES:
|
||||||
aliyun_push_flutter:
|
aliyun_push_flutter:
|
||||||
:path: ".symlinks/plugins/aliyun_push_flutter/ios"
|
:path: ".symlinks/plugins/aliyun_push_flutter/ios"
|
||||||
AMapNavIOSSDK:
|
|
||||||
:path: "./AMapNavIOSSDK"
|
|
||||||
connectivity_plus:
|
connectivity_plus:
|
||||||
:path: ".symlinks/plugins/connectivity_plus/ios"
|
:path: ".symlinks/plugins/connectivity_plus/ios"
|
||||||
device_info_plus:
|
device_info_plus:
|
||||||
:path: ".symlinks/plugins/device_info_plus/ios"
|
:path: ".symlinks/plugins/device_info_plus/ios"
|
||||||
Flutter:
|
Flutter:
|
||||||
:path: Flutter
|
:path: Flutter
|
||||||
|
flutter_app_update:
|
||||||
|
:path: ".symlinks/plugins/flutter_app_update/ios"
|
||||||
flutter_inappwebview_ios:
|
flutter_inappwebview_ios:
|
||||||
:path: ".symlinks/plugins/flutter_inappwebview_ios/ios"
|
:path: ".symlinks/plugins/flutter_inappwebview_ios/ios"
|
||||||
flutter_native_splash:
|
flutter_native_splash:
|
||||||
@@ -129,24 +110,18 @@ EXTERNAL SOURCES:
|
|||||||
|
|
||||||
SPEC CHECKSUMS:
|
SPEC CHECKSUMS:
|
||||||
AlicloudELS: fbf821383330465a5af84a033f36f263ae46ca41
|
AlicloudELS: fbf821383330465a5af84a033f36f263ae46ca41
|
||||||
AlicloudPush: 52cbf38ffc20c07f039cbc72d5738745fd986215
|
AlicloudPush: 95150880af380f64cf1741f5586047c17d36c1d9
|
||||||
AlicloudUTDID: 5d2f22d50e11eecd38f30bc7a48c71925ea90976
|
AlicloudUTDID: 5d2f22d50e11eecd38f30bc7a48c71925ea90976
|
||||||
aliyun_push_flutter: 0fc2f048a08687ef256c0cfdd72dd7a550ef3347
|
aliyun_push_flutter: 0fc2f048a08687ef256c0cfdd72dd7a550ef3347
|
||||||
AMapFoundation-NO-IDFA: 6ce0ef596d4eb8d934ff498e56747b6de1247b05
|
|
||||||
AMapLocation-NO-IDFA: 590fd42af0c8ea9eac26978348221bbc16be4ef9
|
|
||||||
AMapNavi-NO-IDFA: 22edfa7d6a81d75c91756e31b6c26b7746152233
|
|
||||||
AMapNavIOSSDK: ca325c9ac3378daea6a6be4bd8c34fe48d3ac896
|
|
||||||
AMapSearch-NO-IDFA: 53b2193244be8f07f3be0a4d5161200236960587
|
|
||||||
connectivity_plus: cb623214f4e1f6ef8fe7403d580fdad517d2f7dd
|
connectivity_plus: cb623214f4e1f6ef8fe7403d580fdad517d2f7dd
|
||||||
device_info_plus: 71ffc6ab7634ade6267c7a93088ed7e4f74e5896
|
device_info_plus: 71ffc6ab7634ade6267c7a93088ed7e4f74e5896
|
||||||
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
|
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
|
||||||
|
flutter_app_update: 816fdb2e30e4832a7c45e3f108d391c42ef040a9
|
||||||
flutter_inappwebview_ios: b89ba3482b96fb25e00c967aae065701b66e9b99
|
flutter_inappwebview_ios: b89ba3482b96fb25e00c967aae065701b66e9b99
|
||||||
flutter_native_splash: c32d145d68aeda5502d5f543ee38c192065986cf
|
flutter_native_splash: c32d145d68aeda5502d5f543ee38c192065986cf
|
||||||
flutter_pdfview: 32bf27bda6fd85b9dd2c09628a824df5081246cf
|
flutter_pdfview: 32bf27bda6fd85b9dd2c09628a824df5081246cf
|
||||||
geolocator_apple: ab36aa0e8b7d7a2d7639b3b4e48308394e8cef5e
|
geolocator_apple: ab36aa0e8b7d7a2d7639b3b4e48308394e8cef5e
|
||||||
image_picker_ios: e0ece4aa2a75771a7de3fa735d26d90817041326
|
image_picker_ios: e0ece4aa2a75771a7de3fa735d26d90817041326
|
||||||
Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
|
|
||||||
MJExtension: e97d164cb411aa9795cf576093a1fa208b4a8dd8
|
|
||||||
mobile_scanner: 9157936403f5a0644ca3779a38ff8404c5434a93
|
mobile_scanner: 9157936403f5a0644ca3779a38ff8404c5434a93
|
||||||
OrderedSet: e539b66b644ff081c73a262d24ad552a69be3a94
|
OrderedSet: e539b66b644ff081c73a262d24ad552a69be3a94
|
||||||
package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499
|
package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499
|
||||||
@@ -155,6 +130,6 @@ SPEC CHECKSUMS:
|
|||||||
shared_preferences_foundation: 7036424c3d8ec98dfe75ff1667cb0cd531ec82bb
|
shared_preferences_foundation: 7036424c3d8ec98dfe75ff1667cb0cd531ec82bb
|
||||||
url_launcher_ios: 7a95fa5b60cc718a708b8f2966718e93db0cef1b
|
url_launcher_ios: 7a95fa5b60cc718a708b8f2966718e93db0cef1b
|
||||||
|
|
||||||
PODFILE CHECKSUM: 97188da9dab9d4b3372eb4c16e872fbd555fdbea
|
PODFILE CHECKSUM: 357c01ff4e7591871e8c4fd6462220a8c7447220
|
||||||
|
|
||||||
COCOAPODS: 1.16.2
|
COCOAPODS: 1.16.2
|
||||||
|
|||||||
@@ -8,12 +8,11 @@
|
|||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
|
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
|
||||||
298D3D45379E4332D4A8A627 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 95135D36941D5EF2C00065B2 /* Pods_Runner.framework */; };
|
307490676CE2A16C8D75B103 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 937F9432963895EF63BCCD38 /* Pods_RunnerTests.framework */; };
|
||||||
331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; };
|
331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; };
|
||||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
||||||
3F21125D6B84D3CC58F3C574 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 85810788944AB2417549F45E /* Pods_RunnerTests.framework */; };
|
59E555C098DB12132BCE9F6E /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6AF04C5CFFF0B4098EEDA799 /* Pods_Runner.framework */; };
|
||||||
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
|
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
|
||||||
8420D0082F3D9F7E006DB6CC /* NativeFirstPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8420D0072F3D9F7E006DB6CC /* NativeFirstPage.swift */; };
|
|
||||||
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
|
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
|
||||||
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
|
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
|
||||||
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
|
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
|
||||||
@@ -50,14 +49,13 @@
|
|||||||
331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
|
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
|
||||||
4B58A54CFC9A912F2BA04FF2 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
|
4B58A54CFC9A912F2BA04FF2 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
|
||||||
|
6AF04C5CFFF0B4098EEDA799 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
6D3F89E22F04C32900A154AD /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
|
6D3F89E22F04C32900A154AD /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
|
||||||
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
|
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||||
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
|
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
|
||||||
8420D0072F3D9F7E006DB6CC /* NativeFirstPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativeFirstPage.swift; sourceTree = "<group>"; };
|
|
||||||
85810788944AB2417549F45E /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
||||||
87773E6EB1B2C64DA1B1FA42 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = "<group>"; };
|
87773E6EB1B2C64DA1B1FA42 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = "<group>"; };
|
||||||
95135D36941D5EF2C00065B2 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
937F9432963895EF63BCCD38 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
|
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
|
||||||
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
|
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
|
||||||
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
@@ -75,7 +73,7 @@
|
|||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
298D3D45379E4332D4A8A627 /* Pods_Runner.framework in Frameworks */,
|
59E555C098DB12132BCE9F6E /* Pods_Runner.framework in Frameworks */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -83,7 +81,7 @@
|
|||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
3F21125D6B84D3CC58F3C574 /* Pods_RunnerTests.framework in Frameworks */,
|
307490676CE2A16C8D75B103 /* Pods_RunnerTests.framework in Frameworks */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -154,7 +152,6 @@
|
|||||||
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
|
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
|
||||||
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
|
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
|
||||||
74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
|
74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
|
||||||
8420D0072F3D9F7E006DB6CC /* NativeFirstPage.swift */,
|
|
||||||
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
|
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
|
||||||
);
|
);
|
||||||
path = Runner;
|
path = Runner;
|
||||||
@@ -163,8 +160,8 @@
|
|||||||
E621C70ABD0685462494972D /* Frameworks */ = {
|
E621C70ABD0685462494972D /* Frameworks */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
95135D36941D5EF2C00065B2 /* Pods_Runner.framework */,
|
6AF04C5CFFF0B4098EEDA799 /* Pods_Runner.framework */,
|
||||||
85810788944AB2417549F45E /* Pods_RunnerTests.framework */,
|
937F9432963895EF63BCCD38 /* Pods_RunnerTests.framework */,
|
||||||
);
|
);
|
||||||
name = Frameworks;
|
name = Frameworks;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -202,6 +199,7 @@
|
|||||||
97C146EC1CF9000F007C117D /* Resources */,
|
97C146EC1CF9000F007C117D /* Resources */,
|
||||||
9705A1C41CF9048500538489 /* Embed Frameworks */,
|
9705A1C41CF9048500538489 /* Embed Frameworks */,
|
||||||
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
|
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
|
||||||
|
590CF992B35CC61AF9AA4341 /* [CP] Embed Pods Frameworks */,
|
||||||
AF570E8AAEEA12D52BD19B4E /* [CP] Copy Pods Resources */,
|
AF570E8AAEEA12D52BD19B4E /* [CP] Copy Pods Resources */,
|
||||||
);
|
);
|
||||||
buildRules = (
|
buildRules = (
|
||||||
@@ -290,6 +288,23 @@
|
|||||||
shellPath = /bin/sh;
|
shellPath = /bin/sh;
|
||||||
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
|
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
|
||||||
};
|
};
|
||||||
|
590CF992B35CC61AF9AA4341 /* [CP] Embed Pods Frameworks */ = {
|
||||||
|
isa = PBXShellScriptBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
inputFileListPaths = (
|
||||||
|
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
|
||||||
|
);
|
||||||
|
name = "[CP] Embed Pods Frameworks";
|
||||||
|
outputFileListPaths = (
|
||||||
|
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
shellPath = /bin/sh;
|
||||||
|
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
|
||||||
|
showEnvVarsInLog = 0;
|
||||||
|
};
|
||||||
9740EEB61CF901F6004384FC /* Run Script */ = {
|
9740EEB61CF901F6004384FC /* Run Script */ = {
|
||||||
isa = PBXShellScriptBuildPhase;
|
isa = PBXShellScriptBuildPhase;
|
||||||
alwaysOutOfDate = 1;
|
alwaysOutOfDate = 1;
|
||||||
@@ -357,14 +372,10 @@
|
|||||||
inputFileListPaths = (
|
inputFileListPaths = (
|
||||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
|
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
|
||||||
);
|
);
|
||||||
inputPaths = (
|
|
||||||
);
|
|
||||||
name = "[CP] Copy Pods Resources";
|
name = "[CP] Copy Pods Resources";
|
||||||
outputFileListPaths = (
|
outputFileListPaths = (
|
||||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
|
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
|
||||||
);
|
);
|
||||||
outputPaths = (
|
|
||||||
);
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
shellPath = /bin/sh;
|
shellPath = /bin/sh;
|
||||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
|
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
|
||||||
@@ -385,7 +396,6 @@
|
|||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
8420D0082F3D9F7E006DB6CC /* NativeFirstPage.swift in Sources */,
|
|
||||||
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
|
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
|
||||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
|
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
|
||||||
);
|
);
|
||||||
@@ -516,6 +526,8 @@
|
|||||||
"-framework",
|
"-framework",
|
||||||
"\"package_info_plus\"",
|
"\"package_info_plus\"",
|
||||||
"-framework",
|
"-framework",
|
||||||
|
"\"path_provider_foundation\"",
|
||||||
|
"-framework",
|
||||||
"\"permission_handler_apple\"",
|
"\"permission_handler_apple\"",
|
||||||
"-framework",
|
"-framework",
|
||||||
"\"shared_preferences_foundation\"",
|
"\"shared_preferences_foundation\"",
|
||||||
@@ -553,6 +565,8 @@
|
|||||||
"-framework",
|
"-framework",
|
||||||
"\"package_info_plus\"",
|
"\"package_info_plus\"",
|
||||||
"-framework",
|
"-framework",
|
||||||
|
"\"path_provider_foundation\"",
|
||||||
|
"-framework",
|
||||||
"\"permission_handler_apple\"",
|
"\"permission_handler_apple\"",
|
||||||
"-framework",
|
"-framework",
|
||||||
"\"shared_preferences_foundation\"",
|
"\"shared_preferences_foundation\"",
|
||||||
@@ -780,6 +794,8 @@
|
|||||||
"-framework",
|
"-framework",
|
||||||
"\"package_info_plus\"",
|
"\"package_info_plus\"",
|
||||||
"-framework",
|
"-framework",
|
||||||
|
"\"path_provider_foundation\"",
|
||||||
|
"-framework",
|
||||||
"\"permission_handler_apple\"",
|
"\"permission_handler_apple\"",
|
||||||
"-framework",
|
"-framework",
|
||||||
"\"shared_preferences_foundation\"",
|
"\"shared_preferences_foundation\"",
|
||||||
@@ -817,6 +833,8 @@
|
|||||||
"-framework",
|
"-framework",
|
||||||
"\"package_info_plus\"",
|
"\"package_info_plus\"",
|
||||||
"-framework",
|
"-framework",
|
||||||
|
"\"path_provider_foundation\"",
|
||||||
|
"-framework",
|
||||||
"\"permission_handler_apple\"",
|
"\"permission_handler_apple\"",
|
||||||
"-framework",
|
"-framework",
|
||||||
"\"shared_preferences_foundation\"",
|
"\"shared_preferences_foundation\"",
|
||||||
@@ -881,6 +899,8 @@
|
|||||||
"-framework",
|
"-framework",
|
||||||
"\"package_info_plus\"",
|
"\"package_info_plus\"",
|
||||||
"-framework",
|
"-framework",
|
||||||
|
"\"path_provider_foundation\"",
|
||||||
|
"-framework",
|
||||||
"\"permission_handler_apple\"",
|
"\"permission_handler_apple\"",
|
||||||
"-framework",
|
"-framework",
|
||||||
"\"shared_preferences_foundation\"",
|
"\"shared_preferences_foundation\"",
|
||||||
|
|||||||
@@ -61,7 +61,6 @@
|
|||||||
ignoresPersistentStateOnLaunch = "NO"
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
debugDocumentVersioning = "YES"
|
debugDocumentVersioning = "YES"
|
||||||
debugServiceExtension = "internal"
|
debugServiceExtension = "internal"
|
||||||
enableGPUFrameCaptureMode = "3"
|
|
||||||
enableGPUValidationMode = "1"
|
enableGPUValidationMode = "1"
|
||||||
allowLocationSimulation = "YES">
|
allowLocationSimulation = "YES">
|
||||||
<BuildableProductRunnable
|
<BuildableProductRunnable
|
||||||
|
|||||||
@@ -1,86 +1,13 @@
|
|||||||
import Flutter
|
import Flutter
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
///
|
|
||||||
let kAMapKey = "3ac08e5e14df9d7a52e98d40e21a0189";
|
|
||||||
|
|
||||||
|
|
||||||
@main
|
@main
|
||||||
@objc class AppDelegate: FlutterAppDelegate {
|
@objc class AppDelegate: FlutterAppDelegate {
|
||||||
override func application(
|
override func application(
|
||||||
_ application: UIApplication,
|
_ application: UIApplication,
|
||||||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
||||||
) -> Bool {
|
) -> Bool {
|
||||||
|
GeneratedPluginRegistrant.register(with: self)
|
||||||
GeneratedPluginRegistrant.register(with: self)
|
|
||||||
|
|
||||||
AMapNavSDKManager.shared().config(withKey: kAMapKey)
|
|
||||||
|
|
||||||
// 注册平台视图工厂
|
|
||||||
let registrar = self.registrar(forPlugin: "NativeFirstPagePlugin")
|
|
||||||
|
|
||||||
let controller = window?.rootViewController as! FlutterViewController
|
|
||||||
let nativeViewFactory = NativeViewFactory(messenger: controller.binaryMessenger)
|
|
||||||
|
|
||||||
registrar?.register(
|
|
||||||
nativeViewFactory,
|
|
||||||
withId: "NativeFirstPage"
|
|
||||||
)
|
|
||||||
|
|
||||||
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 创建视图工厂
|
|
||||||
class NativeViewFactory: NSObject, FlutterPlatformViewFactory {
|
|
||||||
private var messenger: FlutterBinaryMessenger
|
|
||||||
|
|
||||||
init(messenger: FlutterBinaryMessenger) {
|
|
||||||
self.messenger = messenger
|
|
||||||
super.init()
|
|
||||||
}
|
|
||||||
|
|
||||||
func create(
|
|
||||||
withFrame frame: CGRect,
|
|
||||||
viewIdentifier viewId: Int64,
|
|
||||||
arguments args: Any?
|
|
||||||
) -> FlutterPlatformView {
|
|
||||||
return NativeFlutterView(frame: frame, viewId: viewId, args: args)
|
|
||||||
}
|
|
||||||
|
|
||||||
func createArgsCodec() -> FlutterMessageCodec & NSObjectProtocol {
|
|
||||||
return FlutterStandardMessageCodec.sharedInstance()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class NativeFlutterView: NSObject, FlutterPlatformView {
|
|
||||||
private var _view: UIView
|
|
||||||
private var _nativeVC: UIViewController
|
|
||||||
|
|
||||||
init(frame: CGRect, viewId: Int64, args: Any?) {
|
|
||||||
// 创建原生的 ViewController 视图
|
|
||||||
let nativeVC = AMapNavSDKManager.shared().targetVC;
|
|
||||||
// let nativeVC = NativeFirstPage();
|
|
||||||
|
|
||||||
self._nativeVC = nativeVC
|
|
||||||
|
|
||||||
print("---frame: \(frame)");
|
|
||||||
|
|
||||||
_view = nativeVC.view
|
|
||||||
_view.isUserInteractionEnabled = true
|
|
||||||
_view.frame = CGRectMake(0, 0, CGRectGetWidth(frame), CGRectGetHeight(frame))
|
|
||||||
super.init()
|
|
||||||
}
|
|
||||||
|
|
||||||
func view() -> UIView {
|
|
||||||
return _view
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
"size" : "20x20"
|
"size" : "20x20"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename" : "Icon-App-29x29 1.png",
|
"filename" : "Icon-App-29x29@1x.png",
|
||||||
"idiom" : "iphone",
|
"idiom" : "iphone",
|
||||||
"scale" : "1x",
|
"scale" : "1x",
|
||||||
"size" : "29x29"
|
"size" : "29x29"
|
||||||
@@ -31,25 +31,25 @@
|
|||||||
"size" : "29x29"
|
"size" : "29x29"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename" : "Icon-App-80x80.png",
|
"filename" : "Icon-App-80x80.jpg",
|
||||||
"idiom" : "iphone",
|
"idiom" : "iphone",
|
||||||
"scale" : "2x",
|
"scale" : "2x",
|
||||||
"size" : "40x40"
|
"size" : "40x40"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename" : "Icon-App-120x120.png",
|
"filename" : "Icon-App-120x120.jpg",
|
||||||
"idiom" : "iphone",
|
"idiom" : "iphone",
|
||||||
"scale" : "3x",
|
"scale" : "3x",
|
||||||
"size" : "40x40"
|
"size" : "40x40"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename" : "Icon-App-120x120 1.png",
|
"filename" : "Icon-App-120x120 1.jpg",
|
||||||
"idiom" : "iphone",
|
"idiom" : "iphone",
|
||||||
"scale" : "2x",
|
"scale" : "2x",
|
||||||
"size" : "60x60"
|
"size" : "60x60"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename" : "Icon-App-180.png",
|
"filename" : "Icon-App-180.jpg",
|
||||||
"idiom" : "iphone",
|
"idiom" : "iphone",
|
||||||
"scale" : "3x",
|
"scale" : "3x",
|
||||||
"size" : "60x60"
|
"size" : "60x60"
|
||||||
@@ -61,19 +61,19 @@
|
|||||||
"size" : "20x20"
|
"size" : "20x20"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename" : "Icon-App-20x20@2x 1.png",
|
"filename" : "Icon-App-20x20@2x.png",
|
||||||
"idiom" : "ipad",
|
"idiom" : "ipad",
|
||||||
"scale" : "2x",
|
"scale" : "2x",
|
||||||
"size" : "20x20"
|
"size" : "20x20"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename" : "Icon-App-29x29.png",
|
"filename" : "Icon-App-29x29@1x.png",
|
||||||
"idiom" : "ipad",
|
"idiom" : "ipad",
|
||||||
"scale" : "1x",
|
"scale" : "1x",
|
||||||
"size" : "29x29"
|
"size" : "29x29"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename" : "Icon-App-29x29@2x 1.png",
|
"filename" : "Icon-App-29x29@2x.png",
|
||||||
"idiom" : "ipad",
|
"idiom" : "ipad",
|
||||||
"scale" : "2x",
|
"scale" : "2x",
|
||||||
"size" : "29x29"
|
"size" : "29x29"
|
||||||
@@ -91,7 +91,7 @@
|
|||||||
"size" : "40x40"
|
"size" : "40x40"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename" : "Icon-App-76x76.png",
|
"filename" : "Icon-App-76x76@1x.png",
|
||||||
"idiom" : "ipad",
|
"idiom" : "ipad",
|
||||||
"scale" : "1x",
|
"scale" : "1x",
|
||||||
"size" : "76x76"
|
"size" : "76x76"
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 465 B After Width: | Height: | Size: 509 B |
|
Before Width: | Height: | Size: 849 B |
|
Before Width: | Height: | Size: 849 B After Width: | Height: | Size: 848 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 613 B |
|
Before Width: | Height: | Size: 613 B |
|
After Width: | Height: | Size: 707 B |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 5.0 KiB |
@@ -2,6 +2,8 @@
|
|||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
|
<key></key>
|
||||||
|
<string></string>
|
||||||
<key>CADisableMinimumFrameDurationOnPhone</key>
|
<key>CADisableMinimumFrameDurationOnPhone</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>CFBundleDevelopmentRegion</key>
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
@@ -14,11 +16,6 @@
|
|||||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||||
<key>CFBundleInfoDictionaryVersion</key>
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
<string>6.0</string>
|
<string>6.0</string>
|
||||||
<key>CFBundleLocalizations</key>
|
|
||||||
<array>
|
|
||||||
<string>zh-Hans</string>
|
|
||||||
<string>en</string>
|
|
||||||
</array>
|
|
||||||
<key>CFBundleName</key>
|
<key>CFBundleName</key>
|
||||||
<string>ln_jq_app</string>
|
<string>ln_jq_app</string>
|
||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
@@ -31,10 +28,6 @@
|
|||||||
<string>$(FLUTTER_BUILD_NUMBER)</string>
|
<string>$(FLUTTER_BUILD_NUMBER)</string>
|
||||||
<key>ITSAppUsesNonExemptEncryption</key>
|
<key>ITSAppUsesNonExemptEncryption</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>LSApplicationQueriesSchemes</key>
|
|
||||||
<array>
|
|
||||||
<string>iosamap</string>
|
|
||||||
</array>
|
|
||||||
<key>LSRequiresIPhoneOS</key>
|
<key>LSRequiresIPhoneOS</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSCameraUsageDescription</key>
|
<key>NSCameraUsageDescription</key>
|
||||||
@@ -51,12 +44,6 @@
|
|||||||
<string>需要访问您的相册以选择二维码图片进行识别</string>
|
<string>需要访问您的相册以选择二维码图片进行识别</string>
|
||||||
<key>UIApplicationSupportsIndirectInputEvents</key>
|
<key>UIApplicationSupportsIndirectInputEvents</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>UIBackgroundModes</key>
|
|
||||||
<array>
|
|
||||||
<string>remote-notification</string>
|
|
||||||
<string>fetch</string>
|
|
||||||
<string>location</string>
|
|
||||||
</array>
|
|
||||||
<key>UILaunchStoryboardName</key>
|
<key>UILaunchStoryboardName</key>
|
||||||
<string>LaunchScreen</string>
|
<string>LaunchScreen</string>
|
||||||
<key>UIMainStoryboardFile</key>
|
<key>UIMainStoryboardFile</key>
|
||||||
@@ -76,5 +63,18 @@
|
|||||||
</array>
|
</array>
|
||||||
<key>uses</key>
|
<key>uses</key>
|
||||||
<string></string>
|
<string></string>
|
||||||
|
|
||||||
|
<key>UIBackgroundModes</key>
|
||||||
|
<array>
|
||||||
|
<string>remote-notification</string>
|
||||||
|
<string>fetch</string>
|
||||||
|
</array>
|
||||||
|
|
||||||
|
<key>CFBundleLocalizations</key>
|
||||||
|
<array>
|
||||||
|
<string>zh-Hans</string>
|
||||||
|
<string>en</string>
|
||||||
|
</array>
|
||||||
|
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
@@ -1,66 +0,0 @@
|
|||||||
//
|
|
||||||
// NativeFirstPage.swift
|
|
||||||
// Runner
|
|
||||||
//
|
|
||||||
// Created by admin on 2026/2/9.
|
|
||||||
//
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
class NativeFirstPage: UIViewController {
|
|
||||||
var lable:UILabel!
|
|
||||||
|
|
||||||
override func viewDidLoad() {
|
|
||||||
super.viewDidLoad()
|
|
||||||
|
|
||||||
// Do any additional setup after loading the view.
|
|
||||||
view.backgroundColor = .white
|
|
||||||
|
|
||||||
// 创建原生UI
|
|
||||||
let label = UILabel()
|
|
||||||
label.text = "iOS 原生页面."
|
|
||||||
label.font = UIFont.systemFont(ofSize: 24, weight: .bold)
|
|
||||||
label.textAlignment = .center
|
|
||||||
label.translatesAutoresizingMaskIntoConstraints = false
|
|
||||||
|
|
||||||
let button = UIButton(type: .custom)
|
|
||||||
button.setTitle("点击原生按钮", for: .normal)
|
|
||||||
button.titleLabel?.font = UIFont.systemFont(ofSize: 18)
|
|
||||||
button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)
|
|
||||||
button.translatesAutoresizingMaskIntoConstraints = false
|
|
||||||
button.backgroundColor = .blue
|
|
||||||
|
|
||||||
view.addSubview(label)
|
|
||||||
view.addSubview(button)
|
|
||||||
|
|
||||||
NSLayoutConstraint.activate([
|
|
||||||
label.centerXAnchor.constraint(equalTo: view.centerXAnchor),
|
|
||||||
label.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: -50),
|
|
||||||
|
|
||||||
button.topAnchor.constraint(equalTo: label.bottomAnchor, constant: 30),
|
|
||||||
button.centerXAnchor.constraint(equalTo: view.centerXAnchor)
|
|
||||||
])
|
|
||||||
|
|
||||||
self.lable = label
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc func buttonTapped() {
|
|
||||||
self.lable.text = "click...";
|
|
||||||
|
|
||||||
// 原生按钮点击事件
|
|
||||||
let alert = UIAlertController(
|
|
||||||
title: "原生弹窗",
|
|
||||||
message: "来自 iOS 原生的提示",
|
|
||||||
preferredStyle: .alert
|
|
||||||
)
|
|
||||||
alert.addAction(UIAlertAction(title: "确定", style: .default))
|
|
||||||
present(alert, animated: true)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
|
|
||||||
view.backgroundColor = .orange
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,2 +1 @@
|
|||||||
#import "GeneratedPluginRegistrant.h"
|
#import "GeneratedPluginRegistrant.h"
|
||||||
#import <AMapNavSDKManager.h>
|
|
||||||
|
|||||||
@@ -4,9 +4,5 @@
|
|||||||
<dict>
|
<dict>
|
||||||
<key>aps-environment</key>
|
<key>aps-environment</key>
|
||||||
<string>development</string>
|
<string>development</string>
|
||||||
<key>com.apple.developer.background-tasks.continued-processing.gpu</key>
|
|
||||||
<true/>
|
|
||||||
<key>com.apple.developer.location.push</key>
|
|
||||||
<true/>
|
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
22
ln_jq_app/lib/common/AuthGuard.dart
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import 'package:getx_scaffold/common/index.dart';
|
||||||
|
import 'package:ln_jq_app/pages/login/view.dart';
|
||||||
|
import 'package:ln_jq_app/storage_service.dart';
|
||||||
|
|
||||||
|
class AuthGuard {
|
||||||
|
static bool _handling401 = false;
|
||||||
|
|
||||||
|
static Future<void> handle401(String? message) async {
|
||||||
|
if (_handling401) return;
|
||||||
|
_handling401 = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await StorageService.to.clearLoginInfo();
|
||||||
|
Get.offAll(() => const LoginPage());
|
||||||
|
} finally {
|
||||||
|
// 防止意外卡死,可视情况是否延迟重置
|
||||||
|
Future.delayed(const Duration(seconds: 1), () {
|
||||||
|
_handling401 = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,7 +4,9 @@ class StationModel {
|
|||||||
final String address;
|
final String address;
|
||||||
final String price;
|
final String price;
|
||||||
final String siteStatusName; // 例如 "维修中"
|
final String siteStatusName; // 例如 "维修中"
|
||||||
final int isSelect; // 新增字段 1是可用 0是不可用
|
final int isSelect; // 1是可用 0是不可用
|
||||||
|
final String startBusiness; // 新增:可预约最早开始时间,如 "06:00:00"
|
||||||
|
final String endBusiness; // 新增:可预约最晚结束时间,如 "22:00:00"
|
||||||
|
|
||||||
StationModel({
|
StationModel({
|
||||||
required this.hydrogenId,
|
required this.hydrogenId,
|
||||||
@@ -13,9 +15,10 @@ class StationModel {
|
|||||||
required this.price,
|
required this.price,
|
||||||
required this.siteStatusName,
|
required this.siteStatusName,
|
||||||
required this.isSelect,
|
required this.isSelect,
|
||||||
|
required this.startBusiness,
|
||||||
|
required this.endBusiness,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 从 JSON map 创建对象的工厂构造函数
|
|
||||||
factory StationModel.fromJson(Map<String, dynamic> json) {
|
factory StationModel.fromJson(Map<String, dynamic> json) {
|
||||||
return StationModel(
|
return StationModel(
|
||||||
hydrogenId: json['hydrogenId'] ?? '',
|
hydrogenId: json['hydrogenId'] ?? '',
|
||||||
@@ -23,7 +26,9 @@ class StationModel {
|
|||||||
address: json['address'] ?? '地址未知',
|
address: json['address'] ?? '地址未知',
|
||||||
price: json['price']?.toString() ?? '0.00',
|
price: json['price']?.toString() ?? '0.00',
|
||||||
siteStatusName: json['siteStatusName'] ?? '',
|
siteStatusName: json['siteStatusName'] ?? '',
|
||||||
isSelect: json['isSelect'] as int? ?? 0, // 新增字段的解析,默认为 0
|
isSelect: json['isSelect'] as int? ?? 0,
|
||||||
|
startBusiness: json['startBusiness'] ?? '00:00:00', // 默认全天
|
||||||
|
endBusiness: json['endBusiness'] ?? '23:59:59', // 默认全天
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class AppTheme {
|
|||||||
static const Color themeColor = Color(0xFF017137);
|
static const Color themeColor = Color(0xFF017137);
|
||||||
|
|
||||||
//是否开放域名切换
|
//是否开放域名切换
|
||||||
static const bool is_show_host = false;
|
static const bool is_show_host = true;
|
||||||
|
|
||||||
//http://192.168.110.222:8080/
|
//http://192.168.110.222:8080/
|
||||||
//http://192.168.110.44:8080/
|
//http://192.168.110.44:8080/
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:flutter_localizations/flutter_localizations.dart';
|
|||||||
import 'package:flutter_native_splash/flutter_native_splash.dart';
|
import 'package:flutter_native_splash/flutter_native_splash.dart';
|
||||||
import 'package:get_storage/get_storage.dart';
|
import 'package:get_storage/get_storage.dart';
|
||||||
import 'package:getx_scaffold/getx_scaffold.dart';
|
import 'package:getx_scaffold/getx_scaffold.dart';
|
||||||
|
import 'package:ln_jq_app/common/AuthGuard.dart';
|
||||||
import 'package:ln_jq_app/common/model/base_model.dart';
|
import 'package:ln_jq_app/common/model/base_model.dart';
|
||||||
import 'package:ln_jq_app/common/token_interceptor.dart';
|
import 'package:ln_jq_app/common/token_interceptor.dart';
|
||||||
import 'package:ln_jq_app/storage_service.dart';
|
import 'package:ln_jq_app/storage_service.dart';
|
||||||
@@ -20,7 +21,7 @@ void main() async {
|
|||||||
logTag: '小羚羚',
|
logTag: '小羚羚',
|
||||||
supportedLocales: [const Locale('zh', 'CN')],
|
supportedLocales: [const Locale('zh', 'CN')],
|
||||||
);
|
);
|
||||||
|
|
||||||
// 保持原生闪屏页,直到 WelcomeController 调用 remove()
|
// 保持原生闪屏页,直到 WelcomeController 调用 remove()
|
||||||
FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
|
FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
|
||||||
|
|
||||||
@@ -65,19 +66,16 @@ void main() async {
|
|||||||
void initHttpSet() {
|
void initHttpSet() {
|
||||||
AppTheme.test_service_url = StorageService.to.hostUrl ?? AppTheme.test_service_url;
|
AppTheme.test_service_url = StorageService.to.hostUrl ?? AppTheme.test_service_url;
|
||||||
|
|
||||||
|
HttpService.to.init(timeout: 15);
|
||||||
HttpService.to.setBaseUrl(AppTheme.test_service_url);
|
HttpService.to.setBaseUrl(AppTheme.test_service_url);
|
||||||
HttpService.to.dio.interceptors.add(TokenInterceptor(tokenKey: 'asoco-token'));
|
HttpService.to.dio.interceptors.add(TokenInterceptor(tokenKey: 'asoco-token'));
|
||||||
HttpService.to.setOnResponseHandler((response) async {
|
HttpService.to.setOnResponseHandler((response) async {
|
||||||
try {
|
try {
|
||||||
if (response.data == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final baseModel = BaseModel.fromJson(response.data);
|
final baseModel = BaseModel.fromJson(response.data);
|
||||||
if (baseModel.code == 0 || baseModel.code == 200) {
|
if (baseModel.code == 0 || baseModel.code == 200) {
|
||||||
return null;
|
return null;
|
||||||
} else if (baseModel.code == 401) {
|
} else if (baseModel.code == 401) {
|
||||||
await StorageService.to.clearLoginInfo();
|
await AuthGuard.handle401(baseModel.message);
|
||||||
Get.offAll(() => const LoginPage());
|
|
||||||
return baseModel.message;
|
return baseModel.message;
|
||||||
} else {
|
} else {
|
||||||
return (baseModel.error.toString()).isEmpty
|
return (baseModel.error.toString()).isEmpty
|
||||||
|
|||||||
@@ -1,82 +0,0 @@
|
|||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/gestures.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
|
|
||||||
/// 原生地图页面
|
|
||||||
class NativePageIOS extends StatelessWidget {
|
|
||||||
const NativePageIOS({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
if (Platform.isIOS) {
|
|
||||||
return _buildIOSView(context);
|
|
||||||
} else if (Platform.isAndroid) {
|
|
||||||
return _buildAndroidView(context);
|
|
||||||
} else {
|
|
||||||
return const Center(
|
|
||||||
child: Text('不支持的平台', style: TextStyle(fontSize: 16)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 构建iOS Platform View
|
|
||||||
Widget _buildIOSView(BuildContext context) {
|
|
||||||
return Container(
|
|
||||||
width: MediaQuery.of(context).size.width,
|
|
||||||
height: MediaQuery.of(context).size.height - 100,
|
|
||||||
color: Colors.white,
|
|
||||||
child: UiKitView(
|
|
||||||
viewType: 'NativeFirstPage', // 与iOS原生端注册的标识一致
|
|
||||||
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>{}.toSet(),
|
|
||||||
hitTestBehavior: PlatformViewHitTestBehavior.opaque,
|
|
||||||
creationParamsCodec: const StandardMessageCodec(),
|
|
||||||
layoutDirection: TextDirection.ltr,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 构建Android Platform View
|
|
||||||
Widget _buildAndroidView(BuildContext context) {
|
|
||||||
return Container(
|
|
||||||
width: MediaQuery.of(context).size.width,
|
|
||||||
height: MediaQuery.of(context).size.height - 100,
|
|
||||||
color: Colors.white,
|
|
||||||
child: AndroidView(
|
|
||||||
viewType: 'NativeFirstPage', // 与Android原生端注册的标识一致
|
|
||||||
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>{}.toSet(),
|
|
||||||
hitTestBehavior: PlatformViewHitTestBehavior.opaque,
|
|
||||||
creationParamsCodec: const StandardMessageCodec(),
|
|
||||||
layoutDirection: TextDirection.ltr,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 处理点击事件(如需要)
|
|
||||||
void _handleTap(BuildContext context) {
|
|
||||||
if (kDebugMode) {
|
|
||||||
print("NativePage被点击");
|
|
||||||
}
|
|
||||||
_showDialog(context, '提示', '点击了原生地图页面');
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 显示对话框
|
|
||||||
void _showDialog(BuildContext context, String title, String content) {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) => AlertDialog(
|
|
||||||
title: Text(title),
|
|
||||||
content: Text(content),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Navigator.pop(context),
|
|
||||||
child: const Text('确定'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
import 'package:getx_scaffold/getx_scaffold.dart';
|
import 'package:getx_scaffold/getx_scaffold.dart';
|
||||||
import 'package:ln_jq_app/common/login_util.dart';
|
import 'package:ln_jq_app/common/login_util.dart';
|
||||||
import 'package:ln_jq_app/pages/c_page/base_widgets/NativePageIOS.dart';
|
|
||||||
import 'package:ln_jq_app/pages/c_page/car_info/view.dart';
|
import 'package:ln_jq_app/pages/c_page/car_info/view.dart';
|
||||||
|
import 'package:ln_jq_app/pages/c_page/map/view.dart';
|
||||||
import 'package:ln_jq_app/pages/c_page/mine/view.dart';
|
import 'package:ln_jq_app/pages/c_page/mine/view.dart';
|
||||||
import 'package:ln_jq_app/pages/c_page/reservation/view.dart';
|
import 'package:ln_jq_app/pages/c_page/reservation/view.dart';
|
||||||
|
|
||||||
@@ -32,7 +33,7 @@ class BaseWidgetsPage extends GetView<BaseWidgetsController> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> _buildPages() {
|
List<Widget> _buildPages() {
|
||||||
return [ReservationPage(), NativePageIOS(), CarInfoPage(), MinePage()];
|
return [ReservationPage(), MapPage(), CarInfoPage(), MinePage()];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 自定义导航栏 (悬浮胶囊样式)
|
// 自定义导航栏 (悬浮胶囊样式)
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ class CarInfoController extends GetxController with BaseControllerMixin {
|
|||||||
|
|
||||||
// --- 车辆基本信息 ---
|
// --- 车辆基本信息 ---
|
||||||
String plateNumber = "";
|
String plateNumber = "";
|
||||||
String vin = "未知";
|
String vin = "-";
|
||||||
String modelName = "未知";
|
String modelName = "-";
|
||||||
String brandName = "未知";
|
String brandName = "-";
|
||||||
|
|
||||||
// --- 证件附件列表 ---
|
// --- 证件附件列表 ---
|
||||||
final RxList<String> drivingAttachments = <String>[].obs;
|
final RxList<String> drivingAttachments = <String>[].obs;
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ class CarInfoPage extends GetView<CarInfoController> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () async{
|
onPressed: () async {
|
||||||
var scanResult = await Get.to(() => const MessagePage());
|
var scanResult = await Get.to(() => const MessagePage());
|
||||||
if (scanResult == null) {
|
if (scanResult == null) {
|
||||||
controller.msgNotice();
|
controller.msgNotice();
|
||||||
@@ -163,11 +163,26 @@ class CarInfoPage extends GetView<CarInfoController> {
|
|||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
_buildModernStatItem('本月里程数', 'Accumulated', '2,852km', ''),
|
_buildModernStatItem(
|
||||||
|
'本月里程数',
|
||||||
|
'Accumulated',
|
||||||
|
StorageService.to.hasVehicleInfo ? '2,852km' : '-',
|
||||||
|
'',
|
||||||
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
_buildModernStatItem('总里程', 'Refuel Count', "2.5W km", ''),
|
_buildModernStatItem(
|
||||||
|
'总里程',
|
||||||
|
'Refuel Count',
|
||||||
|
StorageService.to.hasVehicleInfo ? "2.5W km" : '-',
|
||||||
|
'',
|
||||||
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
_buildModernStatItem('服务评分', 'Driver rating', "4.9分", ''),
|
_buildModernStatItem(
|
||||||
|
'服务评分',
|
||||||
|
'Driver rating',
|
||||||
|
StorageService.to.hasVehicleInfo ? "4.9分" : '-',
|
||||||
|
'',
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -300,20 +315,20 @@ class CarInfoPage extends GetView<CarInfoController> {
|
|||||||
children: [
|
children: [
|
||||||
ClipRRect(
|
ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(4),
|
borderRadius: BorderRadius.circular(4),
|
||||||
child: const LinearProgressIndicator(
|
child: LinearProgressIndicator(
|
||||||
value: 0.75,
|
value: StorageService.to.hasVehicleInfo ? 0.75 : 0,
|
||||||
minHeight: 8,
|
minHeight: 8,
|
||||||
backgroundColor: Color(0xFFF0F2F5),
|
backgroundColor: Color(0xFFF0F2F5),
|
||||||
valueColor: AlwaysStoppedAnimation<Color>(Color.fromRGBO(16, 185, 129, 1)),
|
valueColor: AlwaysStoppedAnimation<Color>(Color.fromRGBO(16, 185, 129, 1)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
const Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Text("H2 Level", style: TextStyle(fontSize: 11, color: Colors.grey)),
|
Text("H2 Level", style: TextStyle(fontSize: 11, color: Colors.grey)),
|
||||||
Text(
|
Text(
|
||||||
"75%",
|
StorageService.to.hasVehicleInfo ? "75%" : "0%",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 11,
|
fontSize: 11,
|
||||||
color: Color.fromRGBO(16, 185, 129, 1),
|
color: Color.fromRGBO(16, 185, 129, 1),
|
||||||
@@ -382,7 +397,11 @@ class CarInfoPage extends GetView<CarInfoController> {
|
|||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
_buildCertDetailItem('所属公司', controller.rentFromCompany, isFull: false),
|
_buildCertDetailItem(
|
||||||
|
'所属公司',
|
||||||
|
controller.rentFromCompany,
|
||||||
|
isFull: false,
|
||||||
|
),
|
||||||
_buildCertDetailItem('运营城市', controller.address),
|
_buildCertDetailItem('运营城市', controller.address),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -69,239 +69,34 @@ class C_ReservationController extends GetxController with BaseControllerMixin {
|
|||||||
String get formattedTimeSlot =>
|
String get formattedTimeSlot =>
|
||||||
'${_formatTimeOfDay(startTime.value)} - ${_formatTimeOfDay(endTime.value)}';
|
'${_formatTimeOfDay(startTime.value)} - ${_formatTimeOfDay(endTime.value)}';
|
||||||
|
|
||||||
void pickDate(BuildContext context) {
|
|
||||||
DateTime tempDate = selectedDate.value;
|
|
||||||
|
|
||||||
// 获取今天的日期 (不含时间)
|
|
||||||
final DateTime today = DateTime(
|
|
||||||
DateTime.now().year,
|
|
||||||
DateTime.now().month,
|
|
||||||
DateTime.now().day,
|
|
||||||
);
|
|
||||||
|
|
||||||
//计算明天的日期
|
|
||||||
final DateTime tomorrow = today.add(const Duration(days: 1));
|
|
||||||
|
|
||||||
Get.bottomSheet(
|
|
||||||
Container(
|
|
||||||
height: 300,
|
|
||||||
padding: const EdgeInsets.only(top: 6.0),
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
color: Colors.white,
|
|
||||||
borderRadius: BorderRadius.only(
|
|
||||||
topLeft: Radius.circular(16),
|
|
||||||
topRight: Radius.circular(16),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
CupertinoButton(
|
|
||||||
onPressed: () => Get.back(),
|
|
||||||
child: const Text(
|
|
||||||
'取消',
|
|
||||||
style: TextStyle(color: CupertinoColors.systemGrey),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
CupertinoButton(
|
|
||||||
onPressed: () {
|
|
||||||
final bool isChangingToToday =
|
|
||||||
tempDate.isAtSameMomentAs(today) &&
|
|
||||||
!selectedDate.value.isAtSameMomentAs(today);
|
|
||||||
final bool isDateChanged = !tempDate.isAtSameMomentAs(
|
|
||||||
selectedDate.value,
|
|
||||||
);
|
|
||||||
|
|
||||||
// 更新选中的日期
|
|
||||||
selectedDate.value = tempDate;
|
|
||||||
Get.back(); // 先关闭弹窗
|
|
||||||
|
|
||||||
// 如果日期发生了变化,则重置时间
|
|
||||||
if (isDateChanged) {
|
|
||||||
resetTimeForSelectedDate();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: const Text(
|
|
||||||
'确认',
|
|
||||||
style: TextStyle(
|
|
||||||
color: AppTheme.themeColor,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Divider(height: 1, color: Color(0xFFE5E5E5)),
|
|
||||||
Expanded(
|
|
||||||
child: CupertinoDatePicker(
|
|
||||||
mode: CupertinoDatePickerMode.date,
|
|
||||||
initialDateTime: selectedDate.value,
|
|
||||||
minimumDate: today,
|
|
||||||
// 最小可选日期为今天
|
|
||||||
maximumDate: tomorrow,
|
|
||||||
// 最大可选日期为明天
|
|
||||||
// ---------------------
|
|
||||||
onDateTimeChanged: (DateTime newDate) {
|
|
||||||
tempDate = newDate;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void resetTimeForSelectedDate() {
|
void resetTimeForSelectedDate() {
|
||||||
final now = DateTime.now();
|
final now = DateTime.now();
|
||||||
final today = DateTime(now.year, now.month, now.day);
|
final today = DateTime(now.year, now.month, now.day);
|
||||||
|
|
||||||
// 判断新选择的日期是不是今天
|
// 1. 获取当前站点
|
||||||
|
final station = stationOptions.firstWhereOrNull(
|
||||||
|
(s) => s.hydrogenId == selectedStationId.value,
|
||||||
|
);
|
||||||
|
if (station == null) return;
|
||||||
|
|
||||||
|
// 2. 解析营业开始和结束的小时
|
||||||
|
final bizStartHour = int.tryParse(station.startBusiness.split(':')[0]) ?? 0;
|
||||||
|
final bizEndHour = int.tryParse(station.endBusiness.split(':')[0]) ?? 23;
|
||||||
|
|
||||||
if (selectedDate.value.isAtSameMomentAs(today)) {
|
if (selectedDate.value.isAtSameMomentAs(today)) {
|
||||||
// 如果是今天,就将时间重置为当前时间所在的半小时区间
|
// 如果是今天:起始时间 = max(当前小时, 营业开始小时),且上限为营业结束小时
|
||||||
startTime.value = _calculateInitialStartTime(now);
|
int targetHour = now.hour;
|
||||||
endTime.value = TimeOfDay.fromDateTime(
|
if (targetHour < bizStartHour) targetHour = bizStartHour;
|
||||||
_getDateTimeFromTimeOfDay(startTime.value).add(const Duration(minutes: 30)),
|
if (targetHour > bizEndHour) targetHour = bizEndHour;
|
||||||
);
|
|
||||||
|
startTime.value = TimeOfDay(hour: targetHour, minute: 0);
|
||||||
} else {
|
} else {
|
||||||
// 如果是明天(或其他未来日期),则可以将时间重置为一天的最早可用时间,例如 00:00
|
// 如果是明天:起始时间直接重置为营业开始小时
|
||||||
startTime.value = const TimeOfDay(hour: 0, minute: 0);
|
startTime.value = TimeOfDay(hour: bizStartHour, minute: 0);
|
||||||
endTime.value = const TimeOfDay(hour: 0, minute: 30);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
///60 分钟为间隔 时间选择器
|
|
||||||
void pickTime(BuildContext context) {
|
|
||||||
final now = DateTime.now();
|
|
||||||
final isToday =
|
|
||||||
selectedDate.value.year == now.year &&
|
|
||||||
selectedDate.value.month == now.month &&
|
|
||||||
selectedDate.value.day == now.day;
|
|
||||||
|
|
||||||
final List<TimeSlot> availableSlots = [];
|
|
||||||
for (int i = 0; i < 24; i++) {
|
|
||||||
// 每次增加 60 分钟
|
|
||||||
final startMinutes = i * 60;
|
|
||||||
final endMinutes = startMinutes + 60;
|
|
||||||
|
|
||||||
final startTime = TimeOfDay(hour: startMinutes ~/ 60, minute: startMinutes % 60);
|
|
||||||
// 注意:endMinutes % 60 始终为 0,因为间隔是整小时
|
|
||||||
final endTime = TimeOfDay(hour: (endMinutes ~/ 60) % 24, minute: endMinutes % 60);
|
|
||||||
|
|
||||||
// 如果不是今天,所有时间段都有效
|
|
||||||
if (!isToday) {
|
|
||||||
availableSlots.add(TimeSlot(startTime, endTime));
|
|
||||||
} else {
|
|
||||||
// 如果是今天,需要判断该时间段是否可选
|
|
||||||
// 创建时间段的结束时间对象
|
|
||||||
final slotEndDateTime = DateTime(
|
|
||||||
selectedDate.value.year,
|
|
||||||
selectedDate.value.month,
|
|
||||||
selectedDate.value.day,
|
|
||||||
endTime.hour,
|
|
||||||
endTime.minute,
|
|
||||||
);
|
|
||||||
|
|
||||||
// 注意:如果是跨天的 00:00 (例如 23:00 - 00:00),需要将日期加一天,否则 isAfter 判断会出错
|
|
||||||
// 但由于我们用的是 endTime.hour % 24,当变成 0 时,日期还是 selectedDate
|
|
||||||
// 这里做一个特殊处理:如果 endTime 是 00:00,意味着它实际上是明天的开始
|
|
||||||
DateTime realEndDateTime = slotEndDateTime;
|
|
||||||
if (endTime.hour == 0 && endTime.minute == 0) {
|
|
||||||
realEndDateTime = slotEndDateTime.add(const Duration(days: 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 只要时间段的结束时间晚于当前时间,这个时间段就是可预约的
|
|
||||||
if (realEndDateTime.isAfter(now)) {
|
|
||||||
availableSlots.add(TimeSlot(startTime, endTime));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (availableSlots.isEmpty) {
|
// 结束时间默认顺延1小时
|
||||||
showToast('今天已没有可预约的时间段');
|
endTime.value = TimeOfDay(hour: (startTime.value.hour + 1) % 24, minute: 0);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查找当前选中的时间对应的新列表中的索引
|
|
||||||
int initialItem = availableSlots.indexWhere(
|
|
||||||
(slot) => slot.start.hour == startTime.value.hour,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (initialItem == -1) {
|
|
||||||
initialItem = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
TimeSlot tempSlot = availableSlots[initialItem];
|
|
||||||
|
|
||||||
final FixedExtentScrollController scrollController = FixedExtentScrollController(
|
|
||||||
initialItem: initialItem,
|
|
||||||
);
|
|
||||||
|
|
||||||
Get.bottomSheet(
|
|
||||||
Container(
|
|
||||||
height: 300,
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
color: Colors.white,
|
|
||||||
borderRadius: BorderRadius.only(
|
|
||||||
topLeft: Radius.circular(16),
|
|
||||||
topRight: Radius.circular(16),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
CupertinoButton(
|
|
||||||
onPressed: () => Get.back(),
|
|
||||||
child: const Text(
|
|
||||||
'取消',
|
|
||||||
style: TextStyle(color: CupertinoColors.systemGrey),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
CupertinoButton(
|
|
||||||
onPressed: () {
|
|
||||||
startTime.value = tempSlot.start;
|
|
||||||
endTime.value = tempSlot.end;
|
|
||||||
Get.back();
|
|
||||||
},
|
|
||||||
child: const Text(
|
|
||||||
'确认',
|
|
||||||
style: TextStyle(
|
|
||||||
color: AppTheme.themeColor,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Divider(height: 1, color: Color(0xFFE5E5E5)),
|
|
||||||
Expanded(
|
|
||||||
child: CupertinoPicker(
|
|
||||||
scrollController: scrollController,
|
|
||||||
itemExtent: 40.0,
|
|
||||||
onSelectedItemChanged: (index) {
|
|
||||||
tempSlot = availableSlots[index];
|
|
||||||
},
|
|
||||||
children: availableSlots
|
|
||||||
.map((slot) => Center(child: Text(slot.display)))
|
|
||||||
.toList(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 用于存储上一次成功预约的信息
|
// 用于存储上一次成功预约的信息
|
||||||
@@ -536,12 +331,13 @@ class C_ReservationController extends GetxController with BaseControllerMixin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String workEfficiency = "0";
|
String workEfficiency = "-";
|
||||||
String fillingWeight = "0";
|
String fillingWeight = "-";
|
||||||
String fillingTimes = "0";
|
String fillingTimes = "-";
|
||||||
|
String modeImage = "";
|
||||||
String plateNumber = "";
|
String plateNumber = "";
|
||||||
String vin = "";
|
String vin = "";
|
||||||
String leftHydrogen = "0";
|
String leftHydrogen = "-";
|
||||||
num maxHydrogen = 0;
|
num maxHydrogen = 0;
|
||||||
String difference = "";
|
String difference = "";
|
||||||
var progressValue = 0.0;
|
var progressValue = 0.0;
|
||||||
@@ -650,7 +446,7 @@ class C_ReservationController extends GetxController with BaseControllerMixin {
|
|||||||
try {
|
try {
|
||||||
HttpService.to.setBaseUrl(AppTheme.test_service_url);
|
HttpService.to.setBaseUrl(AppTheme.test_service_url);
|
||||||
var responseData = await HttpService.to.get(
|
var responseData = await HttpService.to.get(
|
||||||
'appointment/truck/history-filling-summary?vin=$vin',
|
'appointment/truck/history-filling-summary?vin=$vin&plateNumber=$plateNumber',
|
||||||
);
|
);
|
||||||
if (responseData == null || responseData.data == null) {
|
if (responseData == null || responseData.data == null) {
|
||||||
showToast('服务暂不可用,请稍后');
|
showToast('服务暂不可用,请稍后');
|
||||||
@@ -664,6 +460,7 @@ class C_ReservationController extends GetxController with BaseControllerMixin {
|
|||||||
|
|
||||||
fillingWeight = "$formatted${result.data["fillingWeightUnit"]}";
|
fillingWeight = "$formatted${result.data["fillingWeightUnit"]}";
|
||||||
fillingTimes = "${result.data["fillingTimes"]}${result.data["fillingTimesUnit"]}";
|
fillingTimes = "${result.data["fillingTimes"]}${result.data["fillingTimesUnit"]}";
|
||||||
|
modeImage = result.data["modeImage"].toString();
|
||||||
|
|
||||||
updateUi();
|
updateUi();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -689,8 +486,8 @@ class C_ReservationController extends GetxController with BaseControllerMixin {
|
|||||||
|
|
||||||
var result = BaseModel.fromJson(responseData.data);
|
var result = BaseModel.fromJson(responseData.data);
|
||||||
|
|
||||||
leftHydrogen = result.data["leftHydrogen"].toString();
|
leftHydrogen = "${result.data["leftHydrogen"]}Kg";
|
||||||
workEfficiency = result.data["workEfficiency"].toString();
|
workEfficiency = "${result.data["workEfficiency"]}Kg";
|
||||||
|
|
||||||
final leftHydrogenNum = double.tryParse(leftHydrogen) ?? 0.0;
|
final leftHydrogenNum = double.tryParse(leftHydrogen) ?? 0.0;
|
||||||
difference = (maxHydrogen - leftHydrogenNum).toStringAsFixed(2);
|
difference = (maxHydrogen - leftHydrogenNum).toStringAsFixed(2);
|
||||||
@@ -725,7 +522,7 @@ class C_ReservationController extends GetxController with BaseControllerMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void getSiteList() async {
|
void getSiteList() async {
|
||||||
if (StorageService.to.phone == "13344444444") {
|
if (StorageService.to.phone == "13888888888") {
|
||||||
//该账号给stationOptions手动添加一个数据
|
//该账号给stationOptions手动添加一个数据
|
||||||
final testStation = StationModel(
|
final testStation = StationModel(
|
||||||
hydrogenId: '1142167389150920704',
|
hydrogenId: '1142167389150920704',
|
||||||
@@ -735,7 +532,9 @@ class C_ReservationController extends GetxController with BaseControllerMixin {
|
|||||||
// 价格
|
// 价格
|
||||||
siteStatusName: '营运中',
|
siteStatusName: '营运中',
|
||||||
// 状态
|
// 状态
|
||||||
isSelect: 1, // 默认可选
|
isSelect: 1,
|
||||||
|
startBusiness: '08:00:00',
|
||||||
|
endBusiness: '20:00:00', // 默认可选
|
||||||
);
|
);
|
||||||
// 使用 assignAll 可以确保列表只包含这个测试数据
|
// 使用 assignAll 可以确保列表只包含这个测试数据
|
||||||
stationOptions.assignAll([testStation]);
|
stationOptions.assignAll([testStation]);
|
||||||
|
|||||||
@@ -148,9 +148,11 @@ class ReservationPage extends GetView<C_ReservationController> {
|
|||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
controller.stopAutoRefresh();
|
||||||
var scanResult = await Get.to(() => const MessagePage());
|
var scanResult = await Get.to(() => const MessagePage());
|
||||||
if (scanResult == null) {
|
if (scanResult == null) {
|
||||||
controller.msgNotice();
|
controller.msgNotice();
|
||||||
|
controller.startAutoRefresh();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
icon: Badge(
|
icon: Badge(
|
||||||
@@ -177,7 +179,12 @@ class ReservationPage extends GetView<C_ReservationController> {
|
|||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
_buildModernStatItem('总加氢次数', '', controller.fillingTimes, ''),
|
_buildModernStatItem('总加氢次数', '', controller.fillingTimes, ''),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
_buildModernStatItem('今日里程', '', "7kg", ''),
|
_buildModernStatItem(
|
||||||
|
'今日里程',
|
||||||
|
'',
|
||||||
|
StorageService.to.hasVehicleInfo ? "7kg" : "-",
|
||||||
|
'',
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -237,17 +244,33 @@ class ReservationPage extends GetView<C_ReservationController> {
|
|||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(flex: 4, child: LoginUtil.getAssImg('ic_car_bg@2x')),
|
Expanded(
|
||||||
|
flex: 4,
|
||||||
|
child: Image.network(
|
||||||
|
controller.modeImage,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
loadingBuilder: (context, child, loadingProgress) {
|
||||||
|
if (loadingProgress == null) return child;
|
||||||
|
return Center(child: CircularProgressIndicator());
|
||||||
|
},
|
||||||
|
errorBuilder: (context, error, stackTrace) {
|
||||||
|
return Center(child: LoginUtil.getAssImg('ic_car_select@2x'));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 6,
|
flex: 6,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
_buildCarDataItem('剩余电量', '36.8%'),
|
_buildCarDataItem(
|
||||||
|
'剩余电量',
|
||||||
|
StorageService.to.hasVehicleInfo ? '36.8%' : '-',
|
||||||
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
_buildCarDataItem('剩余氢量', '${controller.leftHydrogen}Kg'),
|
_buildCarDataItem('剩余氢量', controller.leftHydrogen),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
_buildCarDataItem('百公里氢耗', '${controller.workEfficiency}Kg'),
|
_buildCarDataItem('百公里氢耗', controller.workEfficiency),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
@@ -275,7 +298,7 @@ class ReservationPage extends GetView<C_ReservationController> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
"${controller.leftHydrogen}Kg",
|
controller.leftHydrogen,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 10,
|
fontSize: 10,
|
||||||
color: Color(0xFF006633),
|
color: Color(0xFF006633),
|
||||||
@@ -434,8 +457,27 @@ class ReservationPage extends GetView<C_ReservationController> {
|
|||||||
/// 时间 Slider 选择器
|
/// 时间 Slider 选择器
|
||||||
Widget _buildTimeSlider(BuildContext context) {
|
Widget _buildTimeSlider(BuildContext context) {
|
||||||
return Obx(() {
|
return Obx(() {
|
||||||
// 这里的逻辑对应 Controller 中的 24 小时可用 Slot
|
// 获取当前小时作为滑块值 (0-23)
|
||||||
int currentIdx = controller.startTime.value.hour;
|
int currentHour = controller.startTime.value.hour;
|
||||||
|
|
||||||
|
// 动态获取站点的营业范围限制
|
||||||
|
final station = controller.stationOptions.firstWhereOrNull(
|
||||||
|
(s) => s.hydrogenId == controller.selectedStationId.value,
|
||||||
|
);
|
||||||
|
// 解析营业时间
|
||||||
|
// 处理格式如 "09:00" 或 "09:00:00"
|
||||||
|
final startParts = (station?.startBusiness ?? "00:00").split(':');
|
||||||
|
final endParts = (station?.endBusiness ?? "23:59").split(':');
|
||||||
|
|
||||||
|
int bizStartHour = int.tryParse(startParts[0]) ?? 0;
|
||||||
|
int bizEndHour = int.tryParse(endParts[0]) ?? 23;
|
||||||
|
int bizEndMinute = (endParts.length > 1) ? (int.tryParse(endParts[1]) ?? 0) : 0;
|
||||||
|
|
||||||
|
// 优化结束小时逻辑
|
||||||
|
// 如果分钟为 0 (例如 18:00),说明该小时整点已关门,最大可选小时应减 1
|
||||||
|
if (bizEndMinute == 0 && bizEndHour > 0) {
|
||||||
|
bizEndHour--;
|
||||||
|
}
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
@@ -484,23 +526,23 @@ class ReservationPage extends GetView<C_ReservationController> {
|
|||||||
overlayColor: const Color(0xFF006633).withOpacity(0.1),
|
overlayColor: const Color(0xFF006633).withOpacity(0.1),
|
||||||
),
|
),
|
||||||
child: Slider(
|
child: Slider(
|
||||||
value: currentIdx.toDouble(),
|
value: currentHour.toDouble().clamp(
|
||||||
min: 0,
|
bizStartHour.toDouble(),
|
||||||
max: 23,
|
bizEndHour.toDouble(),
|
||||||
divisions: 23,
|
),
|
||||||
|
min: bizStartHour.toDouble(),
|
||||||
|
max: bizEndHour.toDouble(),
|
||||||
|
// divisions: bizEndHour - bizStartHour > 0 ? bizEndHour - bizStartHour : 1,
|
||||||
onChanged: (val) {
|
onChanged: (val) {
|
||||||
int hour = val.toInt();
|
int hour = val.toInt();
|
||||||
// 模拟 Controller 中的 pickTime 逻辑校验
|
|
||||||
final now = DateTime.now();
|
final now = DateTime.now();
|
||||||
final isToday =
|
final isToday =
|
||||||
controller.selectedDate.value.year == now.year &&
|
controller.selectedDate.value.year == now.year &&
|
||||||
controller.selectedDate.value.month == now.month &&
|
controller.selectedDate.value.month == now.month &&
|
||||||
controller.selectedDate.value.day == now.day;
|
controller.selectedDate.value.day == now.day;
|
||||||
|
|
||||||
if (isToday && hour < now.hour) {
|
// 如果是今天,判断不可选过去的时间点
|
||||||
// 如果是今天且小时数小于当前,则忽略
|
if (isToday && hour < now.hour) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
controller.startTime.value = TimeOfDay(hour: hour, minute: 0);
|
controller.startTime.value = TimeOfDay(hour: hour, minute: 0);
|
||||||
controller.endTime.value = TimeOfDay(hour: (hour + 1) % 24, minute: 0);
|
controller.endTime.value = TimeOfDay(hour: (hour + 1) % 24, minute: 0);
|
||||||
@@ -627,6 +669,7 @@ class ReservationPage extends GetView<C_ReservationController> {
|
|||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
controller.selectedStationId.value = value;
|
controller.selectedStationId.value = value;
|
||||||
|
controller.resetTimeForSelectedDate();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,11 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:aliyun_push_flutter/aliyun_push_flutter.dart';
|
import 'package:aliyun_push_flutter/aliyun_push_flutter.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_app_update/flutter_app_update.dart';
|
||||||
|
import 'package:flutter_app_update/result_model.dart';
|
||||||
import 'package:flutter_native_splash/flutter_native_splash.dart';
|
import 'package:flutter_native_splash/flutter_native_splash.dart';
|
||||||
import 'package:getx_scaffold/getx_scaffold.dart';
|
import 'package:getx_scaffold/getx_scaffold.dart';
|
||||||
|
import 'package:ln_jq_app/common/model/base_model.dart';
|
||||||
import 'package:ln_jq_app/common/styles/theme.dart';
|
import 'package:ln_jq_app/common/styles/theme.dart';
|
||||||
import 'package:ln_jq_app/pages/b_page/base_widgets/view.dart';
|
import 'package:ln_jq_app/pages/b_page/base_widgets/view.dart';
|
||||||
import 'package:ln_jq_app/pages/c_page/base_widgets/view.dart';
|
import 'package:ln_jq_app/pages/c_page/base_widgets/view.dart';
|
||||||
@@ -20,107 +23,195 @@ class HomeController extends GetxController with BaseControllerMixin {
|
|||||||
|
|
||||||
final _aliyunPush = AliyunPushFlutter();
|
final _aliyunPush = AliyunPushFlutter();
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get listenLifecycleEvent => true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
initAliyunPush();
|
initAliyunPush();
|
||||||
addPushCallback();
|
addPushCallback();
|
||||||
FlutterNativeSplash.remove();
|
FlutterNativeSplash.remove();
|
||||||
|
log('page-init');
|
||||||
|
|
||||||
|
// 页面初始化后执行版本检查
|
||||||
|
checkVersionInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
String downloadUrl = "";
|
||||||
|
|
||||||
|
/// 检查 App 更新信息,增加版本号比对逻辑
|
||||||
|
void checkVersionInfo() async {
|
||||||
|
try {
|
||||||
|
final response = await HttpService.to.get('appointment/appConfig/get');
|
||||||
|
if (response != null) {
|
||||||
|
final result = BaseModel.fromJson(response.data);
|
||||||
|
if (result.code == 0 && result.data != null) {
|
||||||
|
final data = result.data as Map<String, dynamic>;
|
||||||
|
|
||||||
|
bool hasUpdate = data['hasUpdate']?.toString().toLowerCase() == "true";
|
||||||
|
bool isForce = data['isForce']?.toString().toLowerCase() == "true";
|
||||||
|
String versionName = data['versionName'] ?? "新版本";
|
||||||
|
String updateContent = data['updateContent'] ?? "优化系统性能,提升用户体验";
|
||||||
|
downloadUrl = data['downloadUrl'].toString();
|
||||||
|
|
||||||
|
// 获取服务器配置的目标构建号
|
||||||
|
int serverVersionCode =
|
||||||
|
int.tryParse(data['versionCode']?.toString() ?? "0") ?? 0;
|
||||||
|
int serverIosBuildId = int.tryParse(data['iosBuildId']?.toString() ?? "0") ?? 0;
|
||||||
|
|
||||||
|
// 获取本地当前的构建号
|
||||||
|
String currentBuildStr = await getBuildNumber();
|
||||||
|
int currentBuild = int.tryParse(currentBuildStr) ?? 0;
|
||||||
|
|
||||||
|
bool needUpdate = false;
|
||||||
|
if (GetPlatform.isAndroid) {
|
||||||
|
needUpdate = currentBuild < serverVersionCode;
|
||||||
|
} else if (GetPlatform.isIOS) {
|
||||||
|
needUpdate = currentBuild < serverIosBuildId;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果服务器标记有更新,且本地版本号确实较低,则弹出更新
|
||||||
|
if (hasUpdate && needUpdate) {
|
||||||
|
_showUpdateDialog("版本:$versionName\n\n更新内容:\n$updateContent", isForce);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
Logger.d("版本检查失败: $e");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 显示更新弹窗
|
||||||
|
void _showUpdateDialog(String content, bool isForce) {
|
||||||
|
DialogX.to.showConfirmDialog(
|
||||||
|
title: '升级提醒',
|
||||||
|
confirmText: '立即升级',
|
||||||
|
content: _buildDialogContent(content),
|
||||||
|
// 如果是强制更新,取消按钮显示为空,即隐藏
|
||||||
|
cancelText: isForce ? "" : '以后再说',
|
||||||
|
// 设置为 false,禁止点击背景和物理返回键关闭
|
||||||
|
barrierDismissible: false,
|
||||||
|
onConfirm: () {
|
||||||
|
jumpUpdateApp();
|
||||||
|
|
||||||
|
// ios如果是强制更新,点击后维持弹窗,防止用户进入 App
|
||||||
|
if (isForce && GetPlatform.isIOS) {
|
||||||
|
Future.delayed(const Duration(milliseconds: 500), () {
|
||||||
|
_showUpdateDialog(content, isForce);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildDialogContent(String content) {
|
||||||
|
return PopScope(
|
||||||
|
canPop: false, // 关键:禁止 pop
|
||||||
|
child: TextX.bodyMedium(content).padding(bottom: 16.h),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void jumpUpdateApp() {
|
||||||
|
if (GetPlatform.isIOS) {
|
||||||
|
// 跳转到 iOS 应用商店网页
|
||||||
|
openWebPage("https://apps.apple.com/cn/app/羚牛氢能/6756245815");
|
||||||
|
} else if (GetPlatform.isAndroid) {
|
||||||
|
// Android 执行下载安装流程
|
||||||
|
showAndroidDownloadDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void showAndroidDownloadDialog() {
|
||||||
|
AzhonAppUpdate.listener((ResultModel model) {
|
||||||
|
if (model.type == ResultType.start) {
|
||||||
|
DialogX.to.showConfirmDialog(
|
||||||
|
content: PopScope(
|
||||||
|
canPop: false,
|
||||||
|
child: Center(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
TextX.bodyMedium('升级中...').padding(bottom: 45.h),
|
||||||
|
CircularProgressIndicator(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
confirmText: '',
|
||||||
|
cancelText: "",
|
||||||
|
barrierDismissible: false,
|
||||||
|
);
|
||||||
|
} else if (model.type == ResultType.done) {
|
||||||
|
Get.back();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
UpdateModel model = UpdateModel(downloadUrl, "xll.apk", "logo", '正在下载最新版本...');
|
||||||
|
AzhonAppUpdate.update(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据登录状态和登录渠道返回不同的首页
|
// 根据登录状态和登录渠道返回不同的首页
|
||||||
Widget getHomePage() {
|
Widget getHomePage() {
|
||||||
requestPermission();
|
requestPermission();
|
||||||
//登录状态跳转
|
|
||||||
if (StorageService.to.isLoggedIn) {
|
if (StorageService.to.isLoggedIn) {
|
||||||
// 如果已登录,再判断是哪个渠道
|
|
||||||
if (StorageService.to.loginChannel == LoginChannel.station) {
|
if (StorageService.to.loginChannel == LoginChannel.station) {
|
||||||
return B_BaseWidgetsPage(); // 站点首页
|
return B_BaseWidgetsPage();
|
||||||
} else if (StorageService.to.loginChannel == LoginChannel.driver) {
|
} else if (StorageService.to.loginChannel == LoginChannel.driver) {
|
||||||
return BaseWidgetsPage(); // 司机首页
|
return BaseWidgetsPage();
|
||||||
} else {
|
} else {
|
||||||
return LoginPage();
|
return LoginPage();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 未登录,直接去登录页
|
|
||||||
return LoginPage();
|
return LoginPage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void requestPermission() async {
|
void requestPermission() async {
|
||||||
PermissionStatus status = await Permission.notification.status;
|
PermissionStatus status = await Permission.notification.status;
|
||||||
if (status.isGranted) {
|
if (status.isGranted) return;
|
||||||
Logger.d("通知权限已开启");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status.isDenied) {
|
if (status.isDenied) {
|
||||||
// 建议此处增加一个应用内的 Rationale (解释说明) 弹窗
|
|
||||||
status = await Permission.notification.request();
|
status = await Permission.notification.request();
|
||||||
}
|
}
|
||||||
if (status.isGranted) {
|
if (status.isGranted) {
|
||||||
// 授权成功
|
|
||||||
Logger.d('通知已开启');
|
Logger.d('通知已开启');
|
||||||
} else if (status.isPermanentlyDenied) {
|
} else if (status.isPermanentlyDenied) {
|
||||||
Logger.d('通知权限已被拒绝,请到系统设置中开启');
|
Logger.d('通知权限已被拒绝,请到系统设置中开启');
|
||||||
} else if (status.isDenied) {
|
|
||||||
Logger.d('请授予通知权限,以便接收加氢站通知');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///推送相关
|
///推送相关初始化 (保持原样)
|
||||||
Future<void> initAliyunPush() async {
|
Future<void> initAliyunPush() async {
|
||||||
// 1. 配置分离:建议将 Key 提取到外部或配置文件中
|
|
||||||
final String appKey = Platform.isIOS ? AppTheme.ios_key : AppTheme.android_key;
|
final String appKey = Platform.isIOS ? AppTheme.ios_key : AppTheme.android_key;
|
||||||
final String appSecret = Platform.isIOS
|
final String appSecret = Platform.isIOS
|
||||||
? AppTheme.ios_appsecret
|
? AppTheme.ios_appsecret
|
||||||
: AppTheme.android_appsecret;
|
: AppTheme.android_appsecret;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 初始化推送
|
|
||||||
final result = await _aliyunPush.initPush(appKey: appKey, appSecret: appSecret);
|
final result = await _aliyunPush.initPush(appKey: appKey, appSecret: appSecret);
|
||||||
|
if (result['code'] != kAliyunPushSuccessCode) return;
|
||||||
if (result['code'] != kAliyunPushSuccessCode) {
|
|
||||||
Logger.d('初始化推送失败: ${result['code']} - ${result['errorMsg']}');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.d('阿里云推送初始化成功');
|
|
||||||
// 分平台配置
|
|
||||||
if (Platform.isIOS) {
|
if (Platform.isIOS) {
|
||||||
await _setupIOSConfig();
|
await _setupIOSConfig();
|
||||||
} else if (Platform.isAndroid) {
|
} else if (Platform.isAndroid) {
|
||||||
await _setupAndroidConfig();
|
await _setupAndroidConfig();
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Logger.d('初始化过程中发生异常: $e');
|
Logger.d('初始化异常: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// iOS 专属配置
|
|
||||||
Future<void> _setupIOSConfig() async {
|
Future<void> _setupIOSConfig() async {
|
||||||
final res = await _aliyunPush.showIOSNoticeWhenForeground(true);
|
await _aliyunPush.showIOSNoticeWhenForeground(true);
|
||||||
if (res['code'] == kAliyunPushSuccessCode) {
|
|
||||||
Logger.d('iOS 前台通知展示已开启');
|
|
||||||
} else {
|
|
||||||
Logger.d('iOS 前台通知开启失败: ${res['errorMsg']}');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Android 专属配置
|
|
||||||
Future<void> _setupAndroidConfig() async {
|
Future<void> _setupAndroidConfig() async {
|
||||||
await _aliyunPush.setNotificationInGroup(true);
|
await _aliyunPush.setNotificationInGroup(true);
|
||||||
final res = await _aliyunPush.createAndroidChannel(
|
await _aliyunPush.createAndroidChannel(
|
||||||
"xll_push_android",
|
"xll_push_android",
|
||||||
'新消息通知',
|
'新消息通知',
|
||||||
4,
|
4,
|
||||||
'用于接收加氢站实时状态提醒',
|
'用于接收加氢站实时状态提醒',
|
||||||
);
|
);
|
||||||
if (res['code'] == kAliyunPushSuccessCode) {
|
|
||||||
Logger.d('Android 通知通道创建成功');
|
|
||||||
} else {
|
|
||||||
Logger.d('Android 通道创建失败: ${res['code']} - ${res['errorMsg']}');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void addPushCallback() {
|
void addPushCallback() {
|
||||||
@@ -139,40 +230,23 @@ class HomeController extends GetxController with BaseControllerMixin {
|
|||||||
|
|
||||||
Future<void> _onAndroidNotificationClickedWithNoAction(
|
Future<void> _onAndroidNotificationClickedWithNoAction(
|
||||||
Map<dynamic, dynamic> message,
|
Map<dynamic, dynamic> message,
|
||||||
) async {
|
) async {}
|
||||||
Logger.d('onAndroidNotificationClickedWithNoAction ====> $message');
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onAndroidNotificationReceivedInApp(Map<dynamic, dynamic> message) async {
|
Future<void> _onAndroidNotificationReceivedInApp(Map<dynamic, dynamic> message) async {}
|
||||||
Logger.d('onAndroidNotificationReceivedInApp ====> $message');
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onMessage(Map<dynamic, dynamic> message) async {
|
Future<void> _onMessage(Map<dynamic, dynamic> message) async {}
|
||||||
Logger.d('onMessage ====> $message');
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onNotification(Map<dynamic, dynamic> message) async {
|
Future<void> _onNotification(Map<dynamic, dynamic> message) async {}
|
||||||
Logger.d('onNotification ====> $message');
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onNotificationOpened(Map<dynamic, dynamic> message) async {
|
Future<void> _onNotificationOpened(Map<dynamic, dynamic> message) async {
|
||||||
Logger.d('onNotificationOpened ====> $message');
|
|
||||||
await Get.to(() => const MessagePage());
|
await Get.to(() => const MessagePage());
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onNotificationRemoved(Map<dynamic, dynamic> message) async {
|
Future<void> _onNotificationRemoved(Map<dynamic, dynamic> message) async {}
|
||||||
Logger.d('onNotificationRemoved ====> $message');
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onIOSChannelOpened(Map<dynamic, dynamic> message) async {
|
Future<void> _onIOSChannelOpened(Map<dynamic, dynamic> message) async {}
|
||||||
Logger.d('onIOSChannelOpened ====> $message');
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onIOSRegisterDeviceTokenSuccess(Map<dynamic, dynamic> message) async {
|
Future<void> _onIOSRegisterDeviceTokenSuccess(Map<dynamic, dynamic> message) async {}
|
||||||
Logger.d('onIOSRegisterDeviceTokenSuccess ====> $message');
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onIOSRegisterDeviceTokenFailed(Map<dynamic, dynamic> message) async {
|
Future<void> _onIOSRegisterDeviceTokenFailed(Map<dynamic, dynamic> message) async {}
|
||||||
Logger.d('onIOSRegisterDeviceTokenFailed====> $message');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,18 +5,13 @@ import 'package:ln_jq_app/pages/home/controller.dart';
|
|||||||
class HomePage extends GetView<HomeController> {
|
class HomePage extends GetView<HomeController> {
|
||||||
const HomePage({super.key});
|
const HomePage({super.key});
|
||||||
|
|
||||||
// 主视图
|
|
||||||
Widget _buildView() {
|
|
||||||
return <Widget>[Text('主页面')].toColumn(mainAxisSize: MainAxisSize.min).center();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GetBuilder<HomeController>(
|
return GetBuilder<HomeController>(
|
||||||
init: HomeController(),
|
init: HomeController(),
|
||||||
id: 'home',
|
id: 'home',
|
||||||
builder: (_) {
|
builder: (_) {
|
||||||
return controller.getHomePage();
|
return Scaffold(body: controller.getHomePage());
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -204,9 +204,9 @@ class _LoginPageState extends State<LoginPage> with SingleTickerProviderStateMix
|
|||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
const Text(
|
const Text(
|
||||||
"欢迎使用 ",
|
"欢迎使用小羚羚 ",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 24,
|
fontSize: 22,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: Color.fromRGBO(51, 51, 51, 1),
|
color: Color.fromRGBO(51, 51, 51, 1),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class WelcomePage extends GetView<WelcomeController> {
|
|||||||
right: 0,
|
right: 0,
|
||||||
child: Image.asset(
|
child: Image.asset(
|
||||||
'assets/images/welcome.png',
|
'assets/images/welcome.png',
|
||||||
fit: BoxFit.fill
|
fit: BoxFit.cover
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import 'package:get/get.dart';
|
|||||||
import 'package:get_storage/get_storage.dart';
|
import 'package:get_storage/get_storage.dart';
|
||||||
import 'package:getx_scaffold/common/utils/log_util.dart';
|
import 'package:getx_scaffold/common/utils/log_util.dart';
|
||||||
import 'package:ln_jq_app/common/model/vehicle_info.dart';
|
import 'package:ln_jq_app/common/model/vehicle_info.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
|
|
||||||
/// 定义登录渠道的枚举类型
|
/// 定义登录渠道的枚举类型
|
||||||
enum LoginChannel {
|
enum LoginChannel {
|
||||||
@@ -104,9 +103,6 @@ class StorageService extends GetxService {
|
|||||||
|
|
||||||
Future<void> saveVehicleInfo(VehicleInfo data) async {
|
Future<void> saveVehicleInfo(VehicleInfo data) async {
|
||||||
await _box.write(_vehicleInfoKey, vehicleInfoToJson(data));
|
await _box.write(_vehicleInfoKey, vehicleInfoToJson(data));
|
||||||
|
|
||||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
||||||
await prefs.setString('plateNumber', data.plateNumber ?? "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> saveStationCredentials(String account, String password) async {
|
Future<void> saveStationCredentials(String account, String password) async {
|
||||||
@@ -121,9 +117,6 @@ class StorageService extends GetxService {
|
|||||||
|
|
||||||
Future<void> clearVehicleInfo() async {
|
Future<void> clearVehicleInfo() async {
|
||||||
await _box.remove(_vehicleInfoKey);
|
await _box.remove(_vehicleInfoKey);
|
||||||
|
|
||||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
||||||
await prefs.remove('plateNumber');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> clearStationCredentials() async {
|
Future<void> clearStationCredentials() async {
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: archive
|
name: archive
|
||||||
sha256: a96e8b390886ee8abb49b7bd3ac8df6f451c621619f52a26e815fdcf568959ff
|
sha256: "2fde1607386ab523f7a36bb3e7edb43bd58e6edaf2ffb29d8a6d578b297fdbbd"
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.0.9"
|
version: "4.0.7"
|
||||||
args:
|
args:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -117,10 +117,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: cross_file
|
name: cross_file
|
||||||
sha256: "28bb3ae56f117b5aec029d702a90f57d285cd975c3c5c281eaca38dbc47c5937"
|
sha256: "701dcfc06da0882883a2657c445103380e53e647060ad8d9dfb710c100996608"
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.3.5+2"
|
version: "0.3.5+1"
|
||||||
crypto:
|
crypto:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -149,10 +149,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: dbus
|
name: dbus
|
||||||
sha256: d0c98dcd4f5169878b6cf8f6e0a52403a9dff371a3e2f019697accbf6f44a270
|
sha256: "79e0c23480ff85dc68de79e2cd6334add97e48f7f4865d17686dd6ea81a47e8c"
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.12"
|
version: "0.7.11"
|
||||||
decimal:
|
decimal:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -181,18 +181,18 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: dio
|
name: dio
|
||||||
sha256: aff32c08f92787a557dd5c0145ac91536481831a01b4648136373cddb0e64f8c
|
sha256: d90ee57923d1828ac14e492ca49440f65477f4bb1263575900be731a3dac66a9
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.9.2"
|
version: "5.9.0"
|
||||||
dio_web_adapter:
|
dio_web_adapter:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: dio_web_adapter
|
name: dio_web_adapter
|
||||||
sha256: "2f9e64323a7c3c7ef69567d5c800424a11f8337b8b228bad02524c9fb3c1f340"
|
sha256: "7586e476d70caecaf1686d21eee7247ea43ef5c345eab9e0cc3583ff13378d78"
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.2"
|
version: "2.1.1"
|
||||||
dropdown_button2:
|
dropdown_button2:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -245,10 +245,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: ffi
|
name: ffi
|
||||||
sha256: "6d7fd89431262d8f3125e81b50d3847a091d846eafcd4fdb88dd06f36d705a45"
|
sha256: "289279317b4b16eb2bb7e271abccd4bf84ec9bdcbe999e278a94b804f5630418"
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.0"
|
version: "2.1.4"
|
||||||
file:
|
file:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -302,6 +302,14 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
flutter_app_update:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_app_update
|
||||||
|
sha256: "09290240949c4651581cd6fc535e52d019e189e694d6019c56b5a56c2e69ba65"
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "3.2.2"
|
||||||
flutter_easyloading:
|
flutter_easyloading:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -330,10 +338,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: flutter_inappwebview_internal_annotations
|
name: flutter_inappwebview_internal_annotations
|
||||||
sha256: e30fba942e3debea7b7e6cdd4f0f59ce89dd403a9865193e3221293b6d1544c6
|
sha256: "787171d43f8af67864740b6f04166c13190aa74a1468a1f1f1e9ee5b90c359cd"
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.0"
|
version: "1.2.0"
|
||||||
flutter_inappwebview_ios:
|
flutter_inappwebview_ios:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -431,10 +439,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: flutter_svg
|
name: flutter_svg
|
||||||
sha256: "1ded017b39c8e15c8948ea855070a5ff8ff8b3d5e83f3446e02d6bb12add7ad9"
|
sha256: "87fbd7c534435b6c5d9d98b01e1fd527812b82e68ddd8bd35fc45ed0fa8f0a95"
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.4"
|
version: "2.2.3"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -577,10 +585,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: image
|
name: image
|
||||||
sha256: f9881ff4998044947ec38d098bc7c8316ae1186fa786eddffdb867b9bc94dfce
|
sha256: "492bd52f6c4fbb6ee41f781ff27765ce5f627910e1e0cbecfa3d9add5562604c"
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.8.0"
|
version: "4.7.2"
|
||||||
image_picker:
|
image_picker:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -593,10 +601,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: image_picker_android
|
name: image_picker_android
|
||||||
sha256: eda9b91b7e266d9041084a42d605a74937d996b87083395c5e47835916a86156
|
sha256: "5e9bf126c37c117cf8094215373c6d561117a3cfb50ebc5add1a61dc6e224677"
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.8.13+14"
|
version: "0.8.13+10"
|
||||||
image_picker_for_web:
|
image_picker_for_web:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -737,10 +745,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: mobile_scanner
|
name: mobile_scanner
|
||||||
sha256: c92c26bf2231695b6d3477c8dcf435f51e28f87b1745966b1fe4c47a286171ce
|
sha256: c6184bf2913dd66be244108c9c27ca04b01caf726321c44b0e7a7a1e32d41044
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "7.2.0"
|
version: "7.1.4"
|
||||||
modal_bottom_sheet:
|
modal_bottom_sheet:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -889,10 +897,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: petitparser
|
name: petitparser
|
||||||
sha256: "91bd59303e9f769f108f8df05e371341b15d59e995e6806aefab827b58336675"
|
sha256: "1a97266a94f7350d30ae522c0af07890c70b8e62c71e8e3920d1db4d23c057d1"
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "7.0.2"
|
version: "7.0.1"
|
||||||
photo_view:
|
photo_view:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -929,10 +937,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: posix
|
name: posix
|
||||||
sha256: "185ef7606574f789b40f289c233efa52e96dead518aed988e040a10737febb07"
|
sha256: "6323a5b0fa688b6a010df4905a56b00181479e6d10534cecfecede2aa55add61"
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.5.0"
|
version: "6.0.3"
|
||||||
pull_to_refresh:
|
pull_to_refresh:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -950,7 +958,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.3"
|
version: "2.2.3"
|
||||||
shared_preferences:
|
shared_preferences:
|
||||||
dependency: "direct main"
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: shared_preferences
|
name: shared_preferences
|
||||||
sha256: "2939ae520c9024cb197fc20dee269cd8cdbf564c8b5746374ec6cacdc5169e64"
|
sha256: "2939ae520c9024cb197fc20dee269cd8cdbf564c8b5746374ec6cacdc5169e64"
|
||||||
@@ -961,10 +969,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: shared_preferences_android
|
name: shared_preferences_android
|
||||||
sha256: "8374d6200ab33ac99031a852eba4c8eb2170c4bf20778b3e2c9eccb45384fb41"
|
sha256: "83af5c682796c0f7719c2bbf74792d113e40ae97981b8f266fa84574573556bc"
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.21"
|
version: "2.4.18"
|
||||||
shared_preferences_foundation:
|
shared_preferences_foundation:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -1022,10 +1030,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: source_span
|
name: source_span
|
||||||
sha256: "56a02f1f4cd1a2d96303c0144c93bd6d909eea6bee6bf5a0e0b685edbd4c47ab"
|
sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c"
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.10.2"
|
version: "1.10.1"
|
||||||
stack_trace:
|
stack_trace:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -1150,10 +1158,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: uuid
|
name: uuid
|
||||||
sha256: "1fef9e8e11e2991bb773070d4656b7bd5d850967a2456cfc83cf47925ba79489"
|
sha256: a11b666489b1954e01d992f3d601b1804a33937b5a8fe677bd26b8a9f96f96e8
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.5.3"
|
version: "4.5.2"
|
||||||
vector_graphics:
|
vector_graphics:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -1174,10 +1182,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vector_graphics_compiler
|
name: vector_graphics_compiler
|
||||||
sha256: "5a88dd14c0954a5398af544651c7fb51b457a2a556949bfb25369b210ef73a74"
|
sha256: d354a7ec6931e6047785f4db12a1f61ec3d43b207fc0790f863818543f8ff0dc
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.1.19"
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ dependencies:
|
|||||||
|
|
||||||
encrypt: ^5.0.3
|
encrypt: ^5.0.3
|
||||||
get_storage: ^2.1.1
|
get_storage: ^2.1.1
|
||||||
shared_preferences: ^2.5.4
|
|
||||||
|
|
||||||
flutter_native_splash: ^2.4.7
|
flutter_native_splash: ^2.4.7
|
||||||
dropdown_button2: ^2.3.8
|
dropdown_button2: ^2.3.8
|
||||||
@@ -53,7 +52,7 @@ dependencies:
|
|||||||
geolocator: ^14.0.2 # 获取精确定位
|
geolocator: ^14.0.2 # 获取精确定位
|
||||||
aliyun_push_flutter: ^1.3.6
|
aliyun_push_flutter: ^1.3.6
|
||||||
pull_to_refresh: ^2.0.0
|
pull_to_refresh: ^2.0.0
|
||||||
|
flutter_app_update: ^3.2.2
|
||||||
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
|||||||