moving stringfying of the verse to it's own function
Some checks failed
/ test (push) Has been cancelled

This commit is contained in:
Chris Cochrun 2026-01-06 14:53:17 -06:00
parent ec572a78d7
commit 0543e2e892
2 changed files with 74 additions and 55 deletions

View file

@ -51,6 +51,72 @@ pub enum Verse {
Other { number: usize, lyric: String },
}
impl Verse {
pub fn get_name(&self) -> String {
match self {
Verse::Verse { number, .. } => {
let mut string = "Verse ".to_string();
string.push_str(&number.to_string());
string
}
Verse::PreChorus { number, .. } => {
let mut string = "Pre-Chorus ".to_string();
string.push_str(&number.to_string());
string
}
Verse::Chorus { number, .. } => {
let mut string = "Chorus ".to_string();
string.push_str(&number.to_string());
string
}
Verse::PostChorus { number, .. } => {
let mut string = "Post-Chorus ".to_string();
string.push_str(&number.to_string());
string
}
Verse::Bridge { number, .. } => {
let mut string = "Bridge ".to_string();
string.push_str(&number.to_string());
string
}
Verse::Intro { number, .. } => {
let mut string = "Intro ".to_string();
string.push_str(&number.to_string());
string
}
Verse::Outro { number, .. } => {
let mut string = "Outro ".to_string();
string.push_str(&number.to_string());
string
}
Verse::Instrumental { number, .. } => {
let mut string = "Instrumental ".to_string();
string.push_str(&number.to_string());
string
}
Verse::Other { number, .. } => {
let mut string = "Other ".to_string();
string.push_str(&number.to_string());
string
}
}
}
pub fn get_lyric(&self) -> String {
match self {
Verse::Verse { lyric, .. } => lyric.clone(),
Verse::PreChorus { lyric, .. } => lyric.clone(),
Verse::Chorus { lyric, .. } => lyric.clone(),
Verse::PostChorus { lyric, .. } => lyric.clone(),
Verse::Bridge { lyric, .. } => lyric.clone(),
Verse::Intro { lyric, .. } => lyric.clone(),
Verse::Outro { lyric, .. } => lyric.clone(),
Verse::Instrumental { lyric, .. } => lyric.clone(),
Verse::Other { lyric, .. } => lyric.clone(),
}
}
}
impl Default for Verse {
fn default() -> Self {
Self::Verse {

View file

@ -411,7 +411,7 @@ order",
.label("Verse Order")
.on_input(Message::ChangeVerseOrder);
let lyric_title = text("Lyrics");
let lyric_title = text::heading("Lyrics");
let lyric_input = column![
lyric_title,
text_editor(&self.lyrics)
@ -424,60 +424,7 @@ order",
if let Some(verses) = song.verses.map(|verses| {
verses
.iter()
.map(|verse| match verse {
Verse::Verse { number, .. } => text({
let mut string = "Verse ".to_string();
string.push_str(&number.to_string());
string
}),
Verse::PreChorus { number, lyric } => text({
let mut string =
"Pre-Chorus ".to_string();
string.push_str(&number.to_string());
string
}),
Verse::Chorus { number, lyric } => text({
let mut string = "Chorus ".to_string();
string.push_str(&number.to_string());
string
}),
Verse::PostChorus { number, lyric } => {
text({
let mut string =
"Post-Chorus ".to_string();
string.push_str(&number.to_string());
string
})
}
Verse::Bridge { number, lyric } => text({
let mut string = "Bridge ".to_string();
string.push_str(&number.to_string());
string
}),
Verse::Intro { number, lyric } => text({
let mut string = "Intro ".to_string();
string.push_str(&number.to_string());
string
}),
Verse::Outro { number, lyric } => text({
let mut string = "Outro ".to_string();
string.push_str(&number.to_string());
string
}),
Verse::Instrumental { number, lyric } => {
text({
let mut string =
"Instrumental ".to_string();
string.push_str(&number.to_string());
string
})
}
Verse::Other { number, lyric } => text({
let mut string = "Other ".to_string();
string.push_str(&number.to_string());
string
}),
})
.map(|verse| text(verse.get_name()))
.collect()
}) {
verses
@ -722,6 +669,12 @@ order",
}
}
fn verses_editor<'a>(verse: Verse) -> Element<'a, Message> {
let verse_title = text(verse.get_name());
let lyric = text(verse.get_lyric());
todo!()
}
impl Default for SongEditor {
fn default() -> Self {
let mut fontdb = fontdb::Database::new();