Skip to content

Commit cfff9f6

Browse files
committed
refactor: sample app ui
1 parent 75fda87 commit cfff9f6

File tree

8 files changed

+9537
-7762
lines changed

8 files changed

+9537
-7762
lines changed

sample/Assets/Scenes/AuthenticatedScene.unity

Lines changed: 9076 additions & 7173 deletions
Large diffs are not rendered by default.

sample/Assets/Scenes/SelectAuthMethod.unity

Lines changed: 353 additions & 515 deletions
Large diffs are not rendered by default.

sample/Assets/Scenes/UnauthenticatedScene.unity

Lines changed: 47 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ MonoBehaviour:
183183
m_Calls: []
184184
m_FontData:
185185
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
186-
m_FontSize: 20
186+
m_FontSize: 24
187187
m_FontStyle: 0
188188
m_BestFit: 0
189189
m_MinSize: 0
@@ -263,7 +263,7 @@ MonoBehaviour:
263263
m_Calls: []
264264
m_FontData:
265265
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
266-
m_FontSize: 20
266+
m_FontSize: 24
267267
m_FontStyle: 0
268268
m_BestFit: 0
269269
m_MinSize: 2
@@ -322,8 +322,8 @@ RectTransform:
322322
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
323323
m_AnchorMin: {x: 0, y: 1}
324324
m_AnchorMax: {x: 0, y: 1}
325-
m_AnchoredPosition: {x: 742, y: -20}
326-
m_SizeDelta: {x: 420, y: 40}
325+
m_AnchoredPosition: {x: 777, y: -30}
326+
m_SizeDelta: {x: 450, y: 60}
327327
m_Pivot: {x: 0.5, y: 0.5}
328328
--- !u!114 &233062549
329329
MonoBehaviour:
@@ -446,8 +446,8 @@ MonoBehaviour:
446446
m_IgnoreLayout: 0
447447
m_MinWidth: -1
448448
m_MinHeight: -1
449-
m_PreferredWidth: 420
450-
m_PreferredHeight: 40
449+
m_PreferredWidth: 450
450+
m_PreferredHeight: 60
451451
m_FlexibleWidth: -1
452452
m_FlexibleHeight: -1
453453
m_LayoutPriority: 1
@@ -488,8 +488,8 @@ RectTransform:
488488
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
489489
m_AnchorMin: {x: 0, y: 1}
490490
m_AnchorMax: {x: 0, y: 1}
491-
m_AnchoredPosition: {x: 391, y: -25}
492-
m_SizeDelta: {x: 250, y: 40}
491+
m_AnchoredPosition: {x: 406, y: -30}
492+
m_SizeDelta: {x: 260, y: 60}
493493
m_Pivot: {x: 0.5, y: 0.5}
494494
--- !u!114 &270318906
495495
MonoBehaviour:
@@ -623,8 +623,8 @@ RectTransform:
623623
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
624624
m_AnchorMin: {x: 0, y: 1}
625625
m_AnchorMax: {x: 0, y: 1}
626-
m_AnchoredPosition: {x: 391, y: -20}
627-
m_SizeDelta: {x: 250, y: 40}
626+
m_AnchoredPosition: {x: 406, y: -30}
627+
m_SizeDelta: {x: 260, y: 60}
628628
m_Pivot: {x: 0.5, y: 0.5}
629629
--- !u!114 &291915220
630630
MonoBehaviour:
@@ -735,8 +735,8 @@ MonoBehaviour:
735735
m_IgnoreLayout: 0
736736
m_MinWidth: -1
737737
m_MinHeight: -1
738-
m_PreferredWidth: 250
739-
m_PreferredHeight: 40
738+
m_PreferredWidth: 260
739+
m_PreferredHeight: 60
740740
m_FlexibleWidth: -1
741741
m_FlexibleHeight: -1
742742
m_LayoutPriority: 1
@@ -823,8 +823,8 @@ MonoBehaviour:
823823
m_TargetGraphic: {fileID: 1541372192}
824824
m_HandleRect: {fileID: 1541372191}
825825
m_Direction: 0
826-
m_Value: 0
827-
m_Size: 1
826+
m_Value: 1
827+
m_Size: 0.99999994
828828
m_NumberOfSteps: 0
829829
m_OnValueChanged:
830830
m_PersistentCalls:
@@ -1073,8 +1073,8 @@ RectTransform:
10731073
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
10741074
m_AnchorMin: {x: 0, y: 1}
10751075
m_AnchorMax: {x: 0, y: 1}
1076-
m_AnchoredPosition: {x: 125, y: -25}
1077-
m_SizeDelta: {x: 250, y: 40}
1076+
m_AnchoredPosition: {x: 130, y: -30}
1077+
m_SizeDelta: {x: 260, y: 60}
10781078
m_Pivot: {x: 0.5, y: 0.5}
10791079
--- !u!114 &613764573
10801080
MonoBehaviour:
@@ -1445,8 +1445,8 @@ RectTransform:
14451445
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
14461446
m_AnchorMin: {x: 0, y: 1}
14471447
m_AnchorMax: {x: 0, y: 1}
1448-
m_AnchoredPosition: {x: 1085.396, y: -111}
1449-
m_SizeDelta: {x: 2138.792, y: 50}
1448+
m_AnchoredPosition: {x: 931.35394, y: -126}
1449+
m_SizeDelta: {x: 1830.7079, y: 60}
14501450
m_Pivot: {x: 0.5, y: 0.5}
14511451
--- !u!114 &756533209
14521452
MonoBehaviour:
@@ -1554,7 +1554,7 @@ MonoBehaviour:
15541554
m_Calls: []
15551555
m_FontData:
15561556
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
1557-
m_FontSize: 20
1557+
m_FontSize: 24
15581558
m_FontStyle: 0
15591559
m_BestFit: 0
15601560
m_MinSize: 0
@@ -1691,7 +1691,7 @@ MonoBehaviour:
16911691
m_Calls: []
16921692
m_FontData:
16931693
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
1694-
m_FontSize: 20
1694+
m_FontSize: 24
16951695
m_FontStyle: 0
16961696
m_BestFit: 0
16971697
m_MinSize: 2
@@ -1834,8 +1834,8 @@ RectTransform:
18341834
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
18351835
m_AnchorMin: {x: 0, y: 1}
18361836
m_AnchorMax: {x: 0, y: 1}
1837-
m_AnchoredPosition: {x: 125, y: -20}
1838-
m_SizeDelta: {x: 250, y: 40}
1837+
m_AnchoredPosition: {x: 130, y: -30}
1838+
m_SizeDelta: {x: 260, y: 60}
18391839
m_Pivot: {x: 0.5, y: 0.5}
18401840
--- !u!114 &892906554
18411841
MonoBehaviour:
@@ -1946,8 +1946,8 @@ MonoBehaviour:
19461946
m_IgnoreLayout: 0
19471947
m_MinWidth: -1
19481948
m_MinHeight: -1
1949-
m_PreferredWidth: 250
1950-
m_PreferredHeight: 40
1949+
m_PreferredWidth: 260
1950+
m_PreferredHeight: 60
19511951
m_FlexibleWidth: -1
19521952
m_FlexibleHeight: -1
19531953
m_LayoutPriority: 1
@@ -2006,7 +2006,7 @@ MonoBehaviour:
20062006
m_MinWidth: -1
20072007
m_MinHeight: -1
20082008
m_PreferredWidth: -1
2009-
m_PreferredHeight: 50
2009+
m_PreferredHeight: 60
20102010
m_FlexibleWidth: -1
20112011
m_FlexibleHeight: -1
20122012
m_LayoutPriority: 1
@@ -2046,6 +2046,7 @@ GameObject:
20462046
m_Component:
20472047
- component: {fileID: 997036539}
20482048
- component: {fileID: 997036540}
2049+
- component: {fileID: 997036541}
20492050
m_Layer: 5
20502051
m_Name: Content
20512052
m_TagString: Untagged
@@ -2106,6 +2107,18 @@ MonoBehaviour:
21062107
m_ChildScaleWidth: 0
21072108
m_ChildScaleHeight: 0
21082109
m_ReverseArrangement: 0
2110+
--- !u!114 &997036541
2111+
MonoBehaviour:
2112+
m_ObjectHideFlags: 0
2113+
m_CorrespondingSourceObject: {fileID: 0}
2114+
m_PrefabInstance: {fileID: 0}
2115+
m_PrefabAsset: {fileID: 0}
2116+
m_GameObject: {fileID: 997036538}
2117+
m_Enabled: 1
2118+
m_EditorHideFlags: 0
2119+
m_Script: {fileID: 11500000, guid: 3eff14abe3dbe4539982d7c5e20b0a58, type: 3}
2120+
m_Name:
2121+
m_EditorClassIdentifier:
21092122
--- !u!1 &1023936387
21102123
GameObject:
21112124
m_ObjectHideFlags: 0
@@ -2293,7 +2306,7 @@ MonoBehaviour:
22932306
m_Calls: []
22942307
m_FontData:
22952308
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
2296-
m_FontSize: 20
2309+
m_FontSize: 24
22972310
m_FontStyle: 0
22982311
m_BestFit: 0
22992312
m_MinSize: 0
@@ -2410,7 +2423,7 @@ MonoBehaviour:
24102423
m_Calls: []
24112424
m_FontData:
24122425
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
2413-
m_FontSize: 20
2426+
m_FontSize: 24
24142427
m_FontStyle: 0
24152428
m_BestFit: 0
24162429
m_MinSize: 0
@@ -2517,8 +2530,8 @@ RectTransform:
25172530
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
25182531
m_AnchorMin: {x: 0, y: 1}
25192532
m_AnchorMax: {x: 0, y: 1}
2520-
m_AnchoredPosition: {x: 1085.396, y: -111}
2521-
m_SizeDelta: {x: 2138.792, y: 50}
2533+
m_AnchoredPosition: {x: 931.35394, y: -126}
2534+
m_SizeDelta: {x: 1830.7079, y: 60}
25222535
m_Pivot: {x: 0.5, y: 0.5}
25232536
--- !u!114 &1349788406
25242537
MonoBehaviour:
@@ -2557,7 +2570,7 @@ MonoBehaviour:
25572570
m_Right: 0
25582571
m_Top: 0
25592572
m_Bottom: 0
2560-
m_ChildAlignment: 0
2573+
m_ChildAlignment: 3
25612574
SpacingX: 16
25622575
SpacingY: 16
25632576
ExpandHorizontalSpacing: 0
@@ -2880,7 +2893,7 @@ RectTransform:
28802893
m_AnchorMin: {x: 0, y: 0}
28812894
m_AnchorMax: {x: 0, y: 0}
28822895
m_AnchoredPosition: {x: 0, y: 0}
2883-
m_SizeDelta: {x: 250, y: 40}
2896+
m_SizeDelta: {x: 260, y: 60}
28842897
m_Pivot: {x: 0.5, y: 0.5}
28852898
--- !u!114 &1582459302
28862899
MonoBehaviour:
@@ -3092,7 +3105,7 @@ RectTransform:
30923105
m_AnchorMin: {x: 0, y: 0}
30933106
m_AnchorMax: {x: 0, y: 0}
30943107
m_AnchoredPosition: {x: 0, y: 0}
3095-
m_SizeDelta: {x: 400, y: 50}
3108+
m_SizeDelta: {x: 400, y: 60}
30963109
m_Pivot: {x: 0.5, y: 0.5}
30973110
--- !u!114 &1661390145
30983111
MonoBehaviour:
@@ -3116,7 +3129,7 @@ MonoBehaviour:
31163129
m_Calls: []
31173130
m_FontData:
31183131
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
3119-
m_FontSize: 28
3132+
m_FontSize: 30
31203133
m_FontStyle: 1
31213134
m_BestFit: 0
31223135
m_MinSize: 2
@@ -3349,7 +3362,7 @@ MonoBehaviour:
33493362
m_Calls: []
33503363
m_FontData:
33513364
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
3352-
m_FontSize: 20
3365+
m_FontSize: 24
33533366
m_FontStyle: 2
33543367
m_BestFit: 0
33553368
m_MinSize: 2

