this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

add 60k track fake data generator

+98 -23
+7
CHANGELOG.md
··· 29 29 - #docs wrote installation instructions in README.md 30 30 - #tooling tested cargo install --path . pipeline 31 31 - #app tested 10k item scrolling (smooth in release mode) 32 + - #app made list full width (removed container padding, added width::Fill to column) 33 + - #app added table-like styling (borders between items, padding on each row) 34 + - #app fixed double border issue (using horizontal_rule between items for clean separation) 35 + - #data created Track struct with realistic fields (artist, title, radio, genre, year, url) 36 + - #data generated 60k fake tracks with 30 artist names, 16 radio stations, 15 genres 37 + - #structure separated concerns: src/track.rs for data, src/main.rs for UI 38 + - #perf verified GPU scrolling handles 60k items instantly
+38 -14
src/main.rs
··· 1 - use iced::widget::{column, container, scrollable, text}; 2 - use iced::Length; 1 + mod track; 2 + 3 + use iced::widget::{column, container, horizontal_rule, scrollable, text}; 4 + use iced::{Color, Length, Theme}; 5 + use track::Track; 3 6 4 7 fn main() -> iced::Result { 5 - iced::run("r4 - 10k items", update, view) 8 + iced::run("r4 - 60k tracks", update, view) 6 9 } 7 10 8 11 struct State { 9 - items: Vec<String>, 12 + tracks: Vec<Track>, 10 13 } 11 14 12 15 impl Default for State { 13 16 fn default() -> Self { 14 17 Self { 15 - items: (0..10_000) 16 - .map(|i| format!("item #{:05} - dummy data for performance testing", i)) 17 - .collect(), 18 + tracks: Track::generate_fake(60_000), 18 19 } 19 20 } 20 21 } ··· 25 26 fn update(_state: &mut State, _message: Message) {} 26 27 27 28 fn view(state: &State) -> iced::Element<Message> { 28 - let item_list = state.items.iter().fold( 29 - column![].spacing(4), 30 - |col, item| col.push(text(item)) 31 - ); 29 + let item_list = state.tracks.iter().enumerate().fold( 30 + column![].spacing(0).width(Length::Fill), 31 + |col, (i, track)| { 32 + let track_info = format!( 33 + "{} - {} [{}] ({})", 34 + track.artist, track.title, track.genre, track.year 35 + ); 36 + let item_container = container(text(track_info)) 37 + .padding(12) 38 + .width(Length::Fill); 32 39 33 - let content = scrollable( 34 - container(item_list) 35 - .padding(20) 40 + let mut col = col.push(item_container); 41 + 42 + if i < state.tracks.len() - 1 { 43 + col = col.push( 44 + horizontal_rule(1) 45 + .style(|_theme: &Theme| { 46 + iced::widget::rule::Style { 47 + color: Color::from_rgb(0.2, 0.2, 0.2), 48 + width: 1, 49 + radius: 0.0.into(), 50 + fill_mode: iced::widget::rule::FillMode::Full, 51 + } 52 + }) 53 + ); 54 + } 55 + 56 + col 57 + } 36 58 ); 59 + 60 + let content = scrollable(item_list); 37 61 38 62 container(content) 39 63 .width(Length::Fill)
+52
src/track.rs
··· 1 + #[derive(Debug, Clone)] 2 + pub struct Track { 3 + pub id: u32, 4 + pub title: String, 5 + pub artist: String, 6 + pub radio: String, 7 + pub genre: String, 8 + pub year: u16, 9 + pub url: String, 10 + } 11 + 12 + impl Track { 13 + pub fn generate_fake(count: usize) -> Vec<Track> { 14 + let genres = [ 15 + "rock", "electronic", "jazz", "ambient", "techno", 16 + "indie", "metal", "pop", "classical", "hip-hop", 17 + "folk", "blues", "punk", "soul", "disco" 18 + ]; 19 + 20 + let radios = [ 21 + "Midnight Frequencies", "Coastal Waves", "Desert Transit", 22 + "Urban Echo", "Forest Sessions", "Neon Nights", 23 + "Analog Dreams", "Digital Shores", "Mountain Reverb", 24 + "Chrome Signals", "Velvet Underground FM", "Crystal Static", 25 + "Concrete Jungle Radio", "Aurora Borealis Broadcast", 26 + "Tropical Frequency", "Arctic Transmissions" 27 + ]; 28 + 29 + let artists = [ 30 + "Luna Vesper", "The Midnight Architects", "Neon Cascades", 31 + "Velvet Machinery", "Solar Flares", "Echo Chamber Ensemble", 32 + "Digital Nomads", "Analog Hearts", "The Reverb Society", 33 + "Crystal Method Collective", "Urban Landscapes", "Cosmic Debris", 34 + "Twilight Operators", "The Static Kings", "Wavelength Warriors", 35 + "Frequency Modulation", "Bass & Treble", "The Delay Pedals", 36 + "Vintage Circuits", "Modern Fossils", "The Loop Collective", 37 + "Synth & Soul", "Tape Deck Memories", "The Algorithm", 38 + "Human After All", "Channel Zero", "The Bandwidth", 39 + "Stereo Phantoms", "Mono Myths", "The Decibels" 40 + ]; 41 + 42 + (0..count).map(|i| Track { 43 + id: i as u32, 44 + title: format!("Track #{:05}", i), 45 + artist: artists[i % artists.len()].to_string(), 46 + radio: radios[i % radios.len()].to_string(), 47 + genre: genres[i % genres.len()].to_string(), 48 + year: 1990 + (i % 35) as u16, 49 + url: format!("https://youtube.com/watch?v=fake{}", i), 50 + }).collect() 51 + } 52 + }
+1 -9
todo.txt
··· 1 1 todo 2 2 ==== 3 3 4 - next - hello world 5 - ------------------ 6 - [ ] remove r4/ folder (dioxus prototype) 7 - [ ] cargo init --name r4 8 - [ ] add iced dependency to Cargo.toml 9 - [ ] write minimal main.rs (counter example from docs) 10 - [ ] cargo run to test 11 - [ ] verify window opens and counter works 12 - 13 4 14 5 backlog 15 6 ------- 7 + - make the list full width and responsive? 16 8 [ ] fetch radio4000 data structure 17 9 [ ] design data model for radios/tracks 18 10 [ ] display list of radios