From b2279f1c6e6c509cf1d380b105859f599252c7a8 Mon Sep 17 00:00:00 2001
From: maxgithubprofile <21055122+maxgithubprofile@users.noreply.github.com>
Date: Sat, 26 Oct 2024 09:33:38 +0300
Subject: [PATCH] patch: miniapps panel (#1310)
* v
* Update satolist.js
* v
* v
* Update package.json
---
components/main/index.css | 4 +-
components/main/index.js | 2 +-
components/main/index.less | 5 +-
components/miniapps/index.css | 12 ++
components/miniapps/index.js | 143 +++++++++++++++++++++++
components/miniapps/index.less | 16 +++
components/miniapps/templates/apps.html | 7 ++
components/miniapps/templates/index.html | 3 +
config/Bastyon.json | 1 +
css/main.css | 17 +++
css/main.less | 22 +++-
js/_map.js | 14 ++-
js/app.js | 1 +
js/lib/apps/index.js | 61 +++++++++-
js/lib/apps/sdk.js | 9 ++
js/satolist.js | 12 +-
package.json | 4 +-
tpls/index.html.tpl | 1 +
tpls/index.php.tpl | 1 +
tpls/index_el.html.tpl | 1 +
tpls/indexcordova.html.tpl | 1 +
21 files changed, 322 insertions(+), 15 deletions(-)
create mode 100644 components/miniapps/index.css
create mode 100644 components/miniapps/index.js
create mode 100644 components/miniapps/index.less
create mode 100644 components/miniapps/templates/apps.html
create mode 100644 components/miniapps/templates/index.html
diff --git a/components/main/index.css b/components/main/index.css
index a613296d4d..f8a42aff2c 100644
--- a/components/main/index.css
+++ b/components/main/index.css
@@ -209,7 +209,6 @@
position: fixed;
left: 0;
bottom: 0;
- background: rgb(var(--background-main));
color: rgb(var(--neutral-grad-3));
padding: 1em;
text-align: center;
@@ -226,6 +225,9 @@
#main .addbutton i {
font-size: 0.8em;
}
+#main .addbutton i {
+ width: 22px;
+}
#main .addbutton.scrollactive {
display: block;
opacity: 0.8;
diff --git a/components/main/index.js b/components/main/index.js
index 0c1240a3b8..3c0e524138 100644
--- a/components/main/index.js
+++ b/components/main/index.js
@@ -166,7 +166,7 @@ var main = (function(){
addbuttonscroll : function(){
- if (self.app.lastScrollTop > 400){
+ if (self.app.lastScrollTop > 1200){
if(!addbuttonShowed)
el.addbutton.addClass('scrollactive')
diff --git a/components/main/index.less b/components/main/index.less
index 16afd1dd9c..d3590bcf45 100644
--- a/components/main/index.less
+++ b/components/main/index.less
@@ -285,7 +285,6 @@
position: fixed;
left : 0;
bottom : 0;
- background: rgb(var(--background-main));
color : rgb(var(--neutral-grad-3));
padding : 2 * @rhythm;
text-align: center;
@@ -300,6 +299,10 @@
font-size: 0.8em;
}
+ i{
+ width: 22px;
+ }
+
&.scrollactive{
display: block;
opacity: 0.8;
diff --git a/components/miniapps/index.css b/components/miniapps/index.css
new file mode 100644
index 0000000000..957ee0dd8e
--- /dev/null
+++ b/components/miniapps/index.css
@@ -0,0 +1,12 @@
+#miniapps {
+ width: 100%;
+}
+#miniapps .miniapp {
+ cursor: pointer;
+ padding: 0.5em 0.75em;
+ width: 100%;
+ background: rgb(var(--background-secondary-theme));
+}
+#miniapps .miniapp .appimage {
+ aspect-ratio: 1;
+}
diff --git a/components/miniapps/index.js b/components/miniapps/index.js
new file mode 100644
index 0000000000..eedcaadd96
--- /dev/null
+++ b/components/miniapps/index.js
@@ -0,0 +1,143 @@
+var miniapps = (function(){
+
+ var self = new nModule();
+
+ var essenses = {};
+
+ var Essense = function(p){
+
+ var primary = deep(p, 'history');
+
+ var el, ed;
+
+ var actions = {
+
+ }
+
+ var events = {
+
+ }
+
+ var renders = {
+ miniapps : function(){
+ var apps = self.app.apps.get.forminiapps()
+
+ self.shell({
+ name : 'apps',
+ data : {
+ apps
+ },
+
+ el : el.c
+
+ }, function(_p){
+ if(clbk) clbk()
+ })
+ }
+ }
+
+ var state = {
+ save : function(){
+
+ },
+ load : function(){
+
+ }
+ }
+
+ var initEvents = function(){
+
+ self.app.apps.on('installed', renders.miniapps)
+ self.app.apps.on('removed', renders.miniapps)
+ self.app.apps.on('loaded', renders.miniapps)
+ }
+
+ return {
+ primary : primary,
+
+ getdata : function(clbk, p){
+
+
+ ed = p.settings.essenseData
+
+ var data = {
+ ed
+ };
+
+
+ pretry(() => {
+ return self.app.apps.inited
+ }, 100, 15000).then(() => {
+ var apps = self.app.apps.get.forminiapps()
+
+ data.apps = apps
+
+
+ clbk(data);
+ })
+
+
+
+ },
+
+ destroy : function(){
+ ed = {}
+ el = {};
+
+ self.app.apps.off('installed', renders.miniapps)
+ self.app.apps.off('removed', renders.miniapps)
+ self.app.apps.off('loaded', renders.miniapps)
+ },
+
+ init : function(p){
+
+ state.load();
+
+ el = {};
+ el.c = p.el.find('#' + self.map.id);
+
+ initEvents();
+
+ renders.miniapps()
+
+ p.clbk(null, p);
+ }
+ }
+ };
+
+
+
+ self.run = function(p){
+
+ var essense = self.addEssense(essenses, Essense, p);
+
+ self.init(essense, p);
+
+ };
+
+ self.stop = function(){
+
+ _.each(essenses, function(essense){
+
+ window.rifticker.add(() => {
+ essense.destroy();
+ })
+
+ })
+
+ }
+
+ return self;
+})();
+
+
+if(typeof module != "undefined")
+{
+ module.exports = miniapps;
+}
+else{
+
+ app.modules.miniapps = {};
+ app.modules.miniapps.module = miniapps;
+
+}
\ No newline at end of file
diff --git a/components/miniapps/index.less b/components/miniapps/index.less
new file mode 100644
index 0000000000..7c791d3edf
--- /dev/null
+++ b/components/miniapps/index.less
@@ -0,0 +1,16 @@
+@import "../../css/__cssvar";
+
+#miniapps{
+ width: 100%;
+ .miniapp{
+ cursor: pointer;
+ padding :@rhythm 1.5 * @rhythm;
+ width: 100%;
+
+ background: rgb(var(--background-secondary-theme));
+
+ .appimage{
+ aspect-ratio: 1;
+ }
+ }
+}
\ No newline at end of file
diff --git a/components/miniapps/templates/apps.html b/components/miniapps/templates/apps.html
new file mode 100644
index 0000000000..e3bbecce6d
--- /dev/null
+++ b/components/miniapps/templates/apps.html
@@ -0,0 +1,7 @@
+<% _.each(apps, function(app){ %>
+
+
+
+ <% }) %>
\ No newline at end of file
diff --git a/components/miniapps/templates/index.html b/components/miniapps/templates/index.html
new file mode 100644
index 0000000000..92bc7ae63d
--- /dev/null
+++ b/components/miniapps/templates/index.html
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/config/Bastyon.json b/config/Bastyon.json
index 4b59f40c0a..a7ec5af0a0 100644
--- a/config/Bastyon.json
+++ b/config/Bastyon.json
@@ -23,6 +23,7 @@
"name" : "Barteron",
"grantedPermissions" : ["account", "chat"],
"includeinsearch" : true,
+ "includeminiapps" : true,
"store" : {}
}],
"protocol" : "bastyon",
diff --git a/css/main.css b/css/main.css
index abeb026da1..cf79b1c783 100644
--- a/css/main.css
+++ b/css/main.css
@@ -2316,6 +2316,7 @@ input[type=radio].radio:checked + label {
}
#windowsContainer .rightchatspacer {
margin-right: 0;
+ margin-left: 0;
}
#windowsContainer .wnd:nth-last-child(2) .wndback,
#windowsContainer .wnd:nth-last-child(1) .wndback {
@@ -6456,14 +6457,29 @@ html.mobileview #bnavigation .fakem {
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b3dced', endColorstr='#ffffff', GradientType=0 );
}
}*/
+#miniappscnt {
+ position: fixed;
+ left: 0;
+ width: 44px;
+ bottom: 52px;
+ border-top-right-radius: 0.5em;
+ border-bottom-right-radius: 0.5em;
+ overflow: hidden;
+ z-index: 15;
+}
@media only screen and (max-width: 1400px) {
.rightchatspacer {
margin-right: 33px;
+ margin-left: 33px;
}
}
@media only screen and (max-width: 768px) {
.rightchatspacer {
margin-right: 0;
+ margin-left: 0;
+ }
+ #miniappscnt {
+ display: none;
}
}
@media only screen and (max-width: 1366px) {
@@ -6479,6 +6495,7 @@ html.mobileview #bnavigation .fakem {
}
html.mobileview .rightchatspacer {
margin-right: 0;
+ margin-left: 0;
}
html.mobileview #content .work {
/*width: 100%;*/
diff --git a/css/main.less b/css/main.less
index decd3d4dbf..1e4cf7f492 100644
--- a/css/main.less
+++ b/css/main.less
@@ -2694,6 +2694,7 @@ input[type=radio].radio:checked + label {
#windowsContainer{
.rightchatspacer{
margin-right: 0;
+ margin-left: 0;
}
.wnd{
@@ -7910,18 +7911,33 @@ html{
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b3dced', endColorstr='#ffffff', GradientType=0 );
}
}*/
-
+#miniappscnt{
+ position: fixed;
+ left: 0;
+ width: 44px;
+ bottom: 52px;
+ border-top-right-radius: @rhythm;
+ border-bottom-right-radius: @rhythm;
+ overflow: hidden;
+ z-index: 15;
+}
@media only screen and (max-width: 1400px) {
.rightchatspacer{
margin-right: 33px;
+ margin-left: 33px;
}
}
@media only screen and (max-width: 768px) {
.rightchatspacer{
margin-right: 0;
+ margin-left: 0;
+ }
+
+ #miniappscnt{
+ display: none;
}
}
@@ -7936,9 +7952,6 @@ html{
}
-
-
-
@media only screen and (max-width: 1280px) {
#content{
.work{
@@ -7951,6 +7964,7 @@ html{
html.mobileview{
.rightchatspacer{
margin-right: 0;
+ margin-left: 0;
}
#content .work{
diff --git a/js/_map.js b/js/_map.js
index c1b23e8989..71c12243e0 100644
--- a/js/_map.js
+++ b/js/_map.js
@@ -968,8 +968,18 @@ __map = {
viewchangereload : true
},
-
-
+ miniapps : {
+ uri : "miniapps",
+ href : "miniapps",
+ add : {
+ el : 'miniapps'
+ },
+ now : true,
+ anonimus : true,
+ renew : true,
+ reload : true,
+ viewchangereload : true
+ },
bnavigation : {
uri : "bnavigation",
diff --git a/js/app.js b/js/app.js
index bd5e004001..53a1505aad 100644
--- a/js/app.js
+++ b/js/app.js
@@ -1408,6 +1408,7 @@ Application = function (p) {
self.el = {
camera: $('#camera'),
content: $('#content'),
+ miniapps: $('#miniappscnt'),
app: $('#application'),
header: $('#headerWrapper'),
menu: $('#menuWrapper'),
diff --git a/js/lib/apps/index.js b/js/lib/apps/index.js
index 98a3f783a0..c16901c3a6 100644
--- a/js/lib/apps/index.js
+++ b/js/lib/apps/index.js
@@ -756,6 +756,43 @@ var BastyonApps = function(app){
return makeAction(vote, application)
}
}
+ },
+
+ open : {
+ donation : {
+ parameters : ['receiver'],
+ action : function({data, application}){
+
+ return app.platform.ui.wallet.donate({
+ reciever : data.reciever
+ }).then((p) => {
+ return Promise.resolve({value : p.value, txid : p.txid})
+ }).catch(e => {
+ return Promise.reject(appsError(e))
+ })
+
+ //// TODO CHECK ELECTRON NODE SAFE
+ return app.api.rpc(data.method, data.parameters, data.options)
+ }
+ },
+
+ post : {
+ parameters : ['txid'],
+ action : function({data, application}){
+
+ self.nav.api.load({
+ open : true,
+ href : 'post?s=' + data.txid,
+ inWnd : true,
+ essenseData : {
+ share : data.txid
+ }
+ })
+
+ //// TODO CHECK ELECTRON NODE SAFE
+ return Promise.resolve({})
+ }
+ }
}
}
@@ -966,6 +1003,12 @@ var BastyonApps = function(app){
result.includeinsearch = true
}
+ if (application.includeminiapps){
+ result.includeminiapps = true
+ }
+
+
+
if (application.production){
result.production = true
}
@@ -993,7 +1036,7 @@ var BastyonApps = function(app){
delete installing[application.id]
}), application}
- return installing[application.id]
+ return installing[application.id].promise
}
@@ -1528,6 +1571,8 @@ var BastyonApps = function(app){
return Promise.all(promises).then(() => {
+ console.log("miniapp ini")
+
self.inited = true
window.addEventListener("message", listener)
@@ -1552,6 +1597,20 @@ var BastyonApps = function(app){
}
})
},
+
+ forminiapps : function(){
+ return _.map(_.filter(installed, (s) => {
+ return s.includeminiapps
+ }), app => {
+
+ return {
+ icon : app.icon,
+ name : app.manifest.name,
+ url : 'application?id=' + app.manifest.id,
+ type : 'application'
+ }
+ })
+ },
installing : function(){
return installing
},
diff --git a/js/lib/apps/sdk.js b/js/lib/apps/sdk.js
index d9db552817..aef8c6184d 100644
--- a/js/lib/apps/sdk.js
+++ b/js/lib/apps/sdk.js
@@ -270,6 +270,15 @@ var BastyonSdk = function(){
}
}
+ self.open = {
+ post : function(txid){
+ return action('open.post', {txid})
+ },
+ donate : function(receiver){
+ return action('open.donate', {receiver})
+ },
+ }
+
self.permissions = {
check : function({permission}){
return action('checkPermission', {permission})
diff --git a/js/satolist.js b/js/satolist.js
index c10e041d74..967e75fa13 100644
--- a/js/satolist.js
+++ b/js/satolist.js
@@ -398,7 +398,13 @@ Platform = function (app, listofnodes) {
'PMABcFZc7fcgPZzstJrHeYoWXJGoP3pd7X' : true,
'PSbFTgRftgSCsTzTdYFWY6SYkPD72Pdqfx' : true,
'PMqBXWqWn4SEM6ZM5fWrXxsFpbtW31886J' : true,
- 'PT7pwrGFNGLmSxUqU1akFr2PzhcTozEH5B' : true
+ 'PT7pwrGFNGLmSxUqU1akFr2PzhcTozEH5B' : true,
+ 'PJehpQqXpregZF2aiDyPfwceer2kG71mCy' : true,
+ 'PThktEkvkgNeL9G6EDAESNwneUGz9DeugR' : true,
+ 'PSdjmyvT9qQZxbYMB7jfmsgKokQtP6KkiX' : true,
+ 'P9K1uMNAkhHJGfbMFJXyxs4nBdmowL9rvp' : true,
+ 'PU3PEYF6EJRjm6HC2cXJpC5R6vFCU3Vkao' : true
+
}
self.bch = {
@@ -4313,7 +4319,7 @@ Platform = function (app, listofnodes) {
if (sender === receiver){
sitemessage(self.app.localization.e('donateself'));
- reject()
+ reject('donateself')
}
else{
@@ -4346,7 +4352,7 @@ Platform = function (app, listofnodes) {
p.value = value;
p.send = _p.send
-
+ p.txid = txid
resolve(p)
}
diff --git a/package.json b/package.json
index 91e6b66e8a..09f27ce3fa 100644
--- a/package.json
+++ b/package.json
@@ -4,9 +4,9 @@
"version": "0.9.102",
- "versionsuffix": "0",
+ "versionsuffix": "2",
"cordovaversion": "1.8.102",
- "cordovaversioncode": "1801020",
+ "cordovaversioncode": "1801022",
"description": "Bastyon desktop application",
"author": "Pocketnet Community ",
diff --git a/tpls/index.html.tpl b/tpls/index.html.tpl
index 4f529f0bff..75cf8b6c5c 100644
--- a/tpls/index.html.tpl
+++ b/tpls/index.html.tpl
@@ -97,6 +97,7 @@
+
diff --git a/tpls/index.php.tpl b/tpls/index.php.tpl
index 46de1a6a20..6f92e333ef 100644
--- a/tpls/index.php.tpl
+++ b/tpls/index.php.tpl
@@ -108,6 +108,7 @@
+
diff --git a/tpls/index_el.html.tpl b/tpls/index_el.html.tpl
index 518f5bfcca..eb07f52fef 100644
--- a/tpls/index_el.html.tpl
+++ b/tpls/index_el.html.tpl
@@ -106,6 +106,7 @@
+
diff --git a/tpls/indexcordova.html.tpl b/tpls/indexcordova.html.tpl
index 122a4f3250..d46935bb25 100644
--- a/tpls/indexcordova.html.tpl
+++ b/tpls/indexcordova.html.tpl
@@ -99,6 +99,7 @@
+