登录页调整 增加半圆角组件 基本完成路线列表功能 基本完成骑行列表 开始做编辑页
This commit is contained in:
1 parent
5156473bb2
commit
10e738f958
100 files changed
+20085
-11852
No files matched your search
@@ -21,10 +21,10 @@ namespace Assets.Scripts.UI.Prefab.Login
|
||||
}
|
||||
return op.options;
|
||||
}
|
||||
public static List<Dropdown.OptionData> dayOption28 = SetOptions(28);
|
||||
public static List<Dropdown.OptionData> dayOption29 = SetOptions(29);
|
||||
public static List<Dropdown.OptionData> dayOption30 = SetOptions(30);
|
||||
public static List<Dropdown.OptionData> dayOption31 = SetOptions(31);
|
||||
public static Dictionary<int, List<Dropdown.OptionData>> dayOption = new Dictionary<int, List<Dropdown.OptionData>>()
|
||||
{
|
||||
{28,SetOptions(28) },{29,SetOptions(29) },{30,SetOptions(30) },{31,SetOptions(31) }
|
||||
};
|
||||
}
|
||||
public class CountryModel
|
||||
{
|
||||
@@ -76,22 +76,8 @@ namespace Assets.Scripts.UI.Prefab.Login
|
||||
}
|
||||
public List<Dropdown.OptionData> GetDayOptions(int year,int month)
|
||||
{
|
||||
if (new int[] { 1, 3, 5, 7, 8, 10, 12 }.Contains(month))
|
||||
{
|
||||
return DayOptions.dayOption31;
|
||||
}
|
||||
else if (new int[] { 4, 6, 9, 11 }.Contains(month))
|
||||
{
|
||||
return DayOptions.dayOption30;
|
||||
}
|
||||
else if (month == 2)
|
||||
{
|
||||
return DateTime.IsLeapYear(year) ? DayOptions.dayOption29 : DayOptions.dayOption28;
|
||||
}
|
||||
else
|
||||
{
|
||||
return days;
|
||||
}
|
||||
int day = DateTime.DaysInMonth(year, month);
|
||||
return DayOptions.dayOption[day];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,16 +20,17 @@ public class QuickLoginUser : MonoBehaviour
|
||||
}
|
||||
public void Initial(QUserInfo user)
|
||||
{
|
||||
if (user ==null) return;
|
||||
transform.GetComponent<Button>().onClick.AddListener(() =>
|
||||
if (user == null) return;
|
||||
transform.GetComponent<Button>().onClick.AddListener(async () =>
|
||||
{
|
||||
ApiBase.SetCookie(user.Cookie);
|
||||
var r = ConfigHelper.userApi.GetUserInfo();
|
||||
var r = await ConfigHelper.userApi.QuickLogin();
|
||||
if (r.result)
|
||||
{
|
||||
App.CurrentUser = r.data;
|
||||
//ConfigHelper.CurrentUser = r.data.Value<UserResultModel>("user");
|
||||
//ConfigHelper.CurrentUser = re;
|
||||
var usermodel = r.data.Value<JObject>("user");
|
||||
//var usermodel = r.data.Value<JObject>("user");
|
||||
//App.CurrentUser = new UserModel
|
||||
//{
|
||||
// NickName = usermodel.Value<string>("NickName"),
|
||||
@@ -41,6 +42,7 @@ public class QuickLoginUser : MonoBehaviour
|
||||
// Distance = 0,
|
||||
// Climb = "",
|
||||
//};
|
||||
|
||||
SceneManager.LoadScene("MainScene");
|
||||
}
|
||||
else
|
||||
@@ -94,6 +96,7 @@ public class QuickLoginUser : MonoBehaviour
|
||||
transform.Find("Avatar").GetComponent<RawImage>().DOFade(1f, 0.3f);
|
||||
transform.GetComponent<Button>().enabled = true;
|
||||
transform.Find("NickNameText").GetComponent<Text>().enabled = true;
|
||||
transform.Find("BtnDelete").GetComponent<Button>().gameObject.SetActive(true);
|
||||
}
|
||||
public void setNoActive()
|
||||
{
|
||||
@@ -102,5 +105,6 @@ public class QuickLoginUser : MonoBehaviour
|
||||
transform.Find("Avatar").GetComponent<RawImage>().DOFade(0.5f, 0.3f);
|
||||
transform.GetComponent<Button>().enabled = false;
|
||||
transform.Find("NickNameText").GetComponent<Text>().enabled = false;
|
||||
transform.Find("BtnDelete").GetComponent<Button>().gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts.UI.Prefab.MapList
|
||||
{
|
||||
public class MapFilterOptions
|
||||
{
|
||||
public static List<Dropdown.OptionData> distances = new string[] {"全部",
|
||||
"0-5KM",
|
||||
"5-10KM",
|
||||
"10-20KM",
|
||||
"20-30KM",
|
||||
"30-50KM",
|
||||
"50-100KM",
|
||||
"100-200KM",
|
||||
"200-无限制", }.Select(x=>new Dropdown.OptionData(x)).ToList();
|
||||
public static Dictionary<string, string> distanceDict = new Dictionary<string, string>()
|
||||
{
|
||||
{"全部","" },
|
||||
{"0-5KM","0-5" },
|
||||
{"5-10KM","5-10" },
|
||||
{"10-20KM","10-20" },
|
||||
{"20-30KM","20-30" },
|
||||
{"50-100KM","50-100" },
|
||||
{"100-200KM","100-200" },
|
||||
{"200-无限制","200-99999" },
|
||||
};
|
||||
public static Dictionary<string,string> diffDict = new Dictionary<string, string>()
|
||||
{
|
||||
{"FLAT","0-100" },
|
||||
{"LV.4","100-250" },
|
||||
{"LV.3","250-350" },
|
||||
{"LV.2","350-550" },
|
||||
{"LV.1","550-750" },
|
||||
{"HC","750-99999" },
|
||||
};
|
||||
public static List<Dropdown.OptionData> sorts = new string[] {
|
||||
"Distance","Name","Difficulty","Hot"//,"Times"
|
||||
}.Select(x => new Dropdown.OptionData(x)).ToList();
|
||||
public static Dictionary<string, string> diffDisplayDict = new Dictionary<string, string>()
|
||||
{
|
||||
{"FLAT","0-100" },
|
||||
{"LV.4","100-250" },
|
||||
{"LV.3","250-350" },
|
||||
{"LV.2","350-550" },
|
||||
{"LV.1","550-750" },
|
||||
{"HC","750-99999" },
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 045d47b55ae6eb844827ba951f3af3e6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,4 +1,4 @@
|
||||
using Assets.Cyp.Common;
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
@@ -6,12 +6,6 @@ using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MyMap
|
||||
{
|
||||
public string name { get; set; }
|
||||
public int rank { get; set; }
|
||||
public string image { get; set; }
|
||||
}
|
||||
public class MapItem : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
@@ -36,9 +30,15 @@ public class MapItem : MonoBehaviour
|
||||
});
|
||||
transform.Find("Name").GetComponent<Text>().text = myMap.Name;
|
||||
Utils.DisplayImage(StartCoroutine, transform.Find("MapTitleImg").GetComponent<RawImage>(), myMap.CoverImage);
|
||||
var props = transform.Find("Props");
|
||||
transform.Find("CollectImg").gameObject.SetActive(myMap.IsFavorite);
|
||||
var props = transform.Find("Props");
|
||||
props.Find("DistanceText").GetComponent<Text>().text = $"{myMap.Distance.ToString("#0.00")}KM";
|
||||
props.Find("EleText").GetComponent<Text>().text = $"{(myMap.TotalClimb ?? 0.0).ToString("#0.00")}M";
|
||||
props.Find("SlopeText").GetComponent<Text>().text = $"{myMap.AverageGrade.ToString("#0.00")}%";
|
||||
props.Find("rideText").GetComponent<Text>().text = myMap.TheHeat.ToString();
|
||||
var tabContainer = transform.Find("TabContainer");
|
||||
var diff = tabContainer.Find("Diff");
|
||||
diff.Find("Text").GetComponent<Text>().text = myMap.Hard;
|
||||
tabContainer.Find("3d").gameObject.SetActive(myMap.Enable3D);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class RotateBg : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
transform.Rotate(new Vector3(0,0,-0.01f*1/3));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2646b2ba277320e41bea125e9aebcb06
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -95,29 +95,29 @@ public class EditUserController : PFUIPanel
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height, 0));
|
||||
mHeadImage.material = material;
|
||||
|
||||
var currentUser = App.CurrentUser;
|
||||
mIdText.text = "ID:" + currentUser.Id.ToString();
|
||||
mNameText.text = currentUser.Nickname;
|
||||
//var currentUser = App.CurrentUser;
|
||||
//mIdText.text = "ID:" + currentUser.Id.ToString();
|
||||
//mNameText.text = currentUser.Nickname;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(currentUser.WxHeadImg))
|
||||
{
|
||||
Utils.DisplayImage(StartCoroutine, mHeadImage, currentUser.WxHeadImg);
|
||||
}
|
||||
if (currentUser.Sex == 1)
|
||||
{
|
||||
mSexDropdown.SelectValue("男");
|
||||
}
|
||||
else
|
||||
{
|
||||
mSexDropdown.SelectValue("女");
|
||||
}
|
||||
if (currentUser.Birthday.HasValue)
|
||||
{
|
||||
var birthday = currentUser.Birthday.Value;
|
||||
mYearDropdown.SelectValue(birthday.Year.ToString());
|
||||
mMonthDropdown.SelectValue(birthday.Month.ToString());
|
||||
mDayDropdown.SelectValue(birthday.Day.ToString());
|
||||
}
|
||||
//if (!string.IsNullOrWhiteSpace(currentUser.WxHeadImg))
|
||||
//{
|
||||
// Utils.DisplayImage(StartCoroutine, mHeadImage, currentUser.WxHeadImg);
|
||||
//}
|
||||
//if (currentUser.Sex == 1)
|
||||
//{
|
||||
// mSexDropdown.SelectValue("男");
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// mSexDropdown.SelectValue("女");
|
||||
//}
|
||||
//if (currentUser.Birthday.HasValue)
|
||||
//{
|
||||
// var birthday = currentUser.Birthday.Value;
|
||||
// mYearDropdown.SelectValue(birthday.Year.ToString());
|
||||
// mMonthDropdown.SelectValue(birthday.Month.ToString());
|
||||
// mDayDropdown.SelectValue(birthday.Day.ToString());
|
||||
//}
|
||||
|
||||
UIManager.AddEvent(mSaveButton.gameObject, EventTriggerType.PointerClick, Save);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public class HomeController : PFUIPanel
|
||||
//App.CurrentUser.Distance = res.data.TotalDistance;
|
||||
//App.CurrentUser.Climb = res.data.TotalClimb;
|
||||
//App.CurrentUser.Carlories = res.data.Kcal;
|
||||
SetCurrentUser();
|
||||
//SetCurrentUser();
|
||||
//Climb.text = $"{res.data.TotalClimb.ToString()}M";
|
||||
//Calories.text = $"{res.data.Kcal.ToString()}KCAL";
|
||||
//Calories.text = res.data.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Assets.Cyp.Common;
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using Assets.Scripts.UI.Prefab.MapList;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
@@ -20,7 +21,15 @@ public class MapListController : PFUIPanel
|
||||
[HideInInspector] public int pageIndex = 0;
|
||||
[HideInInspector] public int pageSize = 20;
|
||||
[HideInInspector] public string hard = "全部";
|
||||
|
||||
private Transform distanceOptions;
|
||||
private Transform diffOptions;
|
||||
private Transform tdContainer;
|
||||
private Transform favContainer;
|
||||
private Transform sorts;
|
||||
private Transform sortDir;
|
||||
private Transform searchInput;
|
||||
//private Transform distanceOption;
|
||||
//private Transform distanceOption;
|
||||
private Button returnBtn;
|
||||
public GameObject Content {
|
||||
get
|
||||
@@ -31,6 +40,7 @@ public class MapListController : PFUIPanel
|
||||
private bool isEnd = false;
|
||||
protected override void Start()
|
||||
{
|
||||
ApiBase.SetCookie("73385F5F719B610D132C1ECF3E9143272BF15214D57ED91CD7A9DFD832407471535112AAEB8E9271F75D54FBBF2D99F18FA313C1EEA5676F5D722D7FBB07C926BEC5905591BF9AFDDC6336552DF273112C2DA1794E6FA2F465B11FECD2E82E52");
|
||||
//if (hardSelector != null)
|
||||
//{
|
||||
// hardSelector.onValueChanged.AddListener(ChangeHard);
|
||||
@@ -45,6 +55,44 @@ public class MapListController : PFUIPanel
|
||||
// layout.cellSize = new Vector2((width - 120) / 5, (width - 120) / 5);
|
||||
//}
|
||||
}
|
||||
distanceOptions = transform.Find("Panel").Find("Panel").Find("distanceOptions");
|
||||
if (distanceOptions != null)
|
||||
{
|
||||
var dDropdown = distanceOptions.GetComponent<Dropdown>();
|
||||
dDropdown.options = MapFilterOptions.distances;
|
||||
dDropdown.onValueChanged.AddListener(ChangeDistance);
|
||||
}
|
||||
diffOptions = transform.Find("Panel").Find("Panel").Find("DifficultyContainer");
|
||||
if (diffOptions != null)
|
||||
{
|
||||
foreach (Transform t in diffOptions)
|
||||
{
|
||||
var button = t.GetComponent<Button>();
|
||||
var image = t.GetComponent<Image>();
|
||||
var text = t.Find("Text").GetComponent<Text>();
|
||||
button.onClick.AddListener(() =>
|
||||
{
|
||||
ColorUtility.TryParseHtmlString("#23232D", out Color c1);
|
||||
if (image.color.r == c1.r && image.color.g == c1.g && image.color.b == c1.b)
|
||||
{
|
||||
ColorUtility.TryParseHtmlString("#F93086", out Color c);
|
||||
image.color = c;
|
||||
text.color = new Color(1, 1, 1,1);
|
||||
hands.Add(MapFilterOptions.diffDict[text.text]);
|
||||
}
|
||||
else
|
||||
{
|
||||
ColorUtility.TryParseHtmlString("#6E6E7D", out Color c);
|
||||
image.color = c1;
|
||||
text.color = c;
|
||||
hands.Remove(MapFilterOptions.diffDict[text.text]);
|
||||
}
|
||||
scroll.GetComponent<ScrollRect>().verticalNormalizedPosition = 1;
|
||||
Refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
GetList();
|
||||
if (scroll != null)
|
||||
{
|
||||
@@ -63,6 +111,73 @@ public class MapListController : PFUIPanel
|
||||
UIManager.ShowHomePanel();
|
||||
});
|
||||
}
|
||||
tdContainer = transform.Find("Panel").Find("Panel").Find("3dContainer");
|
||||
favContainer = transform.Find("Panel").Find("Panel").Find("FavContainer");
|
||||
if (tdContainer != null)
|
||||
{
|
||||
tdContainer.GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
var gou = tdContainer.Find("Gou").gameObject;
|
||||
bool v = !gou.activeSelf;
|
||||
gou.SetActive(v);
|
||||
is3d = v;
|
||||
Refresh();
|
||||
});
|
||||
}
|
||||
if (favContainer != null)
|
||||
{
|
||||
favContainer.GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
var gou = favContainer.Find("Gou").gameObject;
|
||||
bool v = !gou.activeSelf;
|
||||
gou.SetActive(v);
|
||||
isFav = v;
|
||||
Refresh();
|
||||
});
|
||||
}
|
||||
searchInput = transform.Find("Panel").Find("Panel").Find("SearchInput");
|
||||
if (searchInput != null)
|
||||
{
|
||||
searchInput.Find("Button").GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
ftname = searchInput.GetComponent<InputField>().text;
|
||||
Refresh();
|
||||
});
|
||||
}
|
||||
sorts = transform.Find("Panel").Find("Panel").Find("FilterOptions");
|
||||
if (sorts != null)
|
||||
{
|
||||
var drop = sorts.GetComponent<Dropdown>();
|
||||
drop.options = MapFilterOptions.sorts;
|
||||
drop.value = 3;
|
||||
drop.onValueChanged.AddListener((int index)=>
|
||||
{
|
||||
sort = drop.options[index].text;
|
||||
var image = sortDir.Find("Image").GetComponent<Image>();
|
||||
image.sprite = Resources.Load<Sprite>("Images/DOWN");
|
||||
sortDire = "desc";
|
||||
Refresh();
|
||||
});
|
||||
}
|
||||
sortDir = transform.Find("Panel").Find("Panel").Find("Dir");
|
||||
if (sortDir)
|
||||
{
|
||||
var image = sortDir.Find("Image").GetComponent<Image>();
|
||||
sortDir.GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
if (image.sprite.name == "DOWN")
|
||||
{
|
||||
image.sprite = Resources.Load<Sprite>("Images/UP");
|
||||
sortDire = "asc";
|
||||
}
|
||||
else
|
||||
{
|
||||
image.sprite = Resources.Load<Sprite>("Images/DOWN");
|
||||
sortDire = "desc";
|
||||
}
|
||||
Refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEndDrag(BaseEventData arg0)
|
||||
@@ -73,7 +188,6 @@ public class MapListController : PFUIPanel
|
||||
Debug.Log(scrollrect.verticalNormalizedPosition);
|
||||
pageIndex++;
|
||||
GetList();
|
||||
|
||||
}
|
||||
if (scrollrect.verticalNormalizedPosition >= 1)
|
||||
{
|
||||
@@ -81,28 +195,39 @@ public class MapListController : PFUIPanel
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeHard(int index)
|
||||
private void ChangeDistance(int index)
|
||||
{
|
||||
var text = distanceOptions.GetComponent<Dropdown>().options[index].text;
|
||||
distance = MapFilterOptions.distanceDict[text];
|
||||
scroll.GetComponent<ScrollRect>().verticalNormalizedPosition = 1;
|
||||
Refresh();
|
||||
//var text = hardSelector.options[index].text;
|
||||
//if (text == "全部难度")
|
||||
//{
|
||||
|
||||
//}
|
||||
}
|
||||
|
||||
//查询条件
|
||||
string ftname = "";
|
||||
string distance = "";
|
||||
List<string> hands = new List<string>();
|
||||
bool is3d = false,isFav = false;
|
||||
string sort = "Hot",sortDire = "desc";
|
||||
//string name = "";
|
||||
//string name = "";
|
||||
public void GetList()
|
||||
{
|
||||
if (isEnd) return;
|
||||
var res = Global.mapApi.GetList(pageIndex, pageSize, "");
|
||||
var res = ConfigHelper.mapApi.GetList(pageIndex, pageSize, ftname,distance,string.Join(",",hands),is3d,sort,sortDire,isFav);
|
||||
if (res.result)
|
||||
{
|
||||
|
||||
if (res.data.Count == 0)
|
||||
if (res.data.Count == 0 && pageIndex != 0)
|
||||
{
|
||||
isEnd = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isEnd = false;
|
||||
DisplayMaps(res.data);
|
||||
}
|
||||
}
|
||||
@@ -128,6 +253,13 @@ public class MapListController : PFUIPanel
|
||||
pageIndex = 0;
|
||||
GetList();
|
||||
}
|
||||
void ResetList()
|
||||
{
|
||||
distance = "";
|
||||
hands = new List<string>();
|
||||
name = "";
|
||||
Refresh();
|
||||
}
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d3acfe11364023479f5bbb56d2cabde
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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