Skip to content

(OLD)Add better support for stateful view (UIButton) for image URL/progress state management#2790

Closed
dreampiggy wants to merge 12 commits intoSDWebImage:masterfrom
dreampiggy:feature_set_image_state_api
Closed

(OLD)Add better support for stateful view (UIButton) for image URL/progress state management#2790
dreampiggy wants to merge 12 commits intoSDWebImage:masterfrom
dreampiggy:feature_set_image_state_api

Conversation

@dreampiggy
Copy link
Copy Markdown
Contributor

New Pull Request Checklist

  • I have read and understood the CONTRIBUTING guide

  • I have read the Documentation

  • I have searched for a similar pull request in the project and found none

  • I have updated this branch with the latest master to avoid conflicts (via merge from master or rebase)

  • I have added the required tests to prove the fix/feature I am adding

  • I have updated the documentation (if necessary)

  • I have run the tests and they pass

  • I have run the lint and it passes (pod lib lint)

This merge request fixes / refers to the following issues: #2701

Pull Request Description

This is the implemntation based on #2701 draft. To solve our current implementation for stateful View Category method.

Reason

Stateful view means the UIView/NSView subclass, which has multiple image instance to set, such as UIButton setImage:forState: or UIImageView.image/UIImage.highlightedImage.

See #2701. Our image request loading model, use a Operation Key, for stateful view to load the image. It's OK because for different state, it use a different operation key, no conflict.

However, currtent these API in UIView+WebCache, it's not good:

  • sd_imageURL
  • sd_imageProgress
  • sd_imageTransition

What if I use UIButton with sd_imageProgress to observe the progress changes ? Should it report the current state's progress, or normal progress ? or even background image's progress ? This is the root case of massive.

Solution

To solve this problem, we follow the same design model as Operation Key on image request. Now, each Operation Key will bind all the state associated to this request. I introduce a SDWebImageStateContainer class.

Each opeartion key bind a state container, and state container can be extended to include all the things we want represent the state.

  • URL
  • Progress
  • Transition
  • User-defined, such as timestamp. User may access this user-defined value in SDSetImageBlock and process your own logic. (like that SDWebImageContext, but for top-level view category, not the network or cache system)

@dreampiggy dreampiggy requested a review from kinarobin July 12, 2019 09:19
@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 12, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@6cfe44e). Click here to learn what that means.
The diff coverage is 46.85%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #2790   +/-   ##
=========================================
  Coverage          ?   82.18%           
=========================================
  Files             ?       58           
  Lines             ?     6428           
  Branches          ?        0           
=========================================
  Hits              ?     5283           
  Misses            ?     1145           
  Partials          ?        0
Flag Coverage Δ
#ios 83.5% <53.63%> (?)
#macos 82.03% <63.43%> (?)
Impacted Files Coverage Δ
SDWebImage/SDWebImageDefine.m 86.95% <ø> (ø)
SDWebImage/UIImageView+WebCache.m 34.69% <0%> (ø)
SDWebImage/NSButton+WebCache.m 34.23% <0%> (ø)
SDWebImage/UIImageView+HighlightedWebCache.m 42.59% <0%> (ø)
SDWebImage/SDWebImageIndicator.m 74.21% <0%> (ø)
SDWebImage/SDImageCache.m 81.71% <100%> (ø)
SDWebImage/SDImageAPNGCoder.m 88.13% <100%> (ø)
SDWebImage/SDAnimatedImageRep.m 87.03% <100%> (ø)
SDWebImage/SDImageGIFCoder.m 89.43% <100%> (ø)
SDWebImage/SDMemoryCache.m 95.29% <100%> (ø)
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6cfe44e...948734c. Read the comment docs.

@stale
Copy link
Copy Markdown

stale Bot commented Sep 15, 2019

This pull request has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs.
If this is still applicable, please make sure it is up to date and if so,
add a comment that this is still an issue to keep it open.
Thank you for your contributions.

@stale stale Bot added the stale label Sep 15, 2019
@stale stale Bot closed this Sep 22, 2019
@dreampiggy dreampiggy reopened this Sep 22, 2019
@stale stale Bot removed the stale label Sep 22, 2019
@stale
Copy link
Copy Markdown

stale Bot commented Nov 21, 2019

This pull request has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs.
If this is still applicable, please make sure it is up to date and if so,
add a comment that this is still an issue to keep it open.
Thank you for your contributions.

@stale stale Bot added the stale label Nov 21, 2019
@dreampiggy
Copy link
Copy Markdown
Contributor Author

dreampiggy commented May 9, 2020

This sounds trivial for most users. (Who use UIButton). But the new added API will introduce more problems.

The changes need more polish. I'll close it for now. Maybe we can do a totally refactory on v6.0.0

@dreampiggy dreampiggy closed this May 9, 2020
@dreampiggy dreampiggy added this to the 5.18.0 milestone Jul 27, 2023
@dreampiggy dreampiggy changed the title Add better support for stateful view (UIButton) for current image URL/progress/transition property Add better support for stateful view (UIButton) for image URL/progress state management Jul 30, 2023
@dreampiggy dreampiggy changed the title Add better support for stateful view (UIButton) for image URL/progress state management (OLD)Add better support for stateful view (UIButton) for image URL/progress state management Jul 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant