haneke / hanekeswift Goto Github PK
View Code? Open in Web Editor NEWA lightweight generic cache for iOS written in Swift with extra love for images.
License: Apache License 2.0
A lightweight generic cache for iOS written in Swift with extra love for images.
License: Apache License 2.0
Support scaling modes by specifying them in formats. In particular: Fill, Aspect fill, Aspect fit, and No scaling.
Additionally, allow formats to define if images can be upscaled or not.
Formats acts as cache buckets, a secondary key for setting/fetching/removing objects from the cache.
For the scope of this issue, formats must have a name which should be also the name of the directory where its images are stored.
In the original Haneke, only Cache
knows about formats. Each format has its DiskCache
, so DiskCache
doesn't know about them.
Allow to specify the desired compression quality at format level.
Allow formats to have a "parent" format. If an image is not available in the cache, Haneke should attempt to create it from the parent format (if any). This should work recursively.
For example, this is useful when you have a "fullsize" format and a "thumbnail" format. "fullsize" would be the "thumbnail" parent.
This feature is not currently available in the original Haneke.
Allow to associate a format with a UIImageView. Return a format that describes the UIImageView if none is given.
Allow formats to define pre-resize and post-resize transformations (e.g., rounded corners) for the images.
Singleton cache to be used in UIKit extensions.
Entities should be objects that know how to fetch an image asynchronously. These can be given to the Cache instead of a key when fetching.
What one should we follow?
Fetches an image from disk.
Fetches an image from the network.
Should we prefix extension functions? E.g., hnk_hasAlpha
in the UIImage extension.
On one hand Swift is not dynamic so collisions would generate compiler errors.
On the other hand, I have no idea what would happen if compiled code runs in a future iOS version in which one of our extension methods is added.
Each format must have its own disk capacity.
Use arbitrary capacity for now.
Apply format when fetching an original image from its entity.
I'll do it as soon we merge all current PRs.
Also, add image to memory cache after reading it from disk.
Support image resizing by specifying the desired image size in the format.
Images must be resized in background prior to being cached.
Format currently has logic that is specific to images. This will have to go elsewhere. Maybe into something like ImageTransformer : Transformer
, of which Format has an instance.
The name Entity
does not convey the responsibilities declared by the protocol. It's too vague. Should we rename it?
Ideas:
Fetcher
: an entity basically fetches and object to be cachedCacheable
CacheObject
(should be CacheImage
, but I'm thinking of Cache being generic)LazyObject
We can't associate a format with a UIImageView because formats are structs.
As a workaround, the various setImage* methods can take a format argument.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.