Task 21: avatar widget and image cache #21

Closed
opened 2026-11-11 08:01:27 +00:00 by charles · 0 comments
Owner

Files:

  • Create: crates/fluxer-ui/src/widgets/avatar.rs, crates/fluxer-platform/src/images.rs, crates/fluxer-core/src/media_urls.rs
  • Test: crates/fluxer-core/tests/media_urls.rs, crates/fluxer-platform/tests/images.rs

Interfaces:

  • Produces (core, pure): fn avatar_url(endpoints: &Endpoints, user: &UserPartial, size: u16) -> AvatarSource { Url(Url) | Default(u8 index) } porting fork:fluxer_app/src/features/user/utils/AvatarUtils.ts:170-250 ({media}/avatars/{id}/{hash}.webp?size={snapped} through buildMediaProxyURL — port that function too; default index = (id >> 22) % 6 or whatever getDefaultAvatarIndex does — copy exactly); fn guild_icon_url(endpoints, guild, size).
  • Produces (platform, I/O): ImageCache::new(paths, max_mem_bytes: 64 MiB); async fn get(&self, url: &Url) -> Result<image::RgbaImage> (reqwest → decode with image + WebP via libfluxwebp or image's webp feature; disk cache in cache_dir/images/<sha256>; LRU in memory). Images stay out of fluxer-core (they are view data, not app state): fluxer-ui receives an injected Arc<dyn ImageLoader> (fn load(&self, Url) -> BoxFuture<'static, Result<RgbaImage>>, defined in fluxer-ui, implemented by fluxer-platform::ImageCache) and loads through iced::Task::perform in its update. This is the single sanctioned I/O boundary in fluxer-ui; record it in crates/fluxer-ui/README.md and in CLAUDE.md.
  • avatar::view(source, size, presence: Option<UserStatus>): circle clip, default avatars assets/avatars/{0..5}.png copied from the web app, presence dot colours from tokens.

Plan: https://git.forked.io/charles/fluxer-native/src/branch/foundation/docs/superpowers/plans/2026-11-11-foundation.md (section "Task 21")

**Files:** - Create: `crates/fluxer-ui/src/widgets/avatar.rs`, `crates/fluxer-platform/src/images.rs`, `crates/fluxer-core/src/media_urls.rs` - Test: `crates/fluxer-core/tests/media_urls.rs`, `crates/fluxer-platform/tests/images.rs` **Interfaces:** - Produces (core, pure): `fn avatar_url(endpoints: &Endpoints, user: &UserPartial, size: u16) -> AvatarSource { Url(Url) | Default(u8 index) }` porting `fork:fluxer_app/src/features/user/utils/AvatarUtils.ts:170-250` (`{media}/avatars/{id}/{hash}.webp?size={snapped}` through `buildMediaProxyURL` — port that function too; default index = `(id >> 22) % 6` or whatever `getDefaultAvatarIndex` does — copy exactly); `fn guild_icon_url(endpoints, guild, size)`. - Produces (platform, I/O): `ImageCache::new(paths, max_mem_bytes: 64 MiB)`; `async fn get(&self, url: &Url) -> Result<image::RgbaImage>` (reqwest → decode with `image` + WebP via `libfluxwebp` or `image`'s webp feature; disk cache in `cache_dir/images/<sha256>`; LRU in memory). Images stay out of `fluxer-core` (they are view data, not app state): `fluxer-ui` receives an injected `Arc<dyn ImageLoader>` (`fn load(&self, Url) -> BoxFuture<'static, Result<RgbaImage>>`, defined in `fluxer-ui`, implemented by `fluxer-platform::ImageCache`) and loads through `iced::Task::perform` in its `update`. This is the single sanctioned I/O boundary in `fluxer-ui`; record it in `crates/fluxer-ui/README.md` and in `CLAUDE.md`. - `avatar::view(source, size, presence: Option<UserStatus>)`: circle clip, default avatars `assets/avatars/{0..5}.png` copied from the web app, presence dot colours from tokens. --- Plan: https://git.forked.io/charles/fluxer-native/src/branch/foundation/docs/superpowers/plans/2026-11-11-foundation.md (section "Task 21")
charles added this to the Foundation milestone 2026-11-11 08:01:27 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/fluxer-native#21
No description provided.