╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Logout.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
55 .min_size = null, 56 }); 57 } 58 59 box.getFocus().child_id = button_id; 60 61 return .{ 62 .center = try ui.widget.Center.init(allocator, .{ .box = box }), 63 .data = data, 64 .session = session, 65 .button_id = button_id, 66 }; 67 } 68 69 pub fn deinit(self: *View, allocator: std.mem.Allocator) void { 70 self.center.deinit(allocator); 71 } 72 73 pub fn build(self: *View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 74 try self.center.build(allocator, constraint, root_focus); 75 } 76 77 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 78 _ = allocator; 79 switch (key) { 80 .enter => { 81 try self.logout(); 82 return; 83 }, 84 .mouse => |mouse| { 85 if (inp.leftClickOn(root_focus, self.button_id, mouse)) { 86 try self.logout(); 87 return; 88 } 89 }, 90 else => {}, 91 } 92 } 93 94 fn logout(self: *View) !void { 95 self.session.logOut(); 96 // leave the auth tab for the page it belongs to, where the web's 97 // /logout redirect also lands 98 try self.session.navigate(self.session.data.current_page.pageRoot()); 99 } 100 101 pub fn clearGrid(self: *View) void { 102 self.center.clearGrid(); 103 } 104 105 pub fn getGrid(self: View) ?Grid { 106 return self.center.getGrid(); 107 } 108 109 pub fn getFocus(self: *View) *Focus { 110 return self.center.getFocus(); 111 } 112 113 pub fn atTop(self: View) bool { 114 _ = self; 115 return true; 116 } 117 }; 118