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
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
use crate::class::NativeImage;
use js_sys::JsString;
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
#[derive(Clone, Debug, PartialEq)]
pub struct NotificationOptions {
    actions: Option<Box<[JsValue]>>,
    body: JsString,
    close_button_text: Option<JsString>,
    has_reply: Option<bool>,
    icon: Option<NativeImage>,
    reply_placeholder: Option<JsString>,
    silent: Option<bool>,
    sound: Option<JsString>,
    subtitle: Option<JsString>,
    timeout_type: Option<JsString>,
    title: JsString,
    urgency: Option<JsString>,
}

#[wasm_bindgen]
impl NotificationOptions {
    #[allow(clippy::too_many_arguments)]
    #[wasm_bindgen(constructor)]
    pub fn new(
        actions: Option<Box<[JsValue]>>,
        body: JsString,
        close_button_text: Option<JsString>,
        has_reply: Option<bool>,
        icon: Option<NativeImage>,
        reply_placeholder: Option<JsString>,
        silent: Option<bool>,
        sound: Option<JsString>,
        subtitle: Option<JsString>,
        timeout_type: Option<JsString>,
        title: JsString,
        urgency: Option<JsString>,
    ) -> NotificationOptions {
        NotificationOptions {
            actions,
            body,
            close_button_text,
            has_reply,
            icon,
            reply_placeholder,
            silent,
            sound,
            subtitle,
            timeout_type,
            title,
            urgency,
        }
    }

    #[wasm_bindgen(getter)]
    pub fn actions(&self) -> Option<Box<[JsValue]>> {
        self.actions.clone()
    }

    #[wasm_bindgen(setter)]
    pub fn set_actions(&mut self, value: Option<Box<[JsValue]>>) {
        self.actions = value;
    }

    #[wasm_bindgen(getter)]
    pub fn body(&self) -> JsString {
        self.body.clone()
    }

    #[wasm_bindgen(setter)]
    pub fn set_body(&mut self, value: JsString) {
        self.body = value;
    }

    #[wasm_bindgen(getter)]
    pub fn close_button_text(&self) -> Option<JsString> {
        self.close_button_text.clone()
    }

    #[wasm_bindgen(setter)]
    pub fn set_close_button_text(&mut self, value: Option<JsString>) {
        self.close_button_text = value;
    }

    #[wasm_bindgen(getter)]
    pub fn has_reply(&self) -> Option<bool> {
        self.has_reply
    }

    #[wasm_bindgen(setter)]
    pub fn set_has_reply(&mut self, value: Option<bool>) {
        self.has_reply = value;
    }

    #[wasm_bindgen(getter)]
    pub fn icon(&self) -> Option<NativeImage> {
        self.icon.clone()
    }

    #[wasm_bindgen(setter)]
    pub fn set_icon(&mut self, value: Option<NativeImage>) {
        self.icon = value;
    }

    #[wasm_bindgen(getter)]
    pub fn reply_placeholder(&self) -> Option<JsString> {
        self.reply_placeholder.clone()
    }

    #[wasm_bindgen(setter)]
    pub fn set_reply_placeholder(&mut self, value: Option<JsString>) {
        self.reply_placeholder = value;
    }

    #[wasm_bindgen(getter)]
    pub fn silent(&self) -> Option<bool> {
        self.silent
    }

    #[wasm_bindgen(setter)]
    pub fn set_silent(&mut self, value: Option<bool>) {
        self.silent = value;
    }

    #[wasm_bindgen(getter)]
    pub fn sound(&self) -> Option<JsString> {
        self.sound.clone()
    }

    #[wasm_bindgen(setter)]
    pub fn set_sound(&mut self, value: Option<JsString>) {
        self.sound = value;
    }

    #[wasm_bindgen(getter)]
    pub fn subtitle(&self) -> Option<JsString> {
        self.subtitle.clone()
    }

    #[wasm_bindgen(setter)]
    pub fn set_subtitle(&mut self, value: Option<JsString>) {
        self.subtitle = value;
    }

    #[wasm_bindgen(getter)]
    pub fn timeout_type(&self) -> Option<JsString> {
        self.timeout_type.clone()
    }

    #[wasm_bindgen(setter)]
    pub fn set_timeout_type(&mut self, value: Option<JsString>) {
        self.timeout_type = value;
    }

    #[wasm_bindgen(getter)]
    pub fn title(&self) -> JsString {
        self.title.clone()
    }

    #[wasm_bindgen(setter)]
    pub fn set_title(&mut self, value: JsString) {
        self.title = value;
    }

    #[wasm_bindgen(getter)]
    pub fn urgency(&self) -> Option<JsString> {
        self.urgency.clone()
    }

    #[wasm_bindgen(setter)]
    pub fn set_urgency(&mut self, value: Option<JsString>) {
        self.urgency = value;
    }
}