mirror of
https://seed.radicle.dev/rad:z39mP9rQAaGmERfUMPULfPUi473tY.git
synced 2026-11-03 10:20:36 +08:00
lib: Add formatable span for list progress
This commit is contained in:
@@ -55,3 +55,21 @@ pub fn notification_id(content: String) -> Span<'static> {
|
||||
pub fn notification_type(content: String) -> Span<'static> {
|
||||
default(content).style(style::gray().dim())
|
||||
}
|
||||
|
||||
pub fn progress(step: usize, len: usize, fill_zeros: bool) -> Span<'static> {
|
||||
if fill_zeros {
|
||||
if len > 10 {
|
||||
badge(format!("{:-02}/{:-02}", step, len))
|
||||
} else if len > 100 {
|
||||
badge(format!("{:-03}/{:-03}", step, len))
|
||||
} else if len > 1000 {
|
||||
badge(format!("{:-04}/{:-04}", step, len))
|
||||
} else if len > 10000 {
|
||||
badge(format!("{:-05}/{:-05}", step, len))
|
||||
} else {
|
||||
badge(format!("{}/{}", step, len))
|
||||
}
|
||||
} else {
|
||||
badge(format!("{}/{}", step, len))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user