1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use ratatui::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Hash, PartialEq, Eq, Clone, Copy)]
pub enum Header {
    Id,
    Name,
    SizeWhenDone,
    Progress,
    Eta,
    DownloadRate,
    UploadRate,
    DownloadDir,
    Padding,
    UploadRatio,
    UploadedEver,
    ActivityDate,
    AddedDate,
    PeersConnected,
    SmallStatus,
    Category,
    CategoryIcon,
}

impl Header {
    pub fn default_constraint(&self) -> Constraint {
        match self {
            Self::Name => Constraint::Max(70),
            Self::SizeWhenDone => Constraint::Length(12),
            Self::Progress => Constraint::Length(12),
            Self::Eta => Constraint::Length(12),
            Self::DownloadRate => Constraint::Length(12),
            Self::UploadRate => Constraint::Length(12),
            Self::DownloadDir => Constraint::Max(70),
            Self::Padding => Constraint::Length(2),
            Self::UploadRatio => Constraint::Length(6),
            Self::UploadedEver => Constraint::Length(12),
            Self::Id => Constraint::Length(4),
            Self::ActivityDate => Constraint::Length(14),
            Self::AddedDate => Constraint::Length(12),
            Self::PeersConnected => Constraint::Length(6),
            Self::SmallStatus => Constraint::Length(1),
            Self::Category => Constraint::Max(15),
            Self::CategoryIcon => Constraint::Length(5),
        }
    }

    pub fn header_name(&self) -> &'static str {
        match *self {
            Self::Name => "Name",
            Self::SizeWhenDone => "Size",
            Self::Progress => "Progress",
            Self::Eta => "ETA",
            Self::DownloadRate => "Download",
            Self::UploadRate => "Upload",
            Self::DownloadDir => "Directory",
            Self::Padding => "",
            Self::UploadRatio => "Ratio",
            Self::UploadedEver => "Up Ever",
            Self::Id => "Id",
            Self::ActivityDate => "Last active",
            Self::AddedDate => "Added",
            Self::PeersConnected => "Peers",
            Self::SmallStatus => "",
            Self::Category => "Category",
            Self::CategoryIcon => "",
        }
    }
}