登录页调整 增加半圆角组件 基本完成路线列表功能 基本完成骑行列表 开始做编辑页
This commit is contained in:
1 parent
5156473bb2
commit
10e738f958
100 files changed
+20085
-11852
No files matched your search
@@ -0,0 +1,216 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ResultListController : MonoBehaviour
|
||||
{
|
||||
[SerializeField]Transform routeResult;
|
||||
Transform scrollContent;
|
||||
Transform routeScroll, matchScroll;
|
||||
Transform routeContent, matchContent;
|
||||
Transform btnRoute, btnMatch,searchInput;
|
||||
Color c1, c2;
|
||||
// Start is called before the first frame update
|
||||
int pageIndex = 0, pageSize = 20;
|
||||
string name = "";
|
||||
void Start()
|
||||
{
|
||||
ApiBase.SetCookie("73385F5F719B610D132C1ECF3E9143272BF15214D57ED91CD7A9DFD832407471535112AAEB8E9271F75D54FBBF2D99F18FA313C1EEA5676F5D722D7FBB07C926BEC5905591BF9AFDDC6336552DF273112C2DA1794E6FA2F465B11FECD2E82E52");
|
||||
InitialColor();
|
||||
scroll = transform.Find("ListPanel").Find("Scroll").GetComponent<ScrollRect>();
|
||||
btnMatch = transform.Find("ListPanel").Find("BtnMatch");
|
||||
btnRoute = transform.Find("ListPanel").Find("BtnRoute");
|
||||
searchInput = transform.Find("ListPanel").Find("SearchInput");
|
||||
scrollContent = scroll.transform.Find("Viewport").Find("Content");
|
||||
routeScroll = scrollContent.Find("RouteList");
|
||||
routeContent = routeScroll.Find("Viewport").Find("Content");
|
||||
matchScroll = scrollContent.Find("MatchList");
|
||||
matchContent = matchScroll.Find("Viewport").Find("Content");
|
||||
if (btnMatch != null)
|
||||
{
|
||||
btnMatch.GetComponent<Button>().onClick.AddListener(() => StartScroll(0));
|
||||
}
|
||||
if (btnRoute != null)
|
||||
{
|
||||
btnRoute.GetComponent<Button>().onClick.AddListener(() => StartScroll(1));
|
||||
}
|
||||
if (searchInput != null)
|
||||
{
|
||||
searchInput.Find("Button").GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
name = searchInput.GetComponent<InputField>().text;
|
||||
Refresh();
|
||||
});
|
||||
}
|
||||
if (routeScroll != null)
|
||||
{
|
||||
UIManager.AddEvent(routeScroll.gameObject, UnityEngine.EventSystems.EventTriggerType.EndDrag, OnEndDrag);
|
||||
}
|
||||
if (matchScroll)
|
||||
{
|
||||
UIManager.AddEvent(matchScroll.gameObject, UnityEngine.EventSystems.EventTriggerType.EndDrag, OnEndDrag);
|
||||
}
|
||||
GetList();
|
||||
}
|
||||
|
||||
private void OnEndDrag(BaseEventData e)
|
||||
{
|
||||
var pe = (PointerEventData)e;
|
||||
var scrollrect = pe.pointerDrag.GetComponent<ScrollRect>();
|
||||
if (scrollrect.verticalNormalizedPosition <= 0)
|
||||
{
|
||||
Debug.Log(scrollrect.verticalNormalizedPosition);
|
||||
pageIndex++;
|
||||
GetList();
|
||||
}
|
||||
if (scrollrect.verticalNormalizedPosition >= 1)
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
routeContent.transform.DestroyChildren();
|
||||
pageIndex = 0;
|
||||
GetList();
|
||||
}
|
||||
bool isEnd = false;
|
||||
void GetList()
|
||||
{
|
||||
var r =ConfigHelper.mapInterruptRecordApi.GetMapInterruptRecord(name, pageIndex, 20);
|
||||
if (r.result)
|
||||
{
|
||||
if (r.data.Count == 0 && pageIndex != 0)
|
||||
{
|
||||
isEnd = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isEnd = false;
|
||||
DisplayRouteResult(r.data,routeContent);
|
||||
DisplayRouteResult(r.data, matchContent);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.showToast(gameObject, r.errMsg);
|
||||
}
|
||||
}
|
||||
void DisplayRouteResult(List<RouteResult> list,Transform content)
|
||||
{
|
||||
if (routeResult != null)
|
||||
{
|
||||
foreach (var item in list)
|
||||
{
|
||||
var obj = Instantiate(routeResult);
|
||||
obj.GetComponent<RouteItem>().Initial(item);
|
||||
//obj.SendMessage("Initial", );
|
||||
obj.transform.parent = content;
|
||||
obj.transform.localScale = new Vector3(1, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
void InitialColor()
|
||||
{
|
||||
ColorUtility.TryParseHtmlString("#FFFFFF", out c1);
|
||||
ColorUtility.TryParseHtmlString("#5C5C6E", out c2);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
GoScroll();
|
||||
}
|
||||
void StartScroll(int index)
|
||||
{
|
||||
if (startScroll) return;
|
||||
if (index == 0)
|
||||
{
|
||||
//翻到比赛页,比赛按钮变白,线路按钮变灰
|
||||
scrollIndex = 1;
|
||||
startScroll = true;
|
||||
btnRoute.GetComponent<Text>().color = c2;
|
||||
btnMatch.GetComponent<Text>().color = c1;
|
||||
}
|
||||
else if (index == 1)
|
||||
{
|
||||
//反过来
|
||||
scrollIndex = 0;
|
||||
startScroll = true;
|
||||
btnRoute.GetComponent<Text>().color = c1;
|
||||
btnMatch.GetComponent<Text>().color = c2;
|
||||
}
|
||||
}
|
||||
#region 主页面滑动逻辑
|
||||
int scrollIndex = 0;
|
||||
bool startScroll = false;
|
||||
ScrollRect scroll;
|
||||
//private float scrollValue = 0.5f;
|
||||
int pageNums = 2;
|
||||
void GoScroll()
|
||||
{
|
||||
var index = scrollIndex;
|
||||
var scrollValue = 1f / (pageNums - 1);
|
||||
var value = index * scrollValue;
|
||||
if (scroll != null && startScroll)
|
||||
{
|
||||
if (scroll.horizontalNormalizedPosition >= value)
|
||||
{
|
||||
scroll.horizontalNormalizedPosition -= (scrollValue / 20);
|
||||
if (scroll.horizontalNormalizedPosition <= value)
|
||||
{
|
||||
Debug.Log(index);
|
||||
scroll.horizontalNormalizedPosition = value;
|
||||
startScroll = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
scroll.horizontalNormalizedPosition += (scrollValue / 20);
|
||||
if (scroll.horizontalNormalizedPosition >= value)
|
||||
{
|
||||
Debug.Log(index);
|
||||
scroll.horizontalNormalizedPosition = value;
|
||||
startScroll = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
//float scrollIndex = 0;
|
||||
//bool startScroll = false;
|
||||
//ScrollRect scroll;
|
||||
//void GoScroll()
|
||||
//{
|
||||
// float value = scrollIndex;
|
||||
// if (scroll != null && startScroll)
|
||||
// {
|
||||
// if (scrollIndex == 0)
|
||||
// {
|
||||
// scroll.horizontalNormalizedPosition -= (1f / 20);
|
||||
// if (scroll.horizontalNormalizedPosition <= 0)
|
||||
// {
|
||||
// scroll.horizontalNormalizedPosition = 0;
|
||||
// startScroll = false;
|
||||
|
||||
// }
|
||||
// }
|
||||
// else if (scrollIndex == 1)
|
||||
// {
|
||||
// scroll.horizontalNormalizedPosition += (1f / 20);
|
||||
// if (scroll.horizontalNormalizedPosition >= 1)
|
||||
// {
|
||||
// scroll.horizontalNormalizedPosition = 1;
|
||||
// startScroll = false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e9e4a559c32ef6d4a95d06e4a10c73d4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,122 @@
|
||||
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 RouteItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandler
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
Transform left,row1,row2,right;
|
||||
Transform btnReRide, btnContinue, btnDelete;
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
string titleColor = "#5c5c6e";
|
||||
public void Initial(RouteResult result)
|
||||
{
|
||||
left = transform.Find("Left");
|
||||
row1 = left.Find("Main").Find("Row1");
|
||||
row2 = left.Find("Main").Find("Row2");
|
||||
Utils.DisplayImage(StartCoroutine, transform.Find("CoverImage").GetComponent<RawImage>(), result.RouteImage);
|
||||
left.Find("Main").Find("Name").GetComponent<Text>().text = result.RouteName;
|
||||
left.Find("Main").Find("Time").GetComponent<Text>().text = result.CreateTime.ToString("yyyy-MM-dd HH-mm-ss");
|
||||
row1.Find("Time").GetComponent<Text>().text = $"<color={titleColor}>Riding time:</color>{result.TrainingTime}";
|
||||
row1.Find("Distance").GetComponent<Text>().text = $"<color={titleColor}>Mileage:</color>{result.EndDistance.ToString("#0.00")}KM";
|
||||
row1.Find("Times").GetComponent<Text>().text = $"<color={titleColor}>Times:</color>{result.Count}";
|
||||
row1.Find("Rank").GetComponent<Text>().text = $"<color={titleColor}>Rank:</color>{result.Ranking}";
|
||||
left.Find("Progress").Find("Image").GetComponent<Image>().fillAmount = (float)result.Progress;
|
||||
left.Find("Progress").Find("Value").GetComponent<Text>().text = (result.Progress * 100).ToString("#0");
|
||||
row2.Find("Device").GetComponent<Text>().text = $"<color={titleColor}>Cycling equipment:</color>{result.ManufacturerName}";
|
||||
right = transform.Find("Right");
|
||||
btnContinue = right.Find("BtnContinue");
|
||||
if (btnContinue)
|
||||
{
|
||||
btnContinue.gameObject.SetActive(false);
|
||||
btnContinue.GetComponent<Button>().onClick.AddListener(GoContinue);
|
||||
}
|
||||
btnReRide = right.Find("BtnReRide");
|
||||
if (btnReRide)
|
||||
{
|
||||
btnReRide.gameObject.SetActive(false);
|
||||
btnReRide.GetComponent<Button>().onClick.AddListener(GoReRide);
|
||||
}
|
||||
btnDelete = right.Find("BtnDelete");
|
||||
if (btnDelete)
|
||||
{
|
||||
btnDelete.gameObject.SetActive(false);
|
||||
btnDelete.GetComponent<Button>().onClick.AddListener(Delete);
|
||||
}
|
||||
}
|
||||
|
||||
private void Delete()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void GoReRide()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void GoContinue()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
transform.GetComponent<Image>().color = Utils.HexToColorHtml("#23232d");
|
||||
if (left != null)
|
||||
{
|
||||
left.Find("Main").Find("Time").GetComponent<Text>().color = Utils.HexToColorHtml("#414251");
|
||||
left.Find("Progress").Find("Image").GetComponent<Image>().color = Utils.HexToColorHtml("#5c5c6e");
|
||||
left.Find("Progress").Find("Value").GetComponent<Text>().color = Utils.HexToColorHtml("#414251");
|
||||
left.Find("Progress").Find("bf").GetComponent<Text>().color = Utils.HexToColorHtml("#414251");
|
||||
}
|
||||
if (row1 != null)
|
||||
{
|
||||
row1.Find("Time").GetComponent<Text>().color = Utils.HexToColorHtml("#9E9EAD");
|
||||
row1.Find("Distance").GetComponent<Text>().color = Utils.HexToColorHtml("#9E9EAD");
|
||||
row1.Find("Times").GetComponent<Text>().color = Utils.HexToColorHtml("#9E9EAD");
|
||||
row1.Find("Rank").GetComponent<Text>().color = Utils.HexToColorHtml("#9E9EAD");
|
||||
}
|
||||
titleColor = "#414251";
|
||||
btnContinue.gameObject.SetActive(false);
|
||||
btnReRide.gameObject.SetActive(false);
|
||||
btnDelete.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
transform.GetComponent<Image>().color = Utils.HexToColorHtml("#353543");
|
||||
if (left != null)
|
||||
{
|
||||
left.Find("Main").Find("Time").GetComponent<Text>().color = Utils.HexToColorHtml("#5c5c6e");
|
||||
left.Find("Progress").Find("Image").GetComponent<Image>().color = Utils.HexToColorHtml("#F93086");
|
||||
left.Find("Progress").Find("Value").GetComponent<Text>().color = Utils.HexToColorHtml("#ffffff");
|
||||
left.Find("Progress").Find("bf").GetComponent<Text>().color = Utils.HexToColorHtml("#ffffff");
|
||||
}
|
||||
if (row1 != null)
|
||||
{
|
||||
row1.Find("Time").GetComponent<Text>().color = Utils.HexToColorHtml("#ffffff");
|
||||
row1.Find("Distance").GetComponent<Text>().color = Utils.HexToColorHtml("#ffffff");
|
||||
row1.Find("Times").GetComponent<Text>().color = Utils.HexToColorHtml("#ffffff");
|
||||
row1.Find("Rank").GetComponent<Text>().color = Utils.HexToColorHtml("#ffffff");
|
||||
}
|
||||
titleColor = "#5c5c6e";
|
||||
btnContinue.gameObject.SetActive(true);
|
||||
btnReRide.gameObject.SetActive(true);
|
||||
btnDelete.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f822eddd7a641a744a198d79e43e3f55
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user