cacao/examples/todos_list/preferences/advanced.rs

28 lines
993 B
Rust
Raw Normal View History

use cacao::layout::{Layout, LayoutConstraint};
2022-07-16 00:14:02 +10:00
use cacao::text::{Label, TextAlign};
use cacao::view::{View, ViewDelegate};
/// A blank advanced preferences view.
#[derive(Debug, Default)]
pub struct AdvancedPreferencesContentView {
label: Label
}
impl ViewDelegate for AdvancedPreferencesContentView {
const NAME: &'static str = "AdvancedPreferencesContentView";
2022-07-11 01:15:29 +10:00
fn did_load(&mut self, view: View) {
2022-07-16 00:14:02 +10:00
self.label
.set_text("And this is where advanced preferences would be... if we had any.");
self.label.set_text_alignment(TextAlign::Center);
view.add_subview(&self.label);
LayoutConstraint::activate(&[
self.label.top.constraint_equal_to(&view.top).offset(100.),
self.label.leading.constraint_equal_to(&view.leading).offset(16.),
self.label.trailing.constraint_equal_to(&view.trailing).offset(-16.),
self.label.bottom.constraint_equal_to(&view.bottom).offset(-100.)
]);
}
}