feat(settings): settings app: apps list + per-capability allow/revoke, about (who/role), sign out; system-only caps permissions/session (install refused); pm MANAGE_BADGE copy (list/apps/allow/revoke only), APPS op; init WHO + session pass-on; factory decisions seeded for new system apps; k-ui list_item/toggle, screens/back/scroll
This commit is contained in:
@@ -106,19 +106,58 @@ impl Painter<'_, '_> {
|
||||
Kind::Text(t) => self.text_in(&t.content, t.style, r, false, theme.text_colour(t.colour)),
|
||||
Kind::Button(b) => {
|
||||
let (fill, label) = theme.button(b.variant);
|
||||
if let (Some(fill), Some(path)) = (fill, rounded(r, theme.corner_radius)) {
|
||||
self.pm.fill_path(&path, &paint(fill), FillRule::Winding, Transform::identity(), None);
|
||||
if let Some(fill) = fill {
|
||||
self.fill(r, theme.corner_radius, fill);
|
||||
}
|
||||
self.text_in(&b.label, TextStyle::Label, r, true, label);
|
||||
if self.focused == Some(me) {
|
||||
let ring = Rect { x: r.x - RING_GAP, y: r.y - RING_GAP, w: r.w + 2.0 * RING_GAP, h: r.h + 2.0 * RING_GAP };
|
||||
if let Some(path) = rounded(ring, theme.corner_radius + RING_GAP) {
|
||||
let stroke = Stroke { width: RING_WIDTH, ..Stroke::default() };
|
||||
self.pm.stroke_path(&path, &paint(theme.focus), &stroke, Transform::identity(), None);
|
||||
}
|
||||
Kind::Item(i) => {
|
||||
self.fill(r, theme.corner_radius, theme.surface);
|
||||
let inner = self.inset(r);
|
||||
match &i.subtitle {
|
||||
Some(sub) => {
|
||||
let half = Rect { h: inner.h / 2.0, ..inner };
|
||||
self.text_in(&i.title, TextStyle::Label, half, false, theme.text_primary);
|
||||
self.text_in(sub, TextStyle::Caption, Rect { y: inner.y + inner.h / 2.0, ..half }, false, theme.text_secondary);
|
||||
}
|
||||
None => self.text_in(&i.title, TextStyle::Label, inner, false, theme.text_primary),
|
||||
}
|
||||
// A chevron: there is more behind it.
|
||||
let chevron = Rect { x: inner.x + inner.w - 12.0, w: 12.0, ..inner };
|
||||
self.text_in(">", TextStyle::Label, chevron, true, theme.text_secondary);
|
||||
}
|
||||
Kind::Toggle(g) => {
|
||||
self.fill(r, theme.corner_radius, theme.surface);
|
||||
let inner = self.inset(r);
|
||||
self.text_in(&g.label, TextStyle::Body, inner, false, theme.text_primary);
|
||||
let (tw, th) = crate::layout::SWITCH;
|
||||
let track = Rect { x: inner.x + inner.w - tw, y: inner.y + (inner.h - th) / 2.0, w: tw, h: th };
|
||||
self.fill(track, th / 2.0, if g.on { theme.accent } else { theme.surface_raised });
|
||||
let knob = th - 6.0;
|
||||
let kx = if g.on { track.x + tw - knob - 3.0 } else { track.x + 3.0 };
|
||||
self.fill(Rect { x: kx, y: track.y + 3.0, w: knob, h: knob }, knob / 2.0, theme.text_primary);
|
||||
}
|
||||
}
|
||||
if self.focused == Some(me) && e.kind.event().is_some() {
|
||||
let ring = Rect { x: r.x - RING_GAP, y: r.y - RING_GAP, w: r.w + 2.0 * RING_GAP, h: r.h + 2.0 * RING_GAP };
|
||||
if let Some(path) = rounded(ring, theme.corner_radius + RING_GAP) {
|
||||
let stroke = Stroke { width: RING_WIDTH, ..Stroke::default() };
|
||||
self.pm.stroke_path(&path, &paint(theme.focus), &stroke, Transform::identity(), None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// `r` filled with `c`, its corners rounded by `radius`.
|
||||
fn fill(&mut self, r: Rect, radius: f32, c: Rgba) {
|
||||
if let Some(path) = rounded(r, radius) {
|
||||
self.pm.fill_path(&path, &paint(c), FillRule::Winding, Transform::identity(), None);
|
||||
}
|
||||
}
|
||||
|
||||
/// `r` less a list row's padding all round.
|
||||
fn inset(&self, r: Rect) -> Rect {
|
||||
let p = crate::layout::row_padding(self.theme);
|
||||
Rect { x: r.x + p, y: r.y + p, w: (r.w - 2.0 * p).max(0.0), h: (r.h - 2.0 * p).max(0.0) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user