新增字段
@@ -125,12 +125,12 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
|||||||
private LinearLayout detailPanel; // 详情面板
|
private LinearLayout detailPanel; // 详情面板
|
||||||
|
|
||||||
private View modeMenu; //模式选择
|
private View modeMenu; //模式选择
|
||||||
private TextView tvStationName, tvStationAddr, planToggleBtn;
|
private TextView tvStationName, tvStationAddr, planToggleBtn, tvBusinessHours;
|
||||||
private ListView suggestionList; // 输入提示列表
|
private ListView suggestionList; // 输入提示列表
|
||||||
private ArrayAdapter<String> suggestionAdapter; // 提示列表适配器
|
private ArrayAdapter<String> suggestionAdapter; // 提示列表适配器
|
||||||
private List<Tip> currentTipList; // 当前提示列表
|
private List<Tip> currentTipList; // 当前提示列表
|
||||||
//时间 费用 里程 路费
|
//时间 费用 里程 路费
|
||||||
private TextView tvDuration, tvDistance, tvTolls, tvTollsFuel;
|
private TextView tvDuration, tvDistance, tvTolls, tvTollsFuel, tvPerson, tvPrice, tvPhone;
|
||||||
|
|
||||||
private LatLng currentLatLng;
|
private LatLng currentLatLng;
|
||||||
private String startName = "我的位置";
|
private String startName = "我的位置";
|
||||||
@@ -154,6 +154,7 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
|||||||
private TruckRouteData truckRouteData;
|
private TruckRouteData truckRouteData;
|
||||||
//当前定位信息
|
//当前定位信息
|
||||||
private AMapLocation mLoc;
|
private AMapLocation mLoc;
|
||||||
|
private ImageButton mLocBtn;
|
||||||
|
|
||||||
|
|
||||||
public NativeMapView(Context context, int id, Object args) {
|
public NativeMapView(Context context, int id, Object args) {
|
||||||
@@ -388,59 +389,78 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
|||||||
container.addView(planToggleBtn, toggleParams);
|
container.addView(planToggleBtn, toggleParams);
|
||||||
|
|
||||||
// --- 右下角定位按钮 ---
|
// --- 右下角定位按钮 ---
|
||||||
ImageButton locBtn = new ImageButton(context);
|
mLocBtn = new ImageButton(context);
|
||||||
locBtn.setImageResource(R.drawable.ic_location);
|
mLocBtn.setImageResource(R.drawable.ic_location);
|
||||||
// 设置自定义的白色圆形背景
|
// 设置自定义的白色圆形背景
|
||||||
locBtn.setBackgroundColor(Color.TRANSPARENT);
|
mLocBtn.setBackgroundColor(Color.TRANSPARENT);
|
||||||
// 设置投影(仅在 API 21+ 有效,能产生干净的阴影而非黑块)
|
// 设置投影(仅在 API 21+ 有效,能产生干净的阴影而非黑块)
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
locBtn.setElevation(dp2px(4));
|
mLocBtn.setElevation(dp2px(4));
|
||||||
}
|
}
|
||||||
locBtn.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
mLocBtn.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||||
int padding = dp2px(2);
|
int padding = dp2px(2);
|
||||||
locBtn.setPadding(padding, padding, padding, padding);
|
mLocBtn.setPadding(padding, padding, padding, padding);
|
||||||
locBtn.setOnClickListener(v -> {
|
mLocBtn.setOnClickListener(v -> {
|
||||||
if (currentLatLng != null)
|
if (currentLatLng != null)
|
||||||
aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(currentLatLng, 15f));
|
aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(currentLatLng, 15f));
|
||||||
});
|
});
|
||||||
FrameLayout.LayoutParams locParams = new FrameLayout.LayoutParams(layoutSize, layoutSize);
|
FrameLayout.LayoutParams locParams = new FrameLayout.LayoutParams(layoutSize, layoutSize);
|
||||||
locParams.setMargins(0, 0, dp2px(15), dp2px(285)); // 调高一点,避开底部的面板
|
locParams.setMargins(0, 0, dp2px(15), dp2px(285)); // 调高一点,避开底部的面板
|
||||||
locParams.gravity = Gravity.BOTTOM | Gravity.END;
|
locParams.gravity = Gravity.BOTTOM | Gravity.END;
|
||||||
container.addView(locBtn, locParams);
|
container.addView(mLocBtn, locParams);
|
||||||
|
|
||||||
//最后调用监听函数
|
//最后调用监听函数
|
||||||
addKeyboardListener();
|
addKeyboardListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int lastKeypadHeight = -1; // 记录上次高度,避免重复刷新
|
||||||
|
|
||||||
private void addKeyboardListener() {
|
private void addKeyboardListener() {
|
||||||
container.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
|
container.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
|
||||||
Rect r = new Rect();
|
Rect r = new Rect();
|
||||||
// 获取当前窗口可视区域
|
// 获取当前容器在屏幕上的可视区域
|
||||||
container.getWindowVisibleDisplayFrame(r);
|
container.getWindowVisibleDisplayFrame(r);
|
||||||
|
|
||||||
// screenHeight - 可视区域高度 = 键盘高度
|
// 获取容器在屏幕上的绝对位置
|
||||||
int screenHeight = container.getRootView().getHeight();
|
int[] location = new int[2];
|
||||||
int keypadHeight = screenHeight - r.bottom;
|
container.getLocationOnScreen(location);
|
||||||
|
|
||||||
// 如果键盘高度大于屏幕的 15%,说明键盘弹出了
|
// 容器底部的绝对屏幕坐标
|
||||||
if (keypadHeight > screenHeight * 0.15) {
|
int containerBottomOnScreen = location[1] + container.getHeight();
|
||||||
// 键盘弹出:增加底部 Margin
|
|
||||||
updateBottomMargin(keypadHeight);
|
// 键盘顶部的绝对屏幕坐标就是 r.bottom
|
||||||
|
// 计算键盘遮挡了容器多少高度
|
||||||
|
int keypadHeight = containerBottomOnScreen - r.bottom;
|
||||||
|
|
||||||
|
// 设置一个阈值(比如 100 像素),过滤掉系统导航栏高度的变化
|
||||||
|
if (keypadHeight > 100) {
|
||||||
|
// 键盘弹出:此时 keypadHeight 是键盘相对于容器底部的真实高度
|
||||||
|
if (lastKeypadHeight != keypadHeight) {
|
||||||
|
lastKeypadHeight = keypadHeight;
|
||||||
|
updateBottomMargin(keypadHeight);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// 键盘收起:恢复原有 Margin (你代码中设置的是 dp2px(65))
|
// 键盘收起:恢复原有间距 dp2px(65)
|
||||||
updateBottomMargin(dp2px(65));
|
if (lastKeypadHeight != 0) {
|
||||||
|
lastKeypadHeight = 0;
|
||||||
|
updateBottomMargin(dp2px(65));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBottomMargin(int bottomPx) {
|
private void updateBottomMargin(int bottomPx) {
|
||||||
if (bottomContainer != null) {
|
if (bottomContainer != null) {
|
||||||
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) bottomContainer.getLayoutParams();
|
// 使用 post 确保在布局请求之后执行,避免某些机型上的 requestLayout 冲突
|
||||||
if (params != null) {
|
bottomContainer.post(() -> {
|
||||||
// 动态设置底部间距
|
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) bottomContainer.getLayoutParams();
|
||||||
params.setMargins(dp2px(12), 0, dp2px(12), bottomPx);
|
if (params != null) {
|
||||||
bottomContainer.setLayoutParams(params);
|
// 如果键盘弹出,我们通常不需要额外的 12dp 左右边距(看你 UI 需求)
|
||||||
}
|
// 这里的重点是 bottomPx
|
||||||
|
params.setMargins(dp2px(12), 0, dp2px(12), bottomPx);
|
||||||
|
bottomContainer.setLayoutParams(params);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -473,6 +493,7 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
|||||||
detailPanel.setVisibility(View.GONE);
|
detailPanel.setVisibility(View.GONE);
|
||||||
searchArea.setVisibility(View.VISIBLE);
|
searchArea.setVisibility(View.VISIBLE);
|
||||||
planToggleBtn.setVisibility(View.VISIBLE);
|
planToggleBtn.setVisibility(View.VISIBLE);
|
||||||
|
mLocBtn.setVisibility(View.VISIBLE);
|
||||||
});
|
});
|
||||||
|
|
||||||
LinearLayout.LayoutParams closeParams = new LinearLayout.LayoutParams(dp2px(28), dp2px(28));
|
LinearLayout.LayoutParams closeParams = new LinearLayout.LayoutParams(dp2px(28), dp2px(28));
|
||||||
@@ -480,6 +501,13 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
|||||||
|
|
||||||
panel.addView(titleLayout);
|
panel.addView(titleLayout);
|
||||||
|
|
||||||
|
//营业时间和地址
|
||||||
|
tvBusinessHours = new TextView(context);
|
||||||
|
tvBusinessHours.setTextSize(13);
|
||||||
|
tvBusinessHours.setPadding(0, dp2px(4), 0, 0);
|
||||||
|
tvBusinessHours.setTextColor(Color.GRAY);
|
||||||
|
panel.addView(tvBusinessHours);
|
||||||
|
|
||||||
tvStationAddr = new TextView(context);
|
tvStationAddr = new TextView(context);
|
||||||
tvStationAddr.setTextSize(13);
|
tvStationAddr.setTextSize(13);
|
||||||
tvStationAddr.setPadding(0, dp2px(4), 0, 0);
|
tvStationAddr.setPadding(0, dp2px(4), 0, 0);
|
||||||
@@ -510,8 +538,25 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
|||||||
tvDistance = createInfoItem(row2, R.drawable.ic_mileage, "行驶里程:", "", 1.0f);
|
tvDistance = createInfoItem(row2, R.drawable.ic_mileage, "行驶里程:", "", 1.0f);
|
||||||
// 过路费
|
// 过路费
|
||||||
tvTolls = createInfoItem(row2, R.drawable.ic_toll, "过路费:", "", 1.0f);
|
tvTolls = createInfoItem(row2, R.drawable.ic_toll, "过路费:", "", 1.0f);
|
||||||
|
|
||||||
routeInfoLayout.addView(row2);
|
routeInfoLayout.addView(row2);
|
||||||
|
|
||||||
|
//第三行
|
||||||
|
LinearLayout row3 = new LinearLayout(context);
|
||||||
|
row3.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
|
row3.setGravity(Gravity.CENTER_VERTICAL);
|
||||||
|
row3.setPadding(0, dp2px(8), 0, 0); // 增加行间距
|
||||||
|
tvPerson = createInfoItem(row3, R.drawable.ic_person, "站联系人:", "", 1.0f);
|
||||||
|
tvPrice = createInfoItem(row3, R.drawable.ic_price, "加氢价格:", "", 1.0f);
|
||||||
|
routeInfoLayout.addView(row3);
|
||||||
|
|
||||||
|
LinearLayout row4 = new LinearLayout(context);
|
||||||
|
row4.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
|
row4.setGravity(Gravity.CENTER_VERTICAL);
|
||||||
|
row4.setPadding(0, dp2px(8), 0, 0); // 增加行间距
|
||||||
|
tvPhone = createInfoItem(row4, R.drawable.ic_phone, "联系方式:", "", 1.0f);
|
||||||
|
routeInfoLayout.addView(row4);
|
||||||
|
|
||||||
|
|
||||||
panel.addView(routeInfoLayout);
|
panel.addView(routeInfoLayout);
|
||||||
|
|
||||||
Button startNaviBtn = new Button(context);
|
Button startNaviBtn = new Button(context);
|
||||||
@@ -612,11 +657,15 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
|||||||
detailPanel.setVisibility(View.VISIBLE);
|
detailPanel.setVisibility(View.VISIBLE);
|
||||||
if (planToggleBtn != null)
|
if (planToggleBtn != null)
|
||||||
planToggleBtn.setVisibility(View.GONE);
|
planToggleBtn.setVisibility(View.GONE);
|
||||||
|
if (mLocBtn != null)
|
||||||
|
mLocBtn.setVisibility(View.GONE);
|
||||||
if (modeMenu != null)
|
if (modeMenu != null)
|
||||||
modeMenu.setVisibility(View.GONE);
|
modeMenu.setVisibility(View.GONE);
|
||||||
|
|
||||||
tvStationName.setText(endName);
|
tvStationName.setText(endName);
|
||||||
tvStationAddr.setText(endAddress);
|
tvStationAddr.setText(endAddress);
|
||||||
|
tvBusinessHours.setText("营业时间:" + truckRouteData.destinationSite.startBusiness + "-" +
|
||||||
|
truckRouteData.destinationSite.endBusiness);
|
||||||
|
|
||||||
double distanceKm = truckRouteData.pathDto.distance / 1000f;
|
double distanceKm = truckRouteData.pathDto.distance / 1000f;
|
||||||
long durationMin = truckRouteData.pathDto.duration / 60;
|
long durationMin = truckRouteData.pathDto.duration / 60;
|
||||||
@@ -636,6 +685,9 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
|||||||
tvDistance.setText("行驶里程:" + String.format("%.1f", distanceKm) + "公里");
|
tvDistance.setText("行驶里程:" + String.format("%.1f", distanceKm) + "公里");
|
||||||
tvTolls.setText("过路费:" + tolls + "元");
|
tvTolls.setText("过路费:" + tolls + "元");
|
||||||
tvTollsFuel.setText("加氢费用:" + (isGetInputtips ? "--" : hydrogenCost) + "元");
|
tvTollsFuel.setText("加氢费用:" + (isGetInputtips ? "--" : hydrogenCost) + "元");
|
||||||
|
tvPerson.setText("站联系人:");
|
||||||
|
tvPrice.setText("加氢价格:");
|
||||||
|
tvPhone.setText("联系方式:");
|
||||||
|
|
||||||
isGetInputtips = false;
|
isGetInputtips = false;
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 781 B |
BIN
ln_jq_app/android/app/src/main/res/drawable/ic_person.png
Normal file
|
After Width: | Height: | Size: 762 B |
BIN
ln_jq_app/android/app/src/main/res/drawable/ic_phone.png
Normal file
|
After Width: | Height: | Size: 865 B |
BIN
ln_jq_app/android/app/src/main/res/drawable/ic_price.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 810 B After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 924 B After Width: | Height: | Size: 791 B |
@@ -7,6 +7,7 @@ import 'package:ln_jq_app/pages/c_page/car_info/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';
|
||||||
|
|
||||||
|
import '../mall/mall_view.dart';
|
||||||
import 'index.dart';
|
import 'index.dart';
|
||||||
|
|
||||||
class BaseWidgetsPage extends GetView<BaseWidgetsController> {
|
class BaseWidgetsPage extends GetView<BaseWidgetsController> {
|
||||||
@@ -33,7 +34,7 @@ class BaseWidgetsPage extends GetView<BaseWidgetsController> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> _buildPages() {
|
List<Widget> _buildPages() {
|
||||||
return [ReservationPage(), NativePageIOS(), CarInfoPage(), MinePage()];
|
return [ReservationPage(), NativePageIOS(), MallPage(), CarInfoPage(), MinePage()];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 自定义导航栏 (悬浮胶囊样式)
|
// 自定义导航栏 (悬浮胶囊样式)
|
||||||
|
|||||||