Skip to content

Commit d66bb6d

Browse files
committed
- added link to apps.spixi.io
- fixed toastbar - added transactionReceived and paymentSent Mini Apps SDK triggers
1 parent 58e9ebe commit d66bb6d

File tree

20 files changed

+77
-24
lines changed

20 files changed

+77
-24
lines changed

Spixi/Meta/SpixiTransactionInclusionCallbacks.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public void receivedTIVResponse(byte[] txid, bool verified)
2424

2525
TransactionCache.addTransaction(tx);
2626
Friend friend = FriendList.getFriend(tx.pubKey);
27+
bool myTransaction = IxianHandler.isMyAddress(tx.pubKey);
2728
if (friend == null)
2829
{
2930
foreach (var toEntry in tx.toList)
@@ -37,10 +38,27 @@ public void receivedTIVResponse(byte[] txid, bool verified)
3738
}
3839
if (friend != null)
3940
{
40-
SingleChatPage page = Utils.getChatPage(friend);
41-
if (page != null)
41+
SingleChatPage chatPage = Utils.getChatPage(friend);
42+
if (chatPage != null)
4243
{
43-
page.updateTransactionStatus(Transaction.getTxIdString(txid), verified);
44+
chatPage.updateTransactionStatus(Transaction.getTxIdString(txid), verified);
45+
}
46+
47+
IxiNumber amount = tx.toList.First().Value.amount;
48+
MiniAppPage page = Node.MiniAppManager.getAppPage(friend.walletAddress);
49+
if (page == null)
50+
{
51+
Logging.info("App session does not exist.");
52+
return;
53+
}
54+
55+
if (myTransaction)
56+
{
57+
page.paymentSent(friend.walletAddress, amount, tx.getTxIdString(), tx.getBytes(true, true), verified);
58+
}
59+
else
60+
{
61+
page.transactionReceived(friend.walletAddress, amount, tx.getTxIdString(), tx.getBytes(true, true), verified);
4462
}
4563
}
4664

Spixi/MiniApps/MiniAppManager.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,19 @@ public MiniAppPage getAppPage(Address sender_address, string app_id)
449449
}
450450
}
451451

452+
public MiniAppPage getAppPage(Address sender_address)
453+
{
454+
lock (appPages)
455+
{
456+
var pages = appPages.Values.Where(x => x.hasUser(sender_address));
457+
if (pages.Any())
458+
{
459+
return getAppPage(sender_address, pages.First().sessionId);
460+
}
461+
return null;
462+
}
463+
}
464+
452465
public Dictionary<byte[], MiniAppPage> getAppPages()
453466
{
454467
return appPages;

Spixi/Pages/Home/HomePage.xaml.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ private HomePage ()
7272
webView.Opacity = 0;
7373

7474
hideBalance = (bool)Preferences.Default.Get("hidebalance", false);
75-
SpixiLocalization.addCustomString("miniAppsStartNoteHidden", Preferences.Default.Get("miniAppsStartNoteHidden", false) ? "true" : "false");
75+
//SpixiLocalization.addCustomString("miniAppsStartNoteHidden", Preferences.Default.Get("miniAppsStartNoteHidden", false) ? "true" : "false");
7676
SpixiLocalization.addCustomString("devMode", Preferences.Default.Get("devMode", false) ? "true" : "false");
7777

7878
loadPage(webView, "index.html");
@@ -397,6 +397,10 @@ private void onNavigating(object sender, WebNavigatingEventArgs e)
397397
{
398398
Navigation.PushModalAsync(new DevPage());
399399
}
400+
else if (current_url.StartsWith("ixian:spixiAppsLink", StringComparison.Ordinal))
401+
{
402+
Browser.Default.OpenAsync(new Uri(Config.spixiAppsUrl));
403+
}
400404
else
401405
{
402406
// Otherwise it's just normal navigation

Spixi/Pages/MiniApps/MiniAppPage.xaml.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,22 @@ public void appEndSessionReceived(Address sender_address, byte[] data)
392392
});
393393
}
394394