sample/Assets/Scripts/AuthenticatedScript.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ private string GetTransactionStatusString(string status)
504504
}
505505
}
506506

507-
public void ShowZkTransactionReceiptStatus()
507+
public void ShowZkTransactionReceipt()
508508
{
509509
AuthenticatedCanvas.gameObject.SetActive(false);
510510
ZkGetTransactionReceiptCanvas.gameObject.SetActive(true);

sample/Assets/Scripts/SafeArea.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using UnityEngine;
2+
3+
/// <summary>
4+
/// Adjusts the UI to fit within the safe area on mobile devices.
5+
/// </summary>
6+
public class SafeArea : MonoBehaviour
7+
{
8+
#if (UNITY_ANDROID && !UNITY_EDITOR) || (UNITY_IPHONE && !UNITY_EDITOR)
9+
private RectTransform rectTransform;
10+
private Rect safeArea;
11+
private Vector2 minAnchor;
12+
private Vector2 maxAnchor;
13+
#endif
14+
15+
void Start()
16+
{
17+
#if (UNITY_ANDROID && !UNITY_EDITOR) || (UNITY_IPHONE && !UNITY_EDITOR)
18+
rectTransform = GetComponent<RectTransform>();
19+
safeArea = Screen.safeArea;
20+
21+
minAnchor = safeArea.position;
22+
maxAnchor = minAnchor + safeArea.size;
23+
24+
minAnchor.x /= Screen.width;
25+
minAnchor.y /= Screen.height;
26+
maxAnchor.x /= Screen.width;
27+
maxAnchor.y /= Screen.height;
28+
29+
rectTransform.anchorMin = minAnchor;
30+
rectTransform.anchorMax = maxAnchor;
31+
#endif
32+
}
33+
}

sample/Assets/Scripts/SafeArea.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sample/Assets/Scripts/SelectAuthMethodScript.cs

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,17 @@ public class SelectAuthMethodScript : MonoBehaviour
99
#pragma warning disable CS8618
1010
[SerializeField] private GameObject TopPadding;
1111
[SerializeField] private Text Output;
12-
[SerializeField] private Toggle UseDeviceCodeAuthToggle;
13-
[SerializeField] private Toggle UsePKCEToggle;
12+
[SerializeField] private Button UseDeviceCodeAuthButton;
13+
[SerializeField] private Button UsePKCEButton;
1414
#pragma warning restore CS8618
1515

1616
void Start()
1717
{
18-
SetupPadding();
19-
2018
// Determine if PKCE is supported based on the platform
2119
SampleAppManager.SupportsPKCE = IsPKCESupported();
2220

23-
// Set up auth based on PKCE support
24-
if (SampleAppManager.SupportsPKCE)
25-
{
26-
ConfigureAuthOptions();
27-
}
28-
else
21+
// If PKCE is not supported, initialise Passport to use Device Code Auth
22+
if (!SampleAppManager.SupportsPKCE)
2923
{
3024
InitialisePassport();
3125
}
@@ -44,24 +38,21 @@ private bool IsPKCESupported()
4438
}
4539

4640
/// <summary>
47-
/// Configures auth options by setting up listeners for the Device Code Auth and PKCE toggles
48-
/// to handle changes in the authentication method.
41+
/// Initialises Passport to use Device Code Auth
4942
/// </summary>
50-
private void ConfigureAuthOptions()
43+
public void UseDeviceCodeAuth()
5144
{
52-
// Set up Device Code Auth toggle
53-
UseDeviceCodeAuthToggle.onValueChanged.AddListener(delegate (bool on)
54-
{
55-
SampleAppManager.UsePKCE = !on;
56-
InitialisePassport();
57-
});
45+
SampleAppManager.UsePKCE = false;
46+
InitialisePassport();
47+
}
5848

59-
// Set up PKCE toggle
60-
UsePKCEToggle.onValueChanged.AddListener(delegate (bool on)
61-
{
62-
SampleAppManager.UsePKCE = on;
63-
InitialisePassport(redirectUri: "imxsample://callback", logoutRedirectUri: "imxsample://callback/logout");
64-
});
49+
/// <summary>
50+
/// Initialises Passport to use PKCE with the specified redirect URIs.
51+
/// </summary>
52+
public void UsePKCE()
53+
{
54+
SampleAppManager.UsePKCE = true;
55+
InitialisePassport(redirectUri: "imxsample://callback", logoutRedirectUri: "imxsample://callback/logout");
6556
}
6657

6758
/// <summary>

0 commit comments

Comments
 (0)