implemented browser , removed browse command
This commit is contained in:
parent
1ba7c33868
commit
7e78acc0cc
|
@ -1,16 +1,4 @@
|
|||
{
|
||||
"browse":
|
||||
{
|
||||
"name":
|
||||
{
|
||||
"en": "Browse"
|
||||
},
|
||||
"dapp?": true,
|
||||
"hide-contact?": true,
|
||||
"bot-url": "local://browse-bot",
|
||||
"unremovable?": true
|
||||
},
|
||||
|
||||
"mailman":
|
||||
{
|
||||
"name":
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
||||
<path fill="" d="M8.17529019,16.4426373 C10.6009211,18.8051525 14.4824966,18.7856274 16.884062,16.384062 C19.3053126,13.9628114 19.3053126,10.0371886 16.884062,7.61593801 C14.4628114,5.19468743 10.5371886,5.19468743 8.11593801,7.61593801 C7.43203677,8.29983925 6.93009988,9.11461765 6.62934021,10 L9.5,10 C10.0522847,10 10.5,10.4477153 10.5,11 C10.5,11.5522847 10.0522847,12 9.5,12 L4.5,12 C3.94771525,12 3.5,11.5522847 3.5,11 L3.5,6 C3.5,5.44771525 3.94771525,5 4.5,5 C5.05228475,5 5.5,5.44771525 5.5,6 L5.5,8.12275556 C5.85382249,7.48469926 6.30153774,6.88475376 6.84314575,6.34314575 C9.96734008,3.21895142 15.0326599,3.21895142 18.1568542,6.34314575 C21.2810486,9.46734008 21.2810486,14.5326599 18.1568542,17.6568542 C15.0326599,20.7810486 9.96734008,20.7810486 6.84314575,17.6568542 L6.8714639,17.6285361 C6.64635582,17.464943 6.5,17.1995631 6.5,16.9 C6.5,16.4029437 6.90294371,16 7.39999998,16 C7.73007871,16 8.01865521,16.1776922 8.17529019,16.4426373 Z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.0 KiB |
|
@ -1,49 +0,0 @@
|
|||
function browse(params, context) {
|
||||
var url;
|
||||
|
||||
if (params.metadata && params.metadata.url
|
||||
&& params.metadata.url !== "undefined" && params.metadata.url != "") {
|
||||
url = params.metadata.url;
|
||||
}
|
||||
|
||||
if (params.url && params.url !== "undefined" && params.url != "") {
|
||||
url = params.url;
|
||||
}
|
||||
|
||||
if (url && !/^[a-zA-Z-_]+:/.test(url)) {
|
||||
url = 'http://' + url;
|
||||
}
|
||||
|
||||
return {
|
||||
title: "Browser",
|
||||
dynamicTitle: true,
|
||||
singleLineInput: true,
|
||||
actions: [
|
||||
{
|
||||
type: status.actions.WEB_VIEW_BACK
|
||||
},
|
||||
{
|
||||
type: status.actions.WEB_VIEW_FORWARD
|
||||
},
|
||||
{
|
||||
type: status.actions.FULLSCREEN
|
||||
},
|
||||
],
|
||||
markup: status.components.bridgedWebView(url)
|
||||
};
|
||||
}
|
||||
|
||||
status.command({
|
||||
name: "browse",
|
||||
title: I18n.t('browse_title'),
|
||||
scope: ["global", "personal-chats", "group-chats", "public-chats", "registered", "dapps", "humans"],
|
||||
description: I18n.t('browse_description'),
|
||||
color: "#ffa500",
|
||||
fullscreen: true,
|
||||
params: [{
|
||||
name: "url",
|
||||
type: status.types.TEXT,
|
||||
placeholder: "URL"
|
||||
}],
|
||||
onSend: browse
|
||||
});
|
|
@ -1,146 +0,0 @@
|
|||
I18n.translations = {
|
||||
en: {
|
||||
browse_title: 'Browser',
|
||||
browse_description: 'Launch the browser'
|
||||
},
|
||||
ru: {
|
||||
browse_title: 'Браузер',
|
||||
browse_description: 'Запуск браузера'
|
||||
},
|
||||
af: {
|
||||
browse_title: 'Webblaaier',
|
||||
browse_description: 'Begin die webblaaier'
|
||||
},
|
||||
ar: {
|
||||
browse_title: 'المتصفح',
|
||||
browse_description: 'تشغيل المتصفح'
|
||||
},
|
||||
'zh-hant': {
|
||||
browse_title: '瀏覽器',
|
||||
browse_description: '啟動瀏覽器'
|
||||
},
|
||||
'zh-hant-tw': {
|
||||
browse_title: '瀏覽器',
|
||||
browse_description: '啟動瀏覽器'
|
||||
},
|
||||
'zh-hant-sg': {
|
||||
browse_title: '瀏覽器',
|
||||
browse_description: '啟動瀏覽器'
|
||||
},
|
||||
'zh-hant-hk': {
|
||||
browse_title: '瀏覽器',
|
||||
browse_description: '啟動瀏覽器'
|
||||
},
|
||||
'zh-hans': {
|
||||
browse_title: '浏览器',
|
||||
browse_description: '启动浏览器'
|
||||
},
|
||||
'zh-yue': {
|
||||
browse_title: '瀏覽器',
|
||||
browse_description: '啟動瀏覽器'
|
||||
},
|
||||
'zh-wuu': {
|
||||
browse_title: '浏览器',
|
||||
browse_description: '启动浏览器'
|
||||
},
|
||||
nl: {
|
||||
browse_title: 'Browser',
|
||||
browse_description: 'Start de browser'
|
||||
},
|
||||
fr: {
|
||||
browse_title: 'Navigateur',
|
||||
browse_description: 'Lancer le navigateur'
|
||||
},
|
||||
de: {
|
||||
browse_title: 'Browser',
|
||||
browse_description: 'Browser starten'
|
||||
},
|
||||
hi: {
|
||||
browse_title: 'ब्राउज़र',
|
||||
browse_description: 'ब्राउज़र लॉन्च करें'
|
||||
},
|
||||
hu: {
|
||||
browse_title: 'Böngésző',
|
||||
browse_description: 'Böngésző indítása'
|
||||
},
|
||||
it: {
|
||||
browse_title: 'Browser',
|
||||
browse_description: 'Lancia il browser'
|
||||
},
|
||||
ja: {
|
||||
browse_title: 'ブラウザ',
|
||||
browse_description: 'ブラウザを起動'
|
||||
},
|
||||
ko: {
|
||||
browse_title: '브라우저',
|
||||
browse_description: '브라우저 시작하기'
|
||||
},
|
||||
pl: {
|
||||
browse_title: 'Przeglądarka',
|
||||
browse_description: 'Uruchom przeglądarkę'
|
||||
},
|
||||
'pt-br': {
|
||||
browse_title: 'Navegador',
|
||||
browse_description: 'Abrir o navegador'
|
||||
},
|
||||
'pt-pt': {
|
||||
browse_title: 'Navegador',
|
||||
browse_description: 'Abrir o navegador'
|
||||
},
|
||||
ro: {
|
||||
browse_title: 'Browser',
|
||||
browse_description: 'Lansare browser'
|
||||
},
|
||||
sl: {
|
||||
browse_title: 'Brskalnik',
|
||||
browse_description: 'Zaženi brskalnik'
|
||||
},
|
||||
es: {
|
||||
browse_title: 'Navegador',
|
||||
browse_description: 'Iniciar el navegador'
|
||||
},
|
||||
'es-ar': {
|
||||
browse_title: 'Navegador',
|
||||
browse_description: 'Iniciar navegador'
|
||||
},
|
||||
sw: {
|
||||
send_title: 'Tuma ETH',
|
||||
send_description: 'Tuma malipo'
|
||||
},
|
||||
sv: {
|
||||
browse_title: 'Webbläsare',
|
||||
browse_description: 'Starta webbläsaren'
|
||||
},
|
||||
'fr-ch': {
|
||||
browse_title: 'Navigateur',
|
||||
browse_description: 'Lancer le navigateur'
|
||||
},
|
||||
'de-ch': {
|
||||
browse_title: 'Browser',
|
||||
browse_description: 'Starte den Browser'
|
||||
},
|
||||
'it-ch': {
|
||||
browse_title: 'Browser',
|
||||
browse_description: 'Avvia il browser'
|
||||
},
|
||||
th: {
|
||||
browse_title: 'เบราว์เซอร์',
|
||||
browse_description: 'เปิดเบราว์เซอร์'
|
||||
},
|
||||
tr: {
|
||||
browse_title: 'Tarayıcı',
|
||||
browse_description: 'Tarayıcıyı başlat'
|
||||
},
|
||||
uk: {
|
||||
browse_title: 'Браузер',
|
||||
browse_description: 'Запустити браузер'
|
||||
},
|
||||
ur: {
|
||||
browse_title: 'براؤزر',
|
||||
browse_description: 'براؤزر کھولیں'
|
||||
},
|
||||
vi: {
|
||||
browse_title: 'Trình duyệt',
|
||||
browse_description: 'Mở trình duyệt'
|
||||
}
|
||||
};
|
|
@ -16,7 +16,6 @@
|
|||
(def intro-message1-id "intro-message1")
|
||||
|
||||
;; TODO(janherich): figure out something better then this
|
||||
(def browse-command-ref ["browse" :command 247 "browse"])
|
||||
(def send-command-ref ["transactor" :command 83 "send"])
|
||||
(def request-command-ref ["transactor" :command 83 "request"])
|
||||
(def phone-command-ref ["console" :command 50 "phone"])
|
||||
|
|
|
@ -91,8 +91,8 @@
|
|||
|
||||
(re-frame/reg-fx
|
||||
:browse
|
||||
(fn [[command link]]
|
||||
(list-selection/browse command link)))
|
||||
(fn [link]
|
||||
(list-selection/browse link)))
|
||||
|
||||
;;;; Handlers
|
||||
|
||||
|
@ -241,7 +241,7 @@
|
|||
(handlers/register-handler-fx
|
||||
:browse-link-from-message
|
||||
(fn [{{:contacts/keys [contacts]} :db} [_ link]]
|
||||
{:browse [(get-in contacts chat-const/browse-command-ref) link]}))
|
||||
{:browse link}))
|
||||
|
||||
(defn preload-chat-data
|
||||
"Takes coeffects map and chat-id, returns effects necessary when navigating to chat"
|
||||
|
@ -317,13 +317,3 @@
|
|||
[(re-frame/inject-cofx :get-stored-chat) re-frame/trim-v]
|
||||
(fn [cofx [chat]]
|
||||
(model/upsert-chat cofx chat)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:check-and-open-dapp!
|
||||
(fn [{{:keys [current-chat-id]
|
||||
:contacts/keys [contacts] :as db} :db} _]
|
||||
(when-let [dapp-url (get-in contacts [current-chat-id :dapp-url])]
|
||||
(-> db
|
||||
(input-events/select-chat-input-command
|
||||
(assoc (get-in contacts chat-const/browse-command-ref) :prefill [dapp-url]) nil true)
|
||||
(assoc :dispatch [:send-current-message])))))
|
||||
|
|
|
@ -28,11 +28,22 @@
|
|||
[action-button {:label (i18n/label :t/add-new-contact)
|
||||
:icon :icons/add
|
||||
:icon-opts {:color :blue}
|
||||
:on-press #(dispatch [:navigate-to :new-contact])}]])
|
||||
:on-press #(dispatch [:navigate-to :new-contact])}]
|
||||
[action-separator]
|
||||
[action-button {:label (i18n/label :t/open-url)
|
||||
:icon :icons/address
|
||||
:icon-opts {:color :blue}
|
||||
:on-press #(do
|
||||
(dispatch [:navigate-to-clean :home])
|
||||
(dispatch [:navigate-to :browser]))}]])
|
||||
|
||||
(defn contact-list-row [contact]
|
||||
(defn contact-list-row [{:keys [dapp-url] :as contact}]
|
||||
[contact-view {:contact contact
|
||||
:on-press #(dispatch [:open-chat-with-contact %])}])
|
||||
:on-press #(if dapp-url
|
||||
(do
|
||||
(dispatch [:navigate-to-clean :home])
|
||||
(dispatch [:open-dapp-in-browser contact]))
|
||||
(dispatch [:open-chat-with-contact %]))}])
|
||||
|
||||
(defview new-chat-toolbar []
|
||||
(letsubs [show-search [:get-in [:toolbar-search :show]]
|
||||
|
|
|
@ -111,8 +111,7 @@
|
|||
show-emoji? [:get-current-chat-ui-prop :show-emoji?]
|
||||
layout-height [:get :layout-height]
|
||||
current-view [:get :view-id]]
|
||||
{:component-did-mount #(re-frame/dispatch [:check-and-open-dapp!])
|
||||
:component-will-unmount #(re-frame/dispatch [:set-chat-ui-props {:show-emoji? false}])}
|
||||
{:component-will-unmount #(re-frame/dispatch [:set-chat-ui-props {:show-emoji? false}])}
|
||||
[react/view {:style style/chat-view
|
||||
:on-layout (fn [event]
|
||||
(let [height (.. event -nativeEvent -layout -height)]
|
||||
|
|
|
@ -6,44 +6,6 @@
|
|||
|
||||
(defmulti action-view (fn [{:keys [type]}] (keyword type)))
|
||||
|
||||
(defmethod action-view :fullscreen
|
||||
[_]
|
||||
(let [fullscreen? (re-frame/subscribe [:get-current-chat-ui-prop :fullscreen?])]
|
||||
(fn []
|
||||
[react/touchable-highlight
|
||||
{:on-press #(re-frame/dispatch [:set-chat-ui-props {:fullscreen? (not @fullscreen?)}])}
|
||||
(if @fullscreen?
|
||||
[react/view (style/action-view true)
|
||||
[react/icon :action_fullscreen_collapse style/action-view-icon]]
|
||||
[react/view (style/action-view true)
|
||||
[react/icon :action_fullscreen_expand style/action-view-fullscreen-expand-icon]])])))
|
||||
|
||||
(defmethod action-view :web-view-back
|
||||
[_]
|
||||
(let [result-box (re-frame/subscribe [:get-current-chat-ui-prop :result-box])
|
||||
webview (re-frame/subscribe [:get :webview-bridge])]
|
||||
(fn []
|
||||
[react/touchable-highlight
|
||||
{:on-press #(.goBack @webview)}
|
||||
[react/view (style/action-view true)
|
||||
[react/icon :action_back style/action-view-icon-tinted]]]
|
||||
#_(if (:can-go-back? @result-box)
|
||||
[react/view (style/action-view false)
|
||||
[react/icon :action_back style/action-view-icon]]))))
|
||||
|
||||
(defmethod action-view :web-view-forward
|
||||
[_]
|
||||
(let [result-box (re-frame/subscribe [:get-current-chat-ui-prop :result-box])
|
||||
webview (re-frame/subscribe [:get :webview-bridge])]
|
||||
(fn []
|
||||
[react/touchable-highlight
|
||||
{:on-press #(.goForward @webview)}
|
||||
[react/view (style/action-view true)
|
||||
[react/icon :action_forward style/action-view-icon-tinted]]]
|
||||
#_(if (:can-go-forward? @result-box)
|
||||
[react/view (style/action-view false)
|
||||
[react/icon :action_forward style/action-view-icon]]))))
|
||||
|
||||
(defmethod action-view :default
|
||||
[{:keys [image executeJs]}]
|
||||
[react/touchable-highlight
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
(ns status-im.chat.views.input.web-view
|
||||
(:require-macros [status-im.utils.views :refer [defview]])
|
||||
(:require [reagent.core :as r]
|
||||
[re-frame.core :refer [dispatch]]
|
||||
[status-im.ui.components.webview-bridge :refer [webview-bridge]]
|
||||
[status-im.ui.components.react :refer [view text] :as components]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.i18n :refer [label]]
|
||||
[status-im.utils.js-resources :as js-res]
|
||||
[clojure.string :as str]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(defn on-navigation-change
|
||||
[event {:keys [dynamicTitle actions] :as result-box}]
|
||||
(let [{:strs [loading url title canGoBack canGoForward]} (js->clj event)]
|
||||
(when-not (= "about:blank" url)
|
||||
(when-not loading
|
||||
(dispatch [:set-command-argument [0 url false]]))
|
||||
(let [result-box (assoc result-box :can-go-back? canGoBack :can-go-forward? canGoForward)
|
||||
result-box (if (and dynamicTitle (not (str/blank? title)))
|
||||
(assoc result-box :title title)
|
||||
result-box)]
|
||||
(dispatch [:set-chat-ui-props {:result-box result-box}])))))
|
||||
|
||||
(defn web-view-error []
|
||||
(r/as-element
|
||||
[view {:justify-content :center
|
||||
:align-items :center
|
||||
:flex-direction :row}
|
||||
[text (label :t/web-view-error)]]))
|
||||
|
||||
(defview bridged-web-view [{:keys [url]}]
|
||||
[extra-js [:web-view-extra-js]
|
||||
rpc-url [:get :rpc-url]
|
||||
result-box [:get-current-chat-ui-prop :result-box]]
|
||||
(when url
|
||||
[webview-bridge
|
||||
{:ref #(dispatch [:chat-webview-bridge/set-ref %])
|
||||
:on-bridge-message #(dispatch [:chat-webview-bridge/process-message %])
|
||||
:source {:uri url}
|
||||
:render-error web-view-error
|
||||
:java-script-enabled true
|
||||
:injected-on-start-loading-java-script (str js-res/web3
|
||||
js-res/jquery
|
||||
(js-res/web3-init rpc-url))
|
||||
:injected-java-script (str js-res/webview-js extra-js)
|
||||
:bounces false
|
||||
:on-navigation-state-change #(on-navigation-change % result-box)
|
||||
:local-storage-enabled true
|
||||
:start-in-loading-state true
|
||||
:render-loading #(r/as-element [view {:padding-top 16}
|
||||
[components/activity-indicator {:animating true}]])}]))
|
|
@ -3,7 +3,6 @@
|
|||
[clojure.walk :as w]
|
||||
[re-frame.core :refer [dispatch trim-v]]
|
||||
[status-im.ui.components.react :as components]
|
||||
[status-im.chat.views.input.web-view :as chat-web-view]
|
||||
[status-im.chat.views.input.validation-messages :as chat-validation-messages]
|
||||
[status-im.chat.views.api.choose-contact :as choose-contact]
|
||||
[status-im.ui.components.qr-code-viewer.views :as qr-code-viewer]
|
||||
|
@ -32,7 +31,6 @@
|
|||
:web-view components/web-view
|
||||
:touchable components/touchable-highlight
|
||||
:activity-indicator components/activity-indicator
|
||||
:bridged-web-view chat-web-view/bridged-web-view
|
||||
:validation-message chat-validation-messages/validation-message
|
||||
:choose-contact choose-contact/choose-contact-view
|
||||
:separator parameter-box-separator
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
(ns status-im.data-store.browser
|
||||
(:require [status-im.data-store.realm.browser :as data-store])
|
||||
(:refer-clojure :exclude [exists?]))
|
||||
|
||||
(defn get-all
|
||||
[]
|
||||
(data-store/get-all))
|
||||
|
||||
(defn get-by-id
|
||||
[id]
|
||||
(data-store/get-by-id id))
|
||||
|
||||
(defn exists?
|
||||
[browser-id]
|
||||
(data-store/exists? browser-id))
|
||||
|
||||
(defn save
|
||||
[{:keys [browser-id] :as browser}]
|
||||
(data-store/save browser (exists? browser-id)))
|
|
@ -0,0 +1,24 @@
|
|||
(ns status-im.data-store.realm.browser
|
||||
(:require [status-im.data-store.realm.core :as realm]
|
||||
[status-im.utils.random :refer [timestamp]])
|
||||
(:refer-clojure :exclude [exists?]))
|
||||
|
||||
(defn get-all
|
||||
[]
|
||||
(-> @realm/account-realm
|
||||
(realm/get-all :browser)
|
||||
(realm/sorted :timestamp :desc)
|
||||
(realm/js-object->clj)))
|
||||
|
||||
(defn save
|
||||
[browser update?]
|
||||
(realm/save @realm/account-realm :browser browser update?))
|
||||
|
||||
(defn exists?
|
||||
[browser-id]
|
||||
(realm/exists? @realm/account-realm :browser {:browser-id browser-id}))
|
||||
|
||||
(defn get-by-id
|
||||
[browser-id]
|
||||
(-> @realm/account-realm
|
||||
(realm/get-one-by-field-clj :browser :browser-id browser-id)))
|
|
@ -17,7 +17,9 @@
|
|||
[status-im.data-store.realm.schemas.account.v16.core :as v16]
|
||||
[status-im.data-store.realm.schemas.account.v17.core :as v17]
|
||||
[status-im.data-store.realm.schemas.account.v18.core :as v18]
|
||||
[status-im.data-store.realm.schemas.account.v19.core :as v19]))
|
||||
[status-im.data-store.realm.schemas.account.v19.core :as v19]
|
||||
[status-im.data-store.realm.schemas.account.v20.core :as v20]
|
||||
[status-im.data-store.realm.schemas.account.v21.core :as v21]))
|
||||
|
||||
|
||||
;; TODO(oskarth): Add failing test if directory vXX exists but isn't in schemas.
|
||||
|
@ -79,5 +81,11 @@
|
|||
:migration v18/migration}
|
||||
{:schema v19/schema
|
||||
:schemaVersion 19
|
||||
:migration v19/migration}])
|
||||
:migration v19/migration}
|
||||
{:schema v20/schema
|
||||
:schemaVersion 20
|
||||
:migration v20/migration}
|
||||
{:schema v21/schema
|
||||
:schemaVersion 21
|
||||
:migration v21/migration}])
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v21.browser)
|
||||
|
||||
(def schema {:name :browser
|
||||
:primaryKey :browser-id
|
||||
:properties {:browser-id :string
|
||||
:name :string
|
||||
:timestamp :int
|
||||
:dapp? {:type :bool
|
||||
:default false}
|
||||
:url {:type :string
|
||||
:optional true}
|
||||
:contact {:type :string
|
||||
:optional true}}})
|
|
@ -0,0 +1,42 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v21.core
|
||||
(:require [status-im.data-store.realm.schemas.account.v19.chat :as chat]
|
||||
[status-im.data-store.realm.schemas.account.v1.chat-contact :as chat-contact]
|
||||
[status-im.data-store.realm.schemas.account.v19.contact :as contact]
|
||||
[status-im.data-store.realm.schemas.account.v20.discover :as discover]
|
||||
[status-im.data-store.realm.schemas.account.v19.message :as message]
|
||||
[status-im.data-store.realm.schemas.account.v12.pending-message :as pending-message]
|
||||
[status-im.data-store.realm.schemas.account.v1.processed-message :as processed-message]
|
||||
[status-im.data-store.realm.schemas.account.v19.request :as request]
|
||||
[status-im.data-store.realm.schemas.account.v19.user-status :as user-status]
|
||||
[status-im.data-store.realm.schemas.account.v5.contact-group :as contact-group]
|
||||
[status-im.data-store.realm.schemas.account.v5.group-contact :as group-contact]
|
||||
[status-im.data-store.realm.schemas.account.v8.local-storage :as local-storage]
|
||||
[status-im.data-store.realm.schemas.account.v21.browser :as browser]
|
||||
[taoensso.timbre :as log]
|
||||
[cljs.reader :as reader]))
|
||||
|
||||
(def schema [chat/schema
|
||||
chat-contact/schema
|
||||
contact/schema
|
||||
discover/schema
|
||||
message/schema
|
||||
pending-message/schema
|
||||
processed-message/schema
|
||||
request/schema
|
||||
user-status/schema
|
||||
contact-group/schema
|
||||
group-contact/schema
|
||||
local-storage/schema
|
||||
browser/schema])
|
||||
|
||||
(defn remove-contact! [new-realm whisper-identity]
|
||||
(when-let [contact (some-> new-realm
|
||||
(.objects "contact")
|
||||
(.filtered (str "whisper-identity = \"" whisper-identity "\""))
|
||||
(aget 0))]
|
||||
(log/debug "v21 Removing contact " (pr-str contact))
|
||||
(.delete new-realm contact)))
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating v21 account database: " old-realm new-realm)
|
||||
(remove-contact! new-realm "browse"))
|
|
@ -13,6 +13,8 @@
|
|||
:next "Next"
|
||||
:open "Open"
|
||||
:description "Description"
|
||||
:enter-url "Enter URL"
|
||||
:open-url "Open URL"
|
||||
:url "URL"
|
||||
:type-a-message "Type a message..."
|
||||
:type-a-command "Start typing a command..."
|
||||
|
@ -114,6 +116,7 @@
|
|||
|
||||
:browsing-title "Browse"
|
||||
:browsing-open-in-web-browser "Open in web browser"
|
||||
:browsing-open-in-browser "Open in browser"
|
||||
:browsing-cancel "Cancel"
|
||||
|
||||
;;sign-up
|
||||
|
@ -392,4 +395,9 @@
|
|||
:connecting-requires-login "Connecting to another network requires login"
|
||||
:close-app-title "Warning!"
|
||||
:close-app-content "The app will stop and close. When you reopen it, the selected network will be used"
|
||||
:close-app-button "Confirm"})
|
||||
:close-app-button "Confirm"
|
||||
|
||||
;; browser
|
||||
:browser "Browser"
|
||||
:enter-dapp-url "Enter a ÐApp URL"
|
||||
:dapp "ÐApp"})
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
(:require-macros [status-im.utils.styles :refer [defstyle defnstyle]])
|
||||
(:require [status-im.utils.platform :as p]
|
||||
[status-im.ui.components.styles :refer [color-white
|
||||
color-light-blue-transparent
|
||||
color-light-blue
|
||||
color-light-gray
|
||||
color-black
|
||||
color-gray4]]))
|
||||
color-light-blue-transparent
|
||||
color-light-blue
|
||||
color-light-gray
|
||||
color-black
|
||||
color-gray4]]))
|
||||
|
||||
(defstyle action-button
|
||||
{:padding-left 16
|
||||
|
|
|
@ -131,6 +131,18 @@
|
|||
:default-chat-icon (styles/default-chat-icon-chat-list components.styles/default-chat-color)
|
||||
:default-chat-icon-text styles/default-chat-icon-text}])
|
||||
|
||||
(defn dapp-icon-browser [contact]
|
||||
[contact-icon-view contact
|
||||
{:container styles/container-chat-list
|
||||
:online-view-wrapper styles/online-view-wrapper
|
||||
:online-view styles/online-view
|
||||
:online-dot-left styles/online-dot-left
|
||||
:online-dot-right styles/online-dot-right
|
||||
:size 36
|
||||
:chat-icon styles/chat-icon-chat-list
|
||||
:default-chat-icon (styles/default-chat-icon-chat-list components.styles/default-chat-color)
|
||||
:default-chat-icon-text styles/default-chat-icon-text}])
|
||||
|
||||
(defn profile-icon-view [photo-path name color edit? size]
|
||||
(let [styles {:container {:width size :height size}
|
||||
:online-view styles/online-view-profile
|
||||
|
@ -151,8 +163,6 @@
|
|||
[chat-icon photo-path styles]
|
||||
[default-chat-icon name styles])]))
|
||||
|
||||
|
||||
|
||||
(defn my-profile-icon [{{:keys [photo-path name]} :account
|
||||
edit? :edit?}]
|
||||
(let [color components.styles/default-chat-color
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
(def white-transparent "rgba(255, 255, 255, 0.2)") ;; Used as icon color on dark background
|
||||
(def blue "#4360df") ;; Used as main wallet color
|
||||
(def black "#000000") ;; Used as the default text color
|
||||
(def gray "#939ba1") ;; Used as a background for a light foreground
|
||||
(def gray "#939ba1") ;; Used as a background for a light foreground and for text descriptions
|
||||
(def red "#ff2d55") ;; Used to highlight errors or "dangerous" actions
|
||||
(def light-gray "#eef2f5") ;; Used as a background or shadow
|
||||
(def text-light-gray "#212121") ;; Used for labels (home items)
|
|
@ -24,7 +24,8 @@
|
|||
(def use (get-class "Use"))
|
||||
(def defs (get-class "Defs"))
|
||||
|
||||
(def icons {:icons/home (slurp-svg "./resources/icons/bottom/home_gray.svg")
|
||||
(def icons {:icons/discover (slurp-svg "./resources/icons/bottom/discover_gray.svg")
|
||||
:icons/home (slurp-svg "./resources/icons/bottom/home_gray.svg")
|
||||
:icons/home-active (slurp-svg "./resources/icons/bottom/home_blue.svg")
|
||||
:icons/profile (slurp-svg "./resources/icons/bottom/profile_gray.svg")
|
||||
:icons/profile-active (slurp-svg "./resources/icons/bottom/profile_blue.svg")
|
||||
|
@ -72,7 +73,8 @@
|
|||
:icons/tooltip-triangle (slurp-svg "./resources/icons/tooltip-triangle.svg")
|
||||
:icons/open (slurp-svg "./resources/icons/open.svg")
|
||||
:icons/network (slurp-svg "./resources/icons/network.svg")
|
||||
:icons/wnode (slurp-svg "./resources/icons/wnode.svg")})
|
||||
:icons/wnode (slurp-svg "./resources/icons/wnode.svg")
|
||||
:icons/refresh (slurp-svg "./resources/icons/refresh.svg")})
|
||||
|
||||
(defn normalize-property-name [n]
|
||||
(if (= n :icons/options)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
(ns status-im.ui.components.list-selection
|
||||
(:require [re-frame.core :refer [dispatch]]
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.ui.components.react :refer [copy-to-clipboard
|
||||
sharing
|
||||
linking]]
|
||||
|
@ -28,19 +28,14 @@
|
|||
:default))
|
||||
:cancel-text (label :t/sharing-cancel)})))
|
||||
|
||||
(defn browse [browse-command link]
|
||||
(defn browse [link]
|
||||
(let [list-selection-fn (:list-selection-fn platform-specific)]
|
||||
(list-selection-fn {:title (label :t/browsing-title)
|
||||
:options [{:text "@browse"}
|
||||
:options [{:text (label :t/browsing-open-in-browser)}
|
||||
{:text (label :t/browsing-open-in-web-browser)}]
|
||||
:callback (fn [index]
|
||||
(case index
|
||||
0 (do
|
||||
(dispatch [:select-chat-input-command
|
||||
(assoc browse-command :prefill [link])
|
||||
nil
|
||||
true])
|
||||
(js/setTimeout #(dispatch [:send-current-message]) 100))
|
||||
0 (re-frame/dispatch [:open-browser {:url link}])
|
||||
1 (.openURL linking link)
|
||||
:default))
|
||||
:cancel-text (label :t/browsing-cancel)})))
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
(def color-light-gray3 "#e8ebec")
|
||||
(def color-light-gray4 "#eff2f3")
|
||||
(def color-light-gray5 "#D7D7D7")
|
||||
(def color-light-gray6 "#BAC1C6")
|
||||
(def color-red "red")
|
||||
(def color-red-2 "#d84b4b")
|
||||
(def color-red-3 "#FFC1BD")
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
(ns status-im.ui.screens.browser.db
|
||||
(:require-macros [status-im.utils.db :refer [allowed-keys]])
|
||||
(:require [cljs.spec.alpha :as spec]))
|
||||
|
||||
(spec/def :browser/browser-id (spec/nilable string?))
|
||||
(spec/def :browser/contact (spec/nilable string?))
|
||||
(spec/def :browser/timestamp (spec/nilable int?))
|
||||
(spec/def :browser/url (spec/nilable string?))
|
||||
(spec/def :browser/photo-path (spec/nilable string?))
|
||||
(spec/def :browser/name (spec/nilable string?))
|
||||
(spec/def :browser/dapp? (spec/nilable boolean?))
|
||||
(spec/def :browser/fullscreen? (spec/nilable boolean?))
|
||||
(spec/def :browser/can-go-back? (spec/nilable boolean?))
|
||||
(spec/def :browser/can-go-forward? (spec/nilable boolean?))
|
||||
|
||||
(spec/def :browser/options
|
||||
(allowed-keys
|
||||
:opt-un [:browser/browser-id
|
||||
:browser/can-go-back?
|
||||
:browser/can-go-forward?
|
||||
:browser/fullscreen?]))
|
||||
|
||||
(spec/def :browser/browser
|
||||
(allowed-keys
|
||||
:req-un [:browser/browser-id
|
||||
:browser/timestamp]
|
||||
:opt-un [:browser/name
|
||||
:browser/dapp?
|
||||
:browser/url
|
||||
:browser/contact]))
|
||||
|
||||
(spec/def :browser/browsers (spec/nilable (spec/map-of :global/not-empty-string :browser/browser)))
|
|
@ -0,0 +1,74 @@
|
|||
(ns status-im.ui.screens.browser.events
|
||||
(:require status-im.ui.screens.browser.navigation
|
||||
[status-im.utils.handlers :as handlers]
|
||||
[status-im.data-store.browser :as browser-store]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.utils.random :as random]
|
||||
[status-im.i18n :as i18n]))
|
||||
|
||||
(re-frame/reg-cofx
|
||||
:all-stored-browsers
|
||||
(fn [cofx _]
|
||||
(assoc cofx :all-stored-browsers (browser-store/get-all))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:initialize-browsers
|
||||
[(re-frame/inject-cofx :all-stored-browsers)]
|
||||
(fn [{:keys [db all-stored-browsers]} _]
|
||||
(let [{:accounts/keys [account-creation?]} db]
|
||||
(when-not account-creation?
|
||||
(let [browsers (into {} (map #(vector (:browser-id %) %) all-stored-browsers))]
|
||||
{:db (assoc db :browser/browsers browsers)})))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:save-browser
|
||||
(fn [browser]
|
||||
(browser-store/save browser)))
|
||||
|
||||
(defn get-new-browser [browser now]
|
||||
(cond-> browser
|
||||
true
|
||||
(assoc :timestamp now)
|
||||
(not (:browser-id browser))
|
||||
(assoc :browser-id (random/id))
|
||||
(not (:name browser))
|
||||
(assoc :name (i18n/label :t/browser))))
|
||||
|
||||
(defn add-browser-fx [{:keys [db now] :as cofx} browser]
|
||||
(let [new-browser (get-new-browser browser now)]
|
||||
{:db (update-in db [:browser/browsers (:browser-id new-browser)] merge new-browser)
|
||||
:save-browser new-browser}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:open-dapp-in-browser
|
||||
[re-frame/trim-v]
|
||||
(fn [cofx [{:keys [name dapp-url] :as contact}]]
|
||||
(let [browser {:browser-id (:whisper-identity contact)
|
||||
:name name
|
||||
:dapp? true
|
||||
:url dapp-url
|
||||
:contact (:whisper-identity contact)}]
|
||||
(merge (add-browser-fx cofx browser)
|
||||
{:dispatch [:navigate-to :browser (:browser-id browser)]}))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:open-browser
|
||||
[re-frame/trim-v]
|
||||
(fn [{:keys [now] :as cofx} [browser]]
|
||||
(let [new-browser (get-new-browser browser now)]
|
||||
(merge (add-browser-fx cofx new-browser)
|
||||
{:dispatch [:navigate-to :browser (:browser-id new-browser)]}))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:update-browser
|
||||
[re-frame/trim-v]
|
||||
(fn [{:keys [db now] :as cofx} [browser]]
|
||||
(let [new-browser (get-new-browser browser now)]
|
||||
(-> (add-browser-fx cofx new-browser)
|
||||
(update-in [:db :browser/options] #(assoc % :browser-id (:browser-id new-browser)))))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:update-browser-options
|
||||
[re-frame/trim-v]
|
||||
(fn [{:keys [db now] :as cofx} [options]]
|
||||
{:db (update db :browser/options merge options)}))
|
|
@ -0,0 +1,6 @@
|
|||
(ns status-im.ui.screens.browser.navigation
|
||||
(:require [status-im.ui.screens.navigation :as navigation]))
|
||||
|
||||
(defmethod navigation/preload-data! :browser
|
||||
[db [_ _ browser-id]]
|
||||
(assoc db :browser/options {:browser-id browser-id}))
|
|
@ -0,0 +1,70 @@
|
|||
(ns status-im.ui.screens.browser.styles
|
||||
(:require-macros [status-im.utils.styles :refer [defstyle defnstyle]])
|
||||
(:require [status-im.ui.components.colors :as colors]))
|
||||
|
||||
(def browser {:flex 1})
|
||||
|
||||
(defstyle dapp-name
|
||||
{:flex 1
|
||||
:justify-content :center
|
||||
:margin-left 12
|
||||
:android {:padding-bottom 6}})
|
||||
|
||||
(def dapp-name-text
|
||||
{:color colors/text-light-gray
|
||||
:font-size 16})
|
||||
|
||||
(defstyle dapp-text
|
||||
{:color colors/gray
|
||||
:ios {:font-size 14
|
||||
:margin-top 4}
|
||||
:android {:font-size 13}})
|
||||
|
||||
(def toolbar
|
||||
{:background-color :white
|
||||
:height 48
|
||||
:flex-direction :row
|
||||
:align-items :center
|
||||
:padding-horizontal 32})
|
||||
|
||||
(def forward-button
|
||||
{:margin-left 72})
|
||||
|
||||
(def background
|
||||
{:flex 1
|
||||
:background-color colors/light-gray
|
||||
:align-items :center
|
||||
:justify-content :center})
|
||||
|
||||
(def web-view-loading
|
||||
{:flex 1
|
||||
:align-items :center
|
||||
:justify-content :center})
|
||||
|
||||
(def web-view-error
|
||||
{:justify-content :center
|
||||
:align-items :center
|
||||
:flex-direction :row})
|
||||
|
||||
(defnstyle toolbar-content [show-actions]
|
||||
{:flex-direction :row
|
||||
:flex 1
|
||||
:border-radius 4
|
||||
:height 36
|
||||
:background-color colors/light-gray
|
||||
:padding-horizontal 12
|
||||
:android {:align-items :flex-start
|
||||
:margin-left (if show-actions 66 18)
|
||||
:padding-bottom 6}
|
||||
:ios {:align-items :center
|
||||
:margin-horizontal 12}})
|
||||
|
||||
(defstyle url-input
|
||||
{:flex 1
|
||||
:font-size 14
|
||||
:letter-spacing -0.2
|
||||
:android {:padding 0}})
|
||||
|
||||
(def toolbar-content-dapp
|
||||
{:flex-direction :row
|
||||
:margin-horizontal 10})
|
|
@ -0,0 +1,11 @@
|
|||
(ns status-im.ui.screens.browser.subs
|
||||
(:require [re-frame.core :as re-frame]))
|
||||
|
||||
(re-frame/reg-sub :browsers :browser/browsers)
|
||||
|
||||
(re-frame/reg-sub
|
||||
:get-current-browser
|
||||
:<- [:get :browser/options]
|
||||
:<- [:browsers]
|
||||
(fn [[options browsers]]
|
||||
(get browsers (:browser-id options))))
|
|
@ -0,0 +1,99 @@
|
|||
(ns status-im.ui.screens.browser.views
|
||||
(:require-macros [status-im.utils.views :as views])
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.ui.components.react :as react]
|
||||
[status-im.ui.screens.browser.styles :as styles]
|
||||
[status-im.ui.components.status-bar.view :as status-bar]
|
||||
[status-im.ui.components.toolbar.view :as toolbar.view]
|
||||
[status-im.chat.views.toolbar-content :as toolbar-content]
|
||||
[status-im.ui.components.webview-bridge :as components.webview-bridge]
|
||||
[status-im.utils.js-resources :as js-res]
|
||||
[status-im.ui.components.react :as components]
|
||||
[reagent.core :as reagent]
|
||||
[status-im.ui.components.chat-icon.screen :as chat-icon.screen]
|
||||
[status-im.ui.components.icons.vector-icons :as vector-icons]
|
||||
[status-im.i18n :as i18n]))
|
||||
|
||||
(views/defview toolbar-content-dapp [contact-identity]
|
||||
(views/letsubs [contact [:contact-by-identity contact-identity]]
|
||||
[react/view styles/toolbar-content-dapp
|
||||
[chat-icon.screen/dapp-icon-browser contact]
|
||||
[react/view styles/dapp-name
|
||||
[react/text {:style styles/dapp-name-text
|
||||
:number-of-lines 1
|
||||
:font :toolbar-title}
|
||||
(:name contact)]
|
||||
[react/text {:style styles/dapp-text}
|
||||
(i18n/label :t/dapp)]]]))
|
||||
|
||||
(defn match-url [url]
|
||||
(str (when (and url (not (re-find #"^[a-zA-Z-_]+:/" url))) "http://") url))
|
||||
|
||||
(defn toolbar-content [{:keys [url] :as browser}]
|
||||
(let [url-text (atom nil)]
|
||||
[react/view (styles/toolbar-content false)
|
||||
[react/text-input {:on-change-text #(reset! url-text %)
|
||||
:on-submit-editing #(re-frame/dispatch [:update-browser (assoc browser :url (match-url @url-text))])
|
||||
:auto-focus (not url)
|
||||
:placeholder (i18n/label :t/enter-url)
|
||||
:default-value url
|
||||
:style styles/url-input}]
|
||||
;;TODO .reload doesn't work, implement later
|
||||
#_[react/touchable-highlight {:on-press #(when @webview (.reload @webview))}
|
||||
[react/view
|
||||
[vector-icons/icon :icons/refresh]]]]))
|
||||
|
||||
(defn web-view-error []
|
||||
(reagent/as-element
|
||||
[react/view styles/web-view-error
|
||||
[react/text (i18n/label :t/web-view-error)]]))
|
||||
|
||||
(defn web-view-loading []
|
||||
(reagent/as-element
|
||||
[react/view styles/web-view-loading
|
||||
[components/activity-indicator {:animating true}]]))
|
||||
|
||||
(defn on-navigation-change [event browser]
|
||||
(let [{:strs [loading url title canGoBack canGoForward]} (js->clj event)]
|
||||
(when-not (= "about:blank" url)
|
||||
(re-frame/dispatch [:update-browser (assoc browser :url url :name title)]))
|
||||
(re-frame/dispatch [:update-browser-options {:can-go-back? canGoBack :can-go-forward? canGoForward}])))
|
||||
|
||||
(views/defview browser []
|
||||
(views/letsubs [webview (atom nil)
|
||||
{:keys [dapp? contact url] :as browser} [:get-current-browser]
|
||||
{:keys [can-go-back? can-go-forward?]} [:get :browser/options]
|
||||
extra-js [:web-view-extra-js]
|
||||
rpc-url [:get :rpc-url]]
|
||||
[react/keyboard-avoiding-view styles/browser
|
||||
[status-bar/status-bar]
|
||||
[toolbar.view/toolbar {}
|
||||
toolbar.view/default-nav-back
|
||||
(if dapp?
|
||||
[toolbar-content-dapp contact]
|
||||
[toolbar-content browser])]
|
||||
(if url
|
||||
[components.webview-bridge/webview-bridge
|
||||
{:ref #(reset! webview %)
|
||||
:source {:uri url}
|
||||
:java-script-enabled true
|
||||
:bounces false
|
||||
:local-storage-enabled true
|
||||
:start-in-loading-state true
|
||||
:render-error web-view-error
|
||||
:render-loading web-view-loading
|
||||
:on-navigation-state-change #(on-navigation-change % browser)
|
||||
:injected-on-start-loading-java-script (str js-res/web3
|
||||
js-res/jquery
|
||||
(js-res/web3-init rpc-url))
|
||||
:injected-java-script (str js-res/webview-js extra-js)}]
|
||||
[react/view styles/background
|
||||
[react/text (i18n/label :t/enter-dapp-url)]])
|
||||
[react/view styles/toolbar
|
||||
[react/touchable-highlight {:on-press #(.goBack @webview) :disabled (not can-go-back?)}
|
||||
[react/view (when (not can-go-back?) {:opacity 0.4})
|
||||
[vector-icons/icon :icons/arrow-left]]]
|
||||
[react/touchable-highlight {:on-press #(.goForward @webview) :disabled (not can-go-forward?)
|
||||
:style styles/forward-button}
|
||||
[react/view (when (not can-go-forward?) {:opacity 0.4})
|
||||
[vector-icons/icon :icons/arrow-right]]]]]))
|
|
@ -14,7 +14,8 @@
|
|||
status-im.ui.screens.profile.db
|
||||
status-im.ui.screens.discover.db
|
||||
status-im.ui.screens.network-settings.db
|
||||
status-im.ui.screens.offline-messaging-settings.db))
|
||||
status-im.ui.screens.offline-messaging-settings.db
|
||||
status-im.ui.screens.browser.db))
|
||||
|
||||
(def transaction-send-default
|
||||
{:symbol :ETH
|
||||
|
@ -131,7 +132,9 @@
|
|||
:node/after-stop
|
||||
:inbox/wnode
|
||||
:inbox/topic
|
||||
:inbox/password]
|
||||
:inbox/password
|
||||
:browser/browsers
|
||||
:browser/options]
|
||||
:opt-un
|
||||
[::current-public-key
|
||||
::modal
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
status-im.ui.screens.wallet.settings.events
|
||||
status-im.ui.screens.wallet.transactions.events
|
||||
status-im.ui.screens.wallet.choose-recipient.events
|
||||
status-im.ui.screens.browser.events
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.ui.components.react :as react]
|
||||
|
@ -279,6 +280,7 @@
|
|||
[:initialize-protocol address]
|
||||
[:initialize-sync-listener]
|
||||
[:initialize-chats]
|
||||
[:initialize-browsers]
|
||||
[:load-contacts]
|
||||
[:load-contact-groups]
|
||||
[:initialize-debugging {:address address}]
|
||||
|
@ -344,16 +346,16 @@
|
|||
(let [{:keys [event data]} (types/json->clj data)]
|
||||
(case event
|
||||
"local-storage" (re-frame/dispatch [:set-local-storage {:chat-id chat_id
|
||||
:data data}])
|
||||
:data data}])
|
||||
"show-suggestions" (re-frame/dispatch [:show-suggestions-from-jail {:chat-id chat_id
|
||||
:markup data}])
|
||||
:markup data}])
|
||||
"send-message" (re-frame/dispatch [:send-message-from-jail {:chat-id chat_id
|
||||
:message data}])
|
||||
:message data}])
|
||||
"handler-result" (let [orig-params (:origParams data)]
|
||||
;; TODO(janherich): figure out and fix chat_id from event
|
||||
(re-frame/dispatch [:command-handler! (:chat-id orig-params)
|
||||
(restore-command-ref-keyword orig-params)
|
||||
{:result {:returned (dissoc data :origParams)}}]))
|
||||
(restore-command-ref-keyword orig-params)
|
||||
{:result {:returned (dissoc data :origParams)}}]))
|
||||
(log/debug "Unknown jail signal " event))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
(ns status-im.ui.screens.home.styles
|
||||
(:require-macros [status-im.utils.styles :refer [defstyle defnstyle]])
|
||||
(:require [status-im.ui.components.styles :as component.styles]))
|
||||
(:require [status-im.ui.components.styles :as component.styles]
|
||||
[status-im.ui.components.colors :as colors]))
|
||||
|
||||
(defn toolbar []
|
||||
{:background-color component.styles/color-white})
|
||||
{:background-color colors/white})
|
||||
|
||||
(def chat-separator-item
|
||||
{:border-bottom-width 1
|
||||
|
@ -11,7 +12,7 @@
|
|||
|
||||
(defstyle chat-container
|
||||
{:flex-direction :row
|
||||
:background-color component.styles/color-white
|
||||
:background-color colors/white
|
||||
:android {:height 76}
|
||||
:ios {:height 74}
|
||||
:overflow "hidden"})
|
||||
|
@ -25,6 +26,14 @@
|
|||
:android {:height 76}
|
||||
:ios {:height 74}})
|
||||
|
||||
(def browser-icon-container
|
||||
{:width 40
|
||||
:height 40
|
||||
:border-radius 20
|
||||
:background-color colors/light-gray
|
||||
:align-items :center
|
||||
:justify-content :center})
|
||||
|
||||
(defstyle chat-info-container
|
||||
{:margin-bottom 13
|
||||
:justify-content :space-between
|
||||
|
@ -121,7 +130,7 @@
|
|||
(defstyle new-messages-text
|
||||
{:left 0
|
||||
:fontSize 12
|
||||
:color component.styles/color-blue
|
||||
:color colors/blue
|
||||
:text-align :center
|
||||
:android {:top 2}
|
||||
:ios {:top 3}})
|
||||
|
@ -130,9 +139,8 @@
|
|||
{:flex 1})
|
||||
|
||||
(defstyle list-container
|
||||
{:android {:background-color component.styles/color-light-gray}
|
||||
|
||||
:ios {:background-color component.styles/color-white}})
|
||||
{:android {:background-color colors/light-gray}
|
||||
:ios {:background-color colors/white}})
|
||||
|
||||
(def toolbar-actions
|
||||
{:flex-direction :row
|
||||
|
@ -148,7 +156,7 @@
|
|||
(def create-icon
|
||||
{:fontSize 20
|
||||
:height 22
|
||||
:color component.styles/color-white})
|
||||
:color colors/white})
|
||||
|
||||
(def group-icon
|
||||
{:margin-top 8
|
||||
|
|
|
@ -1,20 +1,8 @@
|
|||
(ns status-im.ui.screens.home.subs
|
||||
(:require [re-frame.core :refer [reg-sub subscribe]]
|
||||
[clojure.string :as str]))
|
||||
(:require [re-frame.core :as re-frame]))
|
||||
|
||||
(defn search-filter [text item]
|
||||
(let [name (-> (or (:name item) "")
|
||||
(str/lower-case))
|
||||
text (str/lower-case text)]
|
||||
(not= (str/index-of name text) nil)))
|
||||
|
||||
(reg-sub :filtered-chats
|
||||
(re-frame/reg-sub :home-items
|
||||
:<- [:chats]
|
||||
:<- [:get-in [:toolbar-search :text]]
|
||||
:<- [:get-in [:toolbar-search :show]]
|
||||
(fn [[chats search-text show-search]]
|
||||
(let [unordered-chats (if (and (= show-search :home) search-text)
|
||||
(filter #(search-filter search-text (second %))
|
||||
chats)
|
||||
chats)]
|
||||
(sort-by #(-> % second :timestamp) > unordered-chats))))
|
||||
:<- [:browsers]
|
||||
(fn [[chats browsers]]
|
||||
(sort-by #(-> % second :timestamp) > (merge chats browsers))))
|
||||
|
|
|
@ -31,28 +31,28 @@
|
|||
:accessibility-label :plus-button
|
||||
:on-press #(re-frame/dispatch [:navigate-to :new-chat])}])
|
||||
|
||||
(defn chat-list-item [[chat-id chat] edit?]
|
||||
[react/touchable-highlight {:on-press #(re-frame/dispatch [:navigate-to-chat chat-id])}
|
||||
[react/view
|
||||
[inner-item/chat-list-item-inner-view (assoc chat :chat-id chat-id) edit?]]])
|
||||
(defn home-list-item [[home-item-id home-item]]
|
||||
(if (:chat-id home-item)
|
||||
[react/touchable-highlight {:on-press #(re-frame/dispatch [:navigate-to-chat home-item-id])}
|
||||
[react/view
|
||||
[inner-item/home-list-chat-item-inner-view home-item]]]
|
||||
[react/touchable-highlight {:on-press #(re-frame/dispatch [:open-browser home-item])}
|
||||
[react/view
|
||||
[inner-item/home-list-browser-item-inner-view home-item]]]))
|
||||
|
||||
(views/defview home []
|
||||
(views/letsubs [chats [:filtered-chats]
|
||||
edit? [:get-in [:chat-list-ui-props :edit?]]
|
||||
show-search [:get-in [:toolbar-search :show]]
|
||||
tabs-hidden? [:tabs-hidden?]]
|
||||
(views/letsubs [home-items [:home-items]]
|
||||
[react/view styles/chats-container
|
||||
[toolbar-view]
|
||||
[list/flat-list {:style styles/list-container
|
||||
:data chats
|
||||
:render-fn (fn [[chat-id :as chat]]
|
||||
^{:key chat-id} [chat-list-item chat edit?])
|
||||
:header (when-not (empty? chats) list/default-header)
|
||||
:footer (when-not (empty? chats)
|
||||
:data home-items
|
||||
:render-fn (fn [[home-item-id :as home-item]]
|
||||
^{:key home-item-id} [home-list-item home-item])
|
||||
:header (when-not (empty? home-items) list/default-header)
|
||||
:footer (when-not (empty? home-items)
|
||||
[react/view
|
||||
[components.common/list-footer]
|
||||
[components.common/bottom-shadow]])}]
|
||||
|
||||
(when platform/android?
|
||||
[home-action-button])
|
||||
[offline-view]]))
|
|
@ -4,17 +4,18 @@
|
|||
[reagent.core :as reagent]
|
||||
[clojure.string :as str]
|
||||
[status-im.ui.components.react :as react]
|
||||
[status-im.ui.components.icons.vector-icons :as vi]
|
||||
[status-im.ui.components.chat-icon.screen :as chat-icon-screen]
|
||||
[status-im.ui.components.icons.vector-icons :as vector-icons]
|
||||
[status-im.ui.components.context-menu :as context-menu]
|
||||
[status-im.ui.screens.home.styles :as st]
|
||||
[status-im.ui.screens.home.styles :as styles]
|
||||
[status-im.ui.components.styles :as component.styles]
|
||||
[status-im.utils.utils :as utils]
|
||||
[status-im.commands.utils :as commands-utils]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.utils.datetime :as time]
|
||||
[status-im.utils.gfycat.core :as gfycat]
|
||||
[status-im.constants :as const]
|
||||
[taoensso.timbre :as log]))
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.ui.components.chat-icon.screen :as chat-icon.screen]))
|
||||
|
||||
(defn message-content-text [{:keys [content] :as message}]
|
||||
(reagent/create-class
|
||||
|
@ -28,19 +29,19 @@
|
|||
:cache-data? true}]))
|
||||
:reagent-render
|
||||
(fn [{:keys [content] :as message}]
|
||||
[react/view st/last-message-container
|
||||
[react/view styles/last-message-container
|
||||
(cond
|
||||
|
||||
(not message)
|
||||
[react/text {:style st/last-message-text}
|
||||
[react/text {:style styles/last-message-text}
|
||||
(i18n/label :t/no-messages)]
|
||||
|
||||
(str/blank? content)
|
||||
[react/text {:style st/last-message-text}
|
||||
[react/text {:style styles/last-message-text}
|
||||
""]
|
||||
|
||||
(:content content)
|
||||
[react/text {:style st/last-message-text
|
||||
[react/text {:style styles/last-message-text
|
||||
:number-of-lines 1}
|
||||
(:content content)]
|
||||
|
||||
|
@ -49,7 +50,7 @@
|
|||
(commands-utils/generate-hiccup (-> content :short-preview :markup))
|
||||
|
||||
:else
|
||||
[react/text {:style st/last-message-text
|
||||
[react/text {:style styles/last-message-text
|
||||
:number-of-lines 1}
|
||||
content])])}))
|
||||
|
||||
|
@ -62,71 +63,78 @@
|
|||
delivery-statuses)))]
|
||||
(when (and outgoing (or (= chat-id const/console-chat-id)
|
||||
seen-by-everyone))
|
||||
[vi/icon :icons/ok {:style st/status-image}]))))
|
||||
[vector-icons/icon :icons/ok {:style styles/status-image}]))))
|
||||
|
||||
(defn message-timestamp [{:keys [timestamp]}]
|
||||
(when timestamp
|
||||
[react/text {:style st/datetime-text}
|
||||
[react/text {:style styles/datetime-text}
|
||||
(time/to-short-str timestamp)]))
|
||||
|
||||
(defview unviewed-indicator [chat-id]
|
||||
(letsubs [unviewed-messages-count [:unviewed-messages-count chat-id]]
|
||||
(when (pos? unviewed-messages-count)
|
||||
[react/view st/new-messages-container
|
||||
[react/text {:style st/new-messages-text
|
||||
[react/view styles/new-messages-container
|
||||
[react/text {:style styles/new-messages-text
|
||||
:font :medium}
|
||||
unviewed-messages-count]])))
|
||||
|
||||
(defn options-btn [chat-id]
|
||||
(let [options [{:value #(re-frame/dispatch [:remove-chat chat-id])
|
||||
:text (i18n/label :t/delete-chat)
|
||||
:destructive? true}]]
|
||||
[react/view st/opts-btn-container
|
||||
[context-menu/context-menu
|
||||
[vi/icon :icons/options]
|
||||
options
|
||||
nil
|
||||
st/opts-btn]]))
|
||||
|
||||
(defn chat-list-item-name [name group-chat? public? public-key]
|
||||
(let [private-group? (and group-chat? (not public?))
|
||||
public-group? (and group-chat? public?)
|
||||
chat-name (if (str/blank? name)
|
||||
(gfycat/generate-gfy public-key)
|
||||
(utils/truncate-str name 30))]
|
||||
[react/view st/name-view
|
||||
[react/view styles/name-view
|
||||
(when public-group?
|
||||
[react/view st/public-group-icon-container
|
||||
[vi/icon :icons/public-chat {:style st/public-group-icon}]])
|
||||
[react/view styles/public-group-icon-container
|
||||
[vector-icons/icon :icons/public-chat {:style styles/public-group-icon}]])
|
||||
(when private-group?
|
||||
[react/view st/private-group-icon-container
|
||||
[vi/icon :icons/group-chat {:style st/private-group-icon}]])
|
||||
[react/view styles/private-group-icon-container
|
||||
[vector-icons/icon :icons/group-chat {:style styles/private-group-icon}]])
|
||||
[react/view {:flex-shrink 1}
|
||||
[react/text {:style st/name-text
|
||||
[react/text {:style styles/name-text
|
||||
:number-of-lines 1}
|
||||
(if public-group?
|
||||
(str "#" chat-name)
|
||||
chat-name)]]]))
|
||||
|
||||
(defview chat-list-item-inner-view [{:keys [chat-id name color online
|
||||
group-chat contacts public?
|
||||
public-key unremovable?] :as chat}
|
||||
edit?]
|
||||
(defview home-list-chat-item-inner-view [{:keys [chat-id name color online
|
||||
group-chat contacts public?
|
||||
public-key unremovable? :as chat]}]
|
||||
(letsubs [last-message [:get-last-message chat-id]]
|
||||
(let [name (or (i18n/get-contact-translated chat-id :name name)
|
||||
(gfycat/generate-gfy public-key))]
|
||||
[react/view st/chat-container
|
||||
[react/view st/chat-icon-container
|
||||
[chat-icon-screen/chat-icon-view-chat-list chat-id group-chat name color online]]
|
||||
[react/view st/chat-info-container
|
||||
[react/view st/item-upper-container
|
||||
[react/view styles/chat-container
|
||||
[react/view styles/chat-icon-container
|
||||
[chat-icon.screen/chat-icon-view-chat-list chat-id group-chat name color online]]
|
||||
[react/view styles/chat-info-container
|
||||
[react/view styles/item-upper-container
|
||||
[chat-list-item-name name group-chat public? public-key]
|
||||
(when (and (not edit?) last-message)
|
||||
[react/view st/message-status-container
|
||||
(when last-message
|
||||
[react/view styles/message-status-container
|
||||
[message-status chat last-message]
|
||||
[message-timestamp last-message]])]
|
||||
[react/view st/item-lower-container
|
||||
[react/view styles/item-lower-container
|
||||
[message-content-text last-message]
|
||||
(when-not edit? [unviewed-indicator chat-id])]]
|
||||
[react/view st/chat-options-container
|
||||
(when (and edit? (not unremovable?)) [options-btn chat-id])]])))
|
||||
[unviewed-indicator chat-id]]]])))
|
||||
|
||||
(defview home-list-browser-item-inner-view [{:keys [browser-id name url dapp? contact] :as browser}]
|
||||
(letsubs [contact' [:contact-by-identity contact]]
|
||||
[react/view styles/chat-container
|
||||
[react/view styles/chat-icon-container
|
||||
(if contact'
|
||||
[chat-icon.screen/dapp-icon-browser contact']
|
||||
[react/view styles/browser-icon-container
|
||||
[vector-icons/icon :icons/discover {:color component.styles/color-light-gray6}]])]
|
||||
[react/view styles/chat-info-container
|
||||
[react/view styles/item-upper-container
|
||||
[react/view styles/name-view
|
||||
[react/view {:flex-shrink 1}
|
||||
[react/text {:style styles/name-text
|
||||
:number-of-lines 1}
|
||||
name]]]]
|
||||
[react/view styles/item-lower-container
|
||||
[react/view styles/last-message-container
|
||||
[react/text {:style styles/last-message-text
|
||||
:number-of-lines 1}
|
||||
(or url (i18n/label :t/dapp))]]]]]))
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
status-im.ui.screens.wallet.settings.subs
|
||||
status-im.ui.screens.wallet.transactions.subs
|
||||
status-im.ui.screens.network-settings.subs
|
||||
status-im.ui.screens.browser.subs
|
||||
status-im.bots.subs))
|
||||
|
||||
(reg-sub :get
|
||||
|
|
|
@ -51,7 +51,8 @@
|
|||
[status-im.ui.screens.offline-messaging-settings.views :refer [offline-messaging-settings]]
|
||||
[status-im.ui.screens.network-settings.add-rpc.views :refer [add-rpc-url]]
|
||||
[status-im.ui.screens.network-settings.network-details.views :refer [network-details]]
|
||||
[status-im.ui.screens.network-settings.parse-json.views :refer [paste-json-text]]))
|
||||
[status-im.ui.screens.network-settings.parse-json.views :refer [paste-json-text]]
|
||||
[status-im.ui.screens.browser.views :refer [browser]]))
|
||||
|
||||
(defn validate-current-view
|
||||
[current-view signed-up?]
|
||||
|
@ -130,6 +131,7 @@
|
|||
(let [current-view (validate-current-view view-id signed-up?)]
|
||||
(let [component (case current-view
|
||||
(:home :wallet :my-profile) main-tabs
|
||||
:browser browser
|
||||
:wallet-send-transaction send-transaction
|
||||
:wallet-transaction-sent transaction-sent
|
||||
:choose-recipient choose-recipient
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
|
||||
(def console-js (slurp-bot :console "web3_metadata.js"))
|
||||
|
||||
(def browse-js (slurp-bot :browse))
|
||||
|
||||
(def mailman-js (slurp-bot :mailman))
|
||||
|
||||
(def demo-bot-js (slurp-bot :demo_bot))
|
||||
|
@ -24,7 +22,6 @@
|
|||
(def resources
|
||||
{:transactor-bot transactor-js
|
||||
:console-bot console-js
|
||||
:browse-bot browse-js
|
||||
:mailman-bot mailman-js
|
||||
:demo-bot demo-bot-js})
|
||||
|
||||
|
|
|
@ -11,39 +11,6 @@
|
|||
[status-im.utils.js-resources :as js-res]
|
||||
[status-im.utils.datetime :as datetime]))
|
||||
|
||||
(def browse-contact-from-realm-db
|
||||
{:last-updated 0
|
||||
:address nil
|
||||
:name "Browse"
|
||||
|
||||
:command { 247 { "browse" {:description "Launch the browser"
|
||||
:bot "browse"
|
||||
:color "#ffa500"
|
||||
:name "global"
|
||||
:params
|
||||
{:0 {:name "url"
|
||||
:type "text"
|
||||
:placeholder "URL"}}
|
||||
:icon nil
|
||||
:title "Browser"
|
||||
:has-handler false
|
||||
:fullscreen true
|
||||
:suggestions-trigger "on-change"}}}
|
||||
:dapp-url nil
|
||||
:dapp-hash nil
|
||||
:photo-path nil
|
||||
:description "browser contact"
|
||||
:debug? false
|
||||
:status nil
|
||||
:bot-url "local://browse-bot"
|
||||
:pending? false
|
||||
:whisper-identity "browse"
|
||||
:last-online 0
|
||||
:dapp? true
|
||||
:unremovable? true
|
||||
:private-key nil
|
||||
:public-key nil})
|
||||
|
||||
(def test-contact-group
|
||||
{:group-id "1501682106404-685e041e-38e7-593e-b42c-fb4cabd7faa4"
|
||||
:name "Test"
|
||||
|
@ -84,21 +51,6 @@
|
|||
:unremovable? false
|
||||
:public-key nil})
|
||||
|
||||
(def browse-default-contact
|
||||
{:address nil
|
||||
:name "Browse"
|
||||
:description nil
|
||||
:hide-contact? true
|
||||
:dapp-hash nil
|
||||
:photo-path nil
|
||||
:dapp-url nil
|
||||
:bot-url "local://browse-bot"
|
||||
:whisper-identity "browse"
|
||||
:pending? false
|
||||
:dapp? true
|
||||
:unremovable? true
|
||||
:public-key nil})
|
||||
|
||||
(def console-contact
|
||||
{:whisper-identity "console"
|
||||
:name "Console"
|
||||
|
@ -129,7 +81,7 @@
|
|||
(rf/reg-cofx
|
||||
::contacts-events/get-all-contacts
|
||||
(fn [coeffects _]
|
||||
(assoc coeffects :all-contacts [browse-contact-from-realm-db])))
|
||||
(assoc coeffects :all-contacts [])))
|
||||
|
||||
(rf/reg-cofx
|
||||
:get-local-storage-data
|
||||
|
@ -146,7 +98,7 @@
|
|||
::contacts-events/get-default-contacts-and-groups
|
||||
(fn [coeffects _]
|
||||
(assoc coeffects
|
||||
:default-contacts (select-keys js-res/default-contacts [:browse :demo-bot])
|
||||
:default-contacts (select-keys js-res/default-contacts [:demo-bot])
|
||||
:default-groups (select-keys js-res/default-contact-groups [:dapps])))))
|
||||
|
||||
(deftest contacts-events
|
||||
|
@ -249,9 +201,7 @@
|
|||
;;Assert the initial state
|
||||
(is (and (map? @contacts) (empty? @contacts)))
|
||||
|
||||
(rf/dispatch [:load-contacts])
|
||||
|
||||
(is (= {"browse" browse-contact-from-realm-db} @contacts)))
|
||||
(rf/dispatch [:load-contacts]))
|
||||
|
||||
(testing ":load-contact-groups event"
|
||||
|
||||
|
@ -283,14 +233,11 @@
|
|||
(testing "it adds a default contact"
|
||||
(is (= demo-bot-contact (get @contacts "demo-bot"))))
|
||||
|
||||
(testing "it replaces existing contacts"
|
||||
(is (= browse-default-contact (get @contacts "browse"))))
|
||||
|
||||
(testing "it adds the console bot"
|
||||
(is (= console-contact (get @contacts "console"))))
|
||||
|
||||
(testing "it does not add any other contact"
|
||||
(is (= 3 (count (keys @contacts))))))
|
||||
(is (= 2 (count (keys @contacts))))))
|
||||
|
||||
(let [new-contact-public-key "0x048f7d5d4bda298447bbb5b021a34832509bd1a8dbe4e06f9b7223d00a59b6dc14f6e142b21d3220ceb3155a6d8f40ec115cd96394d3cc7c55055b433a1758dc74"
|
||||
new-contact-address "5392ccb49f2e9fef8b8068b3e3b5ba6c020a9aca"
|
||||
|
|
Loading…
Reference in New Issue