集合首页和详情页
This commit is contained in:
1 parent
16b42a19e4
commit
ec4a28cd2a
66 files changed
+10600
-818
No files matched your search
@@ -230,7 +230,10 @@ public class MapItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandler,
|
||||
map.IsFavorite = !map.IsFavorite;
|
||||
transform.Find("CollectImg").Find("Image").GetComponent<Image>().sprite =
|
||||
UIManager.Instance.collectDict[map.IsFavorite];
|
||||
this.model.IsFavorite = map.IsFavorite;
|
||||
if (model != null)
|
||||
{
|
||||
this.model.IsFavorite = map.IsFavorite;
|
||||
}
|
||||
//SetColor(map.IsFavorite);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using System.Collections;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class NewRouteGroupController : MonoBehaviour
|
||||
{
|
||||
@@ -15,4 +18,9 @@ public class NewRouteGroupController : MonoBehaviour
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Initial(MapRouteArea groupItem)
|
||||
{
|
||||
transform.Find("Title").GetComponent<Text>().text = groupItem.Name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class NewRouteItemController : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Initial(MapRouteAreaItem area, Dictionary<string, Texture> caches = null)
|
||||
{
|
||||
if (area.CoverImage != null)
|
||||
{
|
||||
Utils.DisplayImageTempDict(GetComponent<RawImage>(), area.CoverImage, caches);
|
||||
}
|
||||
transform.Find("Panel/Text").GetComponent<Text>().text = area.Name;
|
||||
UIManager.AddEvent(gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
UIManager.ShowNewRouteDetailPanel(area);
|
||||
//ConfigHelper.mapApi.GetMapRouteAreaDetail(area.Id, 0, 10);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ede6683b9fc33934aae08dee1363e667
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -103,7 +103,7 @@ public class HomeController : PFUIPanel
|
||||
Debug.Log(App.firstEnter.ToString());
|
||||
//UIManager.ShowEarthPanel(App.latitude, App.longitude);
|
||||
#if UNITY_ANDROID || UNITY_IOS
|
||||
UIManager.ShowMapListPanel();
|
||||
UIManager.ShowNewRouteOverviewPanel();
|
||||
#else
|
||||
if (App.firstEnter == 0)
|
||||
{
|
||||
|
||||
@@ -92,8 +92,8 @@ public class MapListController : PFUIPanel
|
||||
map = Resources.Load<GameObject>("UI/Prefab/MapList/MapItem-Mobile");
|
||||
#else
|
||||
topContainer = transform.Find("Panel").Find("Top");
|
||||
transform.Find("MainNav").GetComponent<MainNav>().ShowBack();
|
||||
#endif
|
||||
transform.Find("MainNav").GetComponent<MainNav>().ShowBack();
|
||||
sort = "Near";
|
||||
sortDire = "asc";
|
||||
//if (hardSelector != null)
|
||||
@@ -159,7 +159,7 @@ public class MapListController : PFUIPanel
|
||||
}
|
||||
}
|
||||
BindHeadImage();
|
||||
GetList();
|
||||
Refresh();
|
||||
if (scroll != null)
|
||||
{
|
||||
//scroll.GetComponent<ScrollRect>().onValueChanged.AddListener((v) =>
|
||||
@@ -330,14 +330,14 @@ public class MapListController : PFUIPanel
|
||||
string ftname = "";
|
||||
string distance = "";
|
||||
List<string> hands = new List<string>();
|
||||
bool is3d = false,isFav = false;
|
||||
bool is3d = false,isFav = false,isMine = false,isRecent = false;
|
||||
string sort = "",sortDire = "";
|
||||
//string name = "";
|
||||
//string name = "";
|
||||
async void GetList()
|
||||
{
|
||||
if (isEnd) return;
|
||||
var res = await ConfigHelper.mapApi.GetList(pageIndex, pageSize, ftname,distance,string.Join(",",hands),is3d,sort,sortDire,isFav);
|
||||
var res = await ConfigHelper.mapApi.GetList(pageIndex, pageSize, ftname,distance,string.Join(",",hands),is3d,sort,sortDire,isFav,isMine,isRecent);
|
||||
if (res.result)
|
||||
{
|
||||
if (res.data.Count == 0)
|
||||
@@ -380,6 +380,7 @@ public class MapListController : PFUIPanel
|
||||
public void Refresh()
|
||||
{
|
||||
content.transform.DestroyChildren();
|
||||
HandleType();
|
||||
pageIndex = 0;
|
||||
isEnd = false;
|
||||
GetList();
|
||||
@@ -389,8 +390,10 @@ public class MapListController : PFUIPanel
|
||||
{
|
||||
#if !(UNITY_ANDROID || UNITY_IOS)
|
||||
var routeTypeName = transform.Find("Panel/Top/RouteTypeName");
|
||||
routeTypeName.GetComponent<Text>().text = App.GetLocalString(App.CurrentRouteType);
|
||||
#else
|
||||
var routeTypeName = transform.Find("Panel/RouteTypeName");
|
||||
#endif
|
||||
routeTypeName.GetComponent<Text>().text = App.GetLocalString(App.CurrentRouteType);
|
||||
if (searchInput != null)
|
||||
{
|
||||
//empty Data
|
||||
@@ -429,10 +432,28 @@ public class MapListController : PFUIPanel
|
||||
var drop = sorts.GetComponent<Dropdown>();
|
||||
drop.value = 0;
|
||||
}
|
||||
|
||||
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
void HandleType()
|
||||
{
|
||||
isRecent = false;
|
||||
isFav = false;
|
||||
isMine = false;
|
||||
if (App.CurrentRouteType == "My Upload")
|
||||
{
|
||||
isMine = true;
|
||||
}
|
||||
else if (App.CurrentRouteType == "My Collection")
|
||||
{
|
||||
isFav = true;
|
||||
}
|
||||
else if (App.CurrentRouteType == "Recent Routes")
|
||||
{
|
||||
isRecent = true;
|
||||
}
|
||||
}
|
||||
void ResetList()
|
||||
{
|
||||
distance = "";
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class NewRouteDetailController : PFUIPanel
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
Dictionary<string, Texture> caches;
|
||||
GameObject map;
|
||||
ScrollRect scroll;
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
caches = new Dictionary<string, Texture>();
|
||||
scroll = transform.Find("Container/Right/Scroll View").GetComponent<ScrollRect>();
|
||||
UIManager.AddEvent(scroll.gameObject, UnityEngine.EventSystems.EventTriggerType.EndDrag, OnEndDrag);
|
||||
#if UNITY_ANDROID || UNITY_IOS
|
||||
map = Resources.Load<GameObject>("UI/Prefab/MapList/MapItem-Mobile");
|
||||
#else
|
||||
map = Resources.Load<GameObject>("UI/Prefab/MapList/MapItem");
|
||||
#endif
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
caches = null;
|
||||
Resources.UnloadUnusedAssets();
|
||||
GC.Collect();
|
||||
Debug.Log("list empty");
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
transform.Find("MainNav").GetComponent<MainNav>().ShowBack();
|
||||
var rect = transform.GetComponent<RectTransform>();
|
||||
rect.offsetMax = new Vector2(rect.offsetMax.x, 0);
|
||||
rect.offsetMin = new Vector2(rect.offsetMin.x, 0);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetAxis("Mouse ScrollWheel") != 0)
|
||||
{
|
||||
if (scroll.verticalNormalizedPosition <= 0)
|
||||
{
|
||||
startMouse = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (startMouse)
|
||||
{
|
||||
startMouse = false;
|
||||
OnEndDrag(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
MapRouteAreaItem area;
|
||||
int pageIndex = 0, pageSize = 10;
|
||||
bool isEnd = false, startMouse = false;
|
||||
public async void Initial(MapRouteAreaItem area)
|
||||
{
|
||||
isEnd = false;
|
||||
pageIndex = 0;
|
||||
this.area = area;
|
||||
var left = transform.Find("Container/Left");
|
||||
left.Find("Icon").GetComponent<RawImage>().texture = null;
|
||||
scroll.content.DestroyChildren();
|
||||
if (area.BannerImage != null)
|
||||
{
|
||||
Utils.DisplayImageTempDict(left.Find("Icon").GetComponent<RawImage>(), area.BannerImage, caches);
|
||||
}
|
||||
left.Find("Name").GetComponent<Text>().text = area.Name;
|
||||
GetList();
|
||||
|
||||
}
|
||||
|
||||
private void OnEndDrag(BaseEventData arg0)
|
||||
{
|
||||
Debug.Log(scroll.verticalNormalizedPosition);
|
||||
if (scroll.verticalNormalizedPosition <= 0 && !isEnd)
|
||||
{
|
||||
pageIndex++;
|
||||
GetList();
|
||||
}
|
||||
}
|
||||
|
||||
private async void GetList()
|
||||
{
|
||||
var res = await ConfigHelper.mapApi.GetMapRouteAreaDetail(area.Id, pageIndex, pageSize);
|
||||
if (res.result)
|
||||
{
|
||||
if (res.data.Count > 0)
|
||||
{
|
||||
DisplayMaps(res.data);
|
||||
}
|
||||
else
|
||||
{
|
||||
isEnd = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayMaps(List<MapRoute> list)
|
||||
{
|
||||
if (map != null)
|
||||
{
|
||||
foreach (var item in list)
|
||||
{
|
||||
var obj = Instantiate(map);
|
||||
obj.GetComponent<MapItem>().Initial(item, caches);
|
||||
//obj.SendMessage("Initial", );
|
||||
obj.transform.SetParent(scroll.content.transform);
|
||||
obj.transform.localScale = new Vector3(1, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f7db27f83919ce49a865d9187ff71aa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,7 +1,10 @@
|
||||
using Assets.Scripts;
|
||||
using DG.Tweening;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class NewRouteOverviewController: PFUIPanel
|
||||
@@ -9,25 +12,54 @@ public class NewRouteOverviewController: PFUIPanel
|
||||
// Start is called before the first frame update
|
||||
Transform tmpGroup;
|
||||
Transform tmpItem;
|
||||
int bannerIndex = 0;
|
||||
float? startPos = null;
|
||||
RectTransform bannerContent,collectionContent;
|
||||
Dictionary<string, Texture> caches = null;
|
||||
ScrollRect scroll;
|
||||
protected override void Awake()
|
||||
{
|
||||
caches = new Dictionary<string, Texture>();
|
||||
scroll = transform.Find("Container/Right/Scroll View").GetComponent<ScrollRect>();
|
||||
UIManager.AddEvent(scroll.gameObject, UnityEngine.EventSystems.EventTriggerType.EndDrag, OnEndDrag);
|
||||
}
|
||||
|
||||
private void OnEndDrag(BaseEventData arg0)
|
||||
{
|
||||
if (scroll.verticalNormalizedPosition <= 0 && !isEnd)
|
||||
{
|
||||
pageIndex++;
|
||||
GetList();
|
||||
}
|
||||
if (scroll.verticalNormalizedPosition >= 1.1)
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
caches = null;
|
||||
Resources.UnloadUnusedAssets();
|
||||
GC.Collect();
|
||||
Debug.Log("list empty");
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
#if !(UNITY_ANDROID || UNITY_IOS)
|
||||
tmpGroup = Resources.Load<Transform>("UI/Prefab/NewRoute/RouteGroup");
|
||||
tmpItem = Resources.Load<Transform>("UI/Prefab/NewRoute/RouteItem");
|
||||
var rect = transform.Find("Container/Right/Scroll View/Viewport/Content")
|
||||
#else
|
||||
var rect = transform.GetComponent<RectTransform>();
|
||||
rect.offsetMax = new Vector2(rect.offsetMax.x, 0);
|
||||
rect.offsetMin = new Vector2(rect.offsetMin.x, 0);
|
||||
tmpGroup = Resources.Load<Transform>("UI/Prefab/NewRoute/Mobile/RouteGroup");
|
||||
tmpItem = Resources.Load<Transform>("UI/Prefab/NewRoute/Mobile/RouteItem");
|
||||
#endif
|
||||
collectionContent = transform.Find("Container/Right/Scroll View/Viewport/Content")
|
||||
.GetComponent<RectTransform>();
|
||||
Refresh();
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
var group = Instantiate<Transform>(tmpGroup);
|
||||
for (int j = 0; j < 10; j++)
|
||||
{
|
||||
var item = Instantiate<Transform>(tmpItem);
|
||||
item.SetParent(group.Find("Content"));
|
||||
}
|
||||
group.SetParent(rect);
|
||||
group.localScale = Vector3.one;
|
||||
}
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(rect);
|
||||
|
||||
var left = transform.Find("Container/Left");
|
||||
UIManager.AddEvent(left.Find("MyUpload").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
@@ -46,8 +78,94 @@ public class NewRouteOverviewController: PFUIPanel
|
||||
{
|
||||
ToList("All Route");
|
||||
});
|
||||
#if !(UNITY_ANDROID || UNITY_IOS)
|
||||
var banner = collectionContent.Find("Banner");
|
||||
bannerContent = banner.Find("Viewport/Content").GetComponent<RectTransform>();
|
||||
var btnLeft = banner.Find("Left");
|
||||
var btnRight = banner.Find("Right");
|
||||
UIManager.AddEvent(btnLeft.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
MoveBanner(false);
|
||||
});
|
||||
UIManager.AddEvent(btnRight.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
MoveBanner(true);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
int pageIndex = 0, pageSize = 10;
|
||||
bool isEnd = false,isLock = false;
|
||||
private void Refresh()
|
||||
{
|
||||
pageIndex = 0;
|
||||
isEnd = false;
|
||||
scroll.content.DestroyChildren();
|
||||
GetList();
|
||||
}
|
||||
|
||||
async void GetList()
|
||||
{
|
||||
if (isLock) return;
|
||||
isLock = true;
|
||||
var res = await ConfigHelper.mapApi.GetMapRouteAreaList(pageIndex, pageSize);
|
||||
isLock = false;
|
||||
if (!res.result)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (res.data.Count == 0)
|
||||
{
|
||||
isEnd = true;
|
||||
}
|
||||
foreach (var groupItem in res.data)
|
||||
{
|
||||
var group = Instantiate<Transform>(tmpGroup);
|
||||
group.GetComponent<NewRouteGroupController>().Initial(groupItem);
|
||||
foreach (var area in groupItem.areas)
|
||||
{
|
||||
var item = Instantiate<Transform>(tmpItem);
|
||||
item.GetComponent<NewRouteItemController>().Initial(area, caches);
|
||||
item.SetParent(group.Find("Content"));
|
||||
}
|
||||
group.SetParent(collectionContent);
|
||||
group.localScale = Vector3.one;
|
||||
}
|
||||
//for (int i = 0; i < 10; i++)
|
||||
//{
|
||||
// var group = Instantiate<Transform>(tmpGroup);
|
||||
// for (int j = 0; j < 10; j++)
|
||||
// {
|
||||
// var item = Instantiate<Transform>(tmpItem);
|
||||
// item.SetParent(group.Find("Content"));
|
||||
// }
|
||||
// group.SetParent(collectionContent);
|
||||
// group.localScale = Vector3.one;
|
||||
//}
|
||||
//获取数据后需要重绘
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(collectionContent);
|
||||
}
|
||||
void MoveBanner(bool right)
|
||||
{
|
||||
#if !(UNITY_ANDROID || UNITY_IOS)
|
||||
if (bannerContent == null) return;
|
||||
if (!startPos.HasValue)
|
||||
{
|
||||
startPos = bannerContent.localPosition.x;
|
||||
Debug.Log(startPos);
|
||||
}
|
||||
var k = right ? -1 : 1;
|
||||
bannerIndex += k;
|
||||
if (bannerIndex > 0)
|
||||
{
|
||||
bannerIndex = -3;
|
||||
}
|
||||
else if (bannerIndex < -3)
|
||||
{
|
||||
bannerIndex = 0;
|
||||
}
|
||||
bannerContent.DOLocalMoveX(startPos.Value + bannerIndex * 1171, 0.5f);
|
||||
#endif
|
||||
}
|
||||
void ToList(string type)
|
||||
{
|
||||
App.CurrentRouteType = type;// "";
|
||||
@@ -60,8 +178,31 @@ public class NewRouteOverviewController: PFUIPanel
|
||||
transform.MyDOFade();
|
||||
}
|
||||
// Update is called once per frame
|
||||
float time = 10;
|
||||
bool startMouse = false;
|
||||
void Update()
|
||||
{
|
||||
|
||||
time -= Time.deltaTime;
|
||||
if (time <= 0)
|
||||
{
|
||||
MoveBanner(true);
|
||||
time += 10;
|
||||
}
|
||||
|
||||
if (Input.GetAxis("Mouse ScrollWheel") != 0)
|
||||
{
|
||||
if (scroll.verticalNormalizedPosition <= 0 || scroll.verticalNormalizedPosition>=1.1)
|
||||
{
|
||||
startMouse = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (startMouse)
|
||||
{
|
||||
startMouse = false;
|
||||
OnEndDrag(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user