index.uts 1.7 KB
Newer Older
shutao-dc's avatar
shutao-dc 已提交
1
import { CanWebViewGoBack, CanWebViewGoForward, HasNativeView, CheckWebViewNativeView, CheckInputNativeView, CheckTextareaNativeView, CheckViewNativeView} from "../interface";
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
2
import WebView from 'android.webkit.WebView';
3
import View from "android.view.View"
shutao-dc's avatar
shutao-dc 已提交
4 5
import EditText from "android.widget.EditText"
import ViewGroup from "android.view.ViewGroup"
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
6

DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
7 8
export const canWebViewGoBack : CanWebViewGoBack = function (elementId : string) : boolean {
  const view = uni.getElementById(elementId)?.getAndroidView<WebView>();
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
9 10 11
  return view == null ? false : view.canGoBack();
}

DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
12 13
export const canWebViewGoForward : CanWebViewGoForward = function (elementId : string) : boolean {
  const view = uni.getElementById(elementId)?.getAndroidView<WebView>();
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
14
  return view == null ? false : view.canGoForward();
15 16 17 18 19 20
}

export const hasNativeView : HasNativeView = function (elementId : string) : boolean {
  const view = uni.getElementById(elementId)?.getAndroidView<View>();
  return view != null;
}
shutao-dc's avatar
shutao-dc 已提交
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

export const checkWebViewNativeView: CheckWebViewNativeView = function (elementId : string) : boolean {
  const view = uni.getElementById(elementId)?.getAndroidView<WebView>();
  return view != null;
}

export const checkInputNativeView: CheckInputNativeView = function (elementId : string) : boolean {
  const view = uni.getElementById(elementId)?.getAndroidView<EditText>();
  return view != null;
}

export const checkTextareaNativeView: CheckViewNativeView = function (elementId : string) : boolean {
  const view = uni.getElementById(elementId)?.getAndroidView<EditText>();
  return view != null;
}

export const checkViewNativeView: CheckViewNativeView = function (elementId : string) : boolean {
  const view = uni.getElementById(elementId)?.getAndroidView<ViewGroup>();
  return view != null;
}