编辑页面手势应用

This commit is contained in:
Caiyanpeng committed 2021-10-09 10:42:27 +08:00
1 parent fd8f419f09
commit cad2e92fd2
8 files changed
+88 -86

No files matched your search

+1 -1
View File
@@ -13,7 +13,7 @@ using System;
public static class App
{
public static string Host = "http://192.168.0.101:5085/";
public static string Host = "http://192.168.0.101:5084/";
public static string AppVersion = Application.version;
@@ -47,46 +47,67 @@ public class EditUserController : PFUIPanel, INativeOnMobileImageSelect
Transform linkContainer;
Dictionary<string, Selectable> dict;
Transform panel;
float? panelTop = null;
UIGradient g1, g2;
protected override void Awake()
{
Debug.Log(Utils.GetIP(Utils.ADDRESSFAM.IPv4));
userApi = new UserApi();
#if !(UNITY_ANDROID || UNITY_IOS)
var panel = this.transform.Find("Panel");
panel = this.transform.Find("Panel");
#else
var panel = this.transform.Find("Panel/MainPanel");
float? panelTop = null;
UIGradient g1 = transform.Find("Panel/Btn1").GetComponent<UIGradient>()
, g2 = transform.Find("Panel/Btn2").GetComponent<UIGradient>();
panel = this.transform.Find("Panel/MainPanel");
panelTop = null;
g1 = transform.Find("Panel/Btn1").GetComponent<UIGradient>();
g2 = transform.Find("Panel/Btn2").GetComponent<UIGradient>();
if (!panelTop.HasValue) panelTop = panel.localPosition.y;
UIManager.AddEvent(transform.Find("Panel/Btn1").gameObject, EventTriggerType.PointerClick, b =>
{
if (!panelTop.HasValue) panelTop = transform.localPosition.y+185;
panel.DOLocalMoveY(panelTop.Value, 0.3f);
g1.color1 = Utils.HexToColorHtml("#F93086");
g1.color2 = Utils.HexToColorHtml("#ff7485");
g2.color1 = Utils.HexToColorHtml("#353543");
g2.color2 = Utils.HexToColorHtml("#474759");
//.color1 = Utils.HexToColorHtml()
setMobilePanelPosition(true);
});
UIManager.AddEvent(transform.Find("Panel/Btn2").gameObject, EventTriggerType.PointerClick, b =>
{
if (!panelTop.HasValue) panelTop = transform.localPosition.y+185;
panel.DOLocalMoveY(panelTop.Value + 370, 0.3f);
g2.color1 = Utils.HexToColorHtml("#F93086");
g2.color2 = Utils.HexToColorHtml("#ff7485");
g1.color1 = Utils.HexToColorHtml("#353543");
g1.color2 = Utils.HexToColorHtml("#474759");
setMobilePanelPosition(false);
});
Debug.Log(panel.localPosition);
TKPanRecognizer pan = new TKPanRecognizer();
var delta = Vector3.zero;
var rect = this.transform.Find("Panel").GetComponent<RectTransform>();
var startLocation = Vector2.zero;
pan.gestureRecognizedEvent += (r) =>
{
delta = pan.deltaTranslation;
delta.x = 0;
delta.z = 0;
panel.transform.position += delta;
//Debug.Log("pan recognizer fired: " + image.transform.position);
//Debug.Log(UIManager.Instance.MainCanvas);
//Debug.Log(this.transform.Find("Panel").GetComponent<Collider>().bounds.size
startLocation = r.startTouchLocation();
if (rect.isPointInTransfrom(startLocation))
{
delta = pan.deltaTranslation;
delta.x = 0;
delta.z = 0;
panel.transform.position += delta;
}
//Debug.Log("pan recognizer fired: " + panel.transform.localPosition);
};
pan.gestureCompleteEvent += (r) =>
{
if (rect.isPointInTransfrom(startLocation))
{
Debug.Log("运行动画");
if (panel.localPosition.y < 185f + 370f / 2f)
{
setMobilePanelPosition(true);
}
else
{
setMobilePanelPosition(false);
}
}
//if (!panelTop.HasValue) panelTop = transform.localPosition.y + 185;
//Debug.Log($"{panel.localPosition.y},{panelTop}");
//Debug.Log(r.deltaTranslation);
};
TouchKit.addGestureRecognizer(pan);
#endif
mID = panel.Find("IDNumber").Find("input").Find("Text").GetComponent<Text>();
mSexDropdown = panel.Find("SexDropdown").GetComponent<PFUIDropdown>();
@@ -299,7 +320,28 @@ public class EditUserController : PFUIPanel, INativeOnMobileImageSelect
}
void setMobilePanelPosition(bool flag)
{
if(flag)
{
if (!panelTop.HasValue) panelTop = panel.localPosition.y;
panel.DOLocalMoveY(panelTop.Value, 0.3f);
g1.color1 = Utils.HexToColorHtml("#F93086");
g1.color2 = Utils.HexToColorHtml("#ff7485");
g2.color1 = Utils.HexToColorHtml("#353543");
g2.color2 = Utils.HexToColorHtml("#474759");
//.color1 = Utils.HexToColorHtml()
}
else
{
if (!panelTop.HasValue) panelTop = panel.localPosition.y;
panel.DOLocalMoveY(panelTop.Value + 370, 0.3f);
g2.color1 = Utils.HexToColorHtml("#F93086");
g2.color2 = Utils.HexToColorHtml("#ff7485");
g1.color1 = Utils.HexToColorHtml("#353543");
g1.color2 = Utils.HexToColorHtml("#474759");
}
}
void SetDayDropdown()
{
//Debug.Log(mDayDropdown.SelectedItem);
+11 -1
View File
@@ -32,7 +32,17 @@ public class UIManager : MonoBehaviour
this.mMainPanel = value;
}
}
public Canvas MainCanvas
{
get
{
if (mMainPanel)
{
return mMainPanel.transform.parent.GetComponent<Canvas>();
}
return null;
}
}
public GameObject Root;
private HomeController mHomePanel;
+9 -1
View File
@@ -76,7 +76,15 @@ namespace Assets.Scripts
}
return output;
}
public static bool isPointInTransfrom(this RectTransform rect,Vector2 point)
{
var MainCanvas = UIManager.Instance.MainCanvas;
if (!MainCanvas) return false;
var size = rect.sizeDelta * MainCanvas.transform.localScale;
var sPoint = new Vector2(rect.position.x - rect.pivot.x * size.x, rect.position.y - rect.pivot.y * size.y);
var ePoint = new Vector2(rect.position.x + (1 - rect.pivot.x) * size.x, rect.position.y + (1 - rect.pivot.y) * size.y);
return point.x >= sPoint.x && point.x <= ePoint.x && point.y >= sPoint.y && point.y <= ePoint.y;
}
public static bool isLowIPhone()
{
var info = SystemInfo.deviceModel;