395+
public void transactionReceived(Address sender_address, IxiNumber amount, string txid, byte[] data, bool verified)
396+
{
397+
MainThread.BeginInvokeOnMainThread(() =>
398+
{
399+
Utils.sendUiCommand(this, "SpixiAppSdk.onTransactionReceived", sender_address.ToString(), amount.ToString(), txid, Crypto.hashToString(data), verified.ToString());
400+
});
401+
}
402+
403+
public void paymentSent(Address sender_address, IxiNumber amount, string txid, byte[] data, bool verified)
404+
{
405+
MainThread.BeginInvokeOnMainThread(() =>
406+
{
407+
Utils.sendUiCommand(this, "SpixiAppSdk.onPaymentSent", sender_address.ToString(), amount.ToString(), txid, Crypto.hashToString(data), verified.ToString());
408+
});
409+
}
410+
395411
public bool hasUser(Address user)
396412
{
397413
return userAddresses.Any(x => x.addressNoChecksum.SequenceEqual(user.addressNoChecksum));

Spixi/Resources/Raw/html/css/spixiui-dark.css

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,15 +1054,16 @@ img.emoji {
10541054
.spixi-toastbar {
10551055
visibility: hidden;
10561056
min-width: 250px;
1057-
margin-left: -125px;
1057+
max-width: 90%;
10581058
background-color: var(--colors-surface-04);
10591059
color: var(--colors-text-01);
10601060
text-align: center;
10611061
border-radius: 8px;
10621062
padding: 12px 24px;
1063-
position: absolute;
1063+
position: fixed;
10641064
z-index: 2001;
10651065
left: 50%;
1066+
transform: translate(-50%, 0);
10661067
top: 24px;
10671068
font-size: 14px;
10681069
font-weight: 600;
@@ -1320,7 +1321,7 @@ img.emoji {
13201321
font-size: 14px;
13211322
font-weight: 600;
13221323
color: var(--colors-text-action);
1323-
padding-top: 12px;
1324+
padding-top: 10px;
13241325
margin: 16px auto;
13251326
width: calc(100% - 32px);
13261327
max-width: 640px;

Spixi/Resources/Raw/html/css/spixiui-light.css

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,15 +1050,16 @@ img.emoji {
10501050
.spixi-toastbar {
10511051
visibility: hidden;
10521052
min-width: 250px;
1053-
margin-left: -125px;
1053+
max-width: 90%;
10541054
background-color: var(--colors-surface-04);
10551055
color: var(--colors-text-01);
10561056
text-align: center;
10571057
border-radius: 8px;
10581058
padding: 12px 24px;
1059-
position: absolute;
1059+
position: fixed;
10601060
z-index: 2001;
10611061
left: 50%;
1062+
transform: translate(-50%, 0);
10621063
top: 24px;
10631064
font-size: 14px;
10641065
font-weight: 600;
@@ -1314,7 +1315,7 @@ img.emoji {
13141315
font-size: 14px;
13151316
font-weight: 600;
13161317
color: var(--colors-text-action);
1317-
padding-top: 12px;
1318+
padding-top: 10px;
13181319
margin: 16px auto;
13191320
width: calc(100% - 32px);
13201321
max-width: 640px;

Spixi/Resources/Raw/html/dev.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<i class="fas fa-arrow-left"></i>
3535
</div>
3636
<div>
37-
*SL{dev-title}
37+
*SL{index-side-dev}
3838
</div>
3939
<div>
4040
</div>

Spixi/Resources/Raw/lang/cn-cn.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ app-new-dialog-installfailed-text = 安装应用时发生错误。
3737
apps-title = Spixi 应用
3838
apps-empty = 您没有已安装的应用。
3939
apps-apps-text = 应用
40-
apps-not-sure-text = 不确定从哪里开始?试试下面的精选应用
40+
apps-not-sure-text = 不确定从哪里开始?访问 <a href="ixian:spixiAppsLink">{0}</a> 探索 Spixi 迷你应用
4141
apps-launch = 启动
4242
apps-launch-app = 启动应用
4343
apps-remove-app = 移除此应用

Spixi/Resources/Raw/lang/de-de.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ app-new-dialog-installfailed-text = Ein Fehler ist beim Installieren der App auf
3737
apps-title = Spixi Apps
3838
apps-empty = Du hast keine Apps installiert.
3939
apps-apps-text = Apps
40-
apps-not-sure-text = Du weißt nicht, wo du anfangen sollst? Probiere eine unserer empfohlenen Apps unten aus.
40+
apps-not-sure-text = Du bist dir nicht sicher, wo du anfangen sollst? Besuche <a href="ixian:spixiAppsLink">{0}</a>, um Spixi Mini-Apps zu entdecken.
4141
apps-launch = Starten
4242
apps-launch-app = App starten
4343
apps-remove-app = Diese App entfernen

Spixi/Resources/Raw/lang/en-us.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ app-new-dialog-installfailed-text = An error occurred while installing the app.
3737
apps-title = Spixi Apps
3838
apps-empty = You don't have any apps installed.
3939
apps-apps-text = Apps
40-
apps-not-sure-text = Not sure where to start? Try one of our featured apps below.
40+
apps-not-sure-text = Not sure where to start? Visit <a href="ixian:spixiAppsLink">{0}</a> to explore Spixi Mini Apps.
4141
apps-launch = Launch
4242
apps-launch-app = Launch App
4343
apps-remove-app = Remove This App

0 commit comments

Comments
 (0)