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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
use {
    crate::{
        data::{Directory, Note},
        state::notebook::DirectoryItem,
        types::DirectoryId,
        Event,
    },
    strum_macros::Display,
};

#[derive(Display)]
pub enum Transition {
    #[strum(to_string = "Entry::{0}")]
    Entry(EntryTransition),

    #[strum(to_string = "Notebook::{0}")]
    Notebook(NotebookTransition),

    Log(String),
    Error(String),
}

#[derive(Display)]
pub enum EntryTransition {
    OpenNotebook,

    #[strum(to_string = "Inedible::{0}")]
    Inedible(Event),

    None,
}

#[derive(Display)]
pub enum NotebookTransition {
    OpenDirectory {
        id: DirectoryId,
        notes: Vec<Note>,
        directories: Vec<DirectoryItem>,
    },
    CloseDirectory(DirectoryId),

    RenameNote(Note),
    RenameDirectory(Directory),

    RemoveNote {
        note: Note,
        selected_directory: Directory,
    },
    RemoveDirectory {
        directory: Directory,
        selected_directory: Directory,
    },

    AddNote(Note),
    AddDirectory(Directory),

    ShowNoteActionsDialog(Note),
    ShowDirectoryActionsDialog(Directory),

    OpenNote {
        note: Note,
        content: String,
    },
    EditMode,
    ViewMode(Note),
    SelectNote(Note),
    SelectDirectory(Directory),
    UpdateNoteContent,

    ShowEntryDialog,
    Entry(EntryTransition),

    #[strum(to_string = "Inedible::{0}")]
    Inedible(Event),
    None,
}

impl From<EntryTransition> for Transition {
    fn from(t: EntryTransition) -> Self {
        Self::Entry(t)
    }
}

impl From<NotebookTransition> for Transition {
    fn from(t: NotebookTransition) -> Self {
        Self::Notebook(t)
    }
}