-
Notifications
You must be signed in to change notification settings - Fork 983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add loading and error indicators to sticker images #12999
Closed
Closed
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
f9b1315
add final newline to stickers styles
msuess 89f040e
add loading indicators to sticker images in market
msuess 92947d7
increase top margin of sticker pack view
msuess 2378f08
center sticker images in pack view
msuess 80913c4
justify sticker images with space-between
msuess 08b17a1
display loading indicator for pack badges and banners
msuess e782e4f
extract image-with-loader into component
msuess a6dbc14
display loader for sticker in chat message
msuess ba8a471
add error indicator to image-with-loader
msuess a9cfbc7
use fragment as image-with-loader container
msuess 868c6d0
use image-with-loader in sticker picker
msuess bea0ae5
center sticker view
msuess e201ca9
left-align stickers view
msuess 050912d
add accessibility labels to image-with-loader
msuess 4c17b7c
fetch stickers from multiple ipfs gateways
msuess 840471c
fix linter errors
msuess 21da153
add resize-mode to image-with-loader
msuess 262faf8
use a vector for component
msuess File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
(ns status-im.ui.components.image-with-loader | ||
(:require [reagent.core :as reagent] | ||
[quo.design-system.colors :as colors] | ||
[status-im.ui.components.react :as react] | ||
[status-im.ui.components.icons.icons :as icons] | ||
[status-im.utils.contenthash :as contenthash] | ||
[taoensso.timbre :as log])) | ||
|
||
(defn- placeholder [props child] | ||
(let [{:keys [accessibility-label style]} props] | ||
[react/view {:accessibility-label accessibility-label | ||
:style (merge style | ||
{:align-items :center | ||
:justify-content :center | ||
:background-color colors/gray-lighter})} | ||
child])) | ||
|
||
(defn source [props] | ||
(let [{:keys [source style accessibility-labels]} props | ||
loaded? (reagent/atom false) | ||
error? (reagent/atom false) | ||
current-source (reagent/atom (if (seq? source) | ||
source | ||
[source]))] | ||
(fn [] | ||
[react/view | ||
(when @error? | ||
[placeholder {:accessibility-label (:error accessibility-labels) | ||
:style style} | ||
[icons/icon :main-icons/cancel]]) | ||
(when-not (or @loaded? @error?) | ||
[placeholder {:accessibility-label (:loading accessibility-labels) | ||
:style style} | ||
[react/activity-indicator {:animating true}]]) | ||
(when (not @error?) | ||
(log/info "loaded" @loaded?) | ||
(log/info "style" style) | ||
[react/fast-image {:accessibility-label (:success accessibility-labels) | ||
:onError #(if (empty? (rest @current-source)) | ||
(reset! error? true) | ||
(reset! current-source | ||
(rest @current-source))) | ||
:onLoad #(reset! loaded? true) | ||
:style (if @loaded? style {}) | ||
:source (first @current-source) | ||
:resize-mode :contain}])]))) | ||
|
||
(defn ipfs [props] | ||
(let [{:keys [hash]} props] | ||
[source (merge (dissoc props :hash) | ||
{:source (map (fn [u] {:uri u}) | ||
(contenthash/alternatives hash))})])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if all sources failed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An error icon will be displayed if all sources fail