╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Logout.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
58 .min_size = null, 59 }); 60 } 61 62 box.getFocus().child_id = button_id; 63 64 return .{ 65 .center = try ui.Center.init(allocator, .{ .box = box }), 66 .data = data, 67 .session = session, 68 .button_id = button_id, 69 .users_tab_id = users_tab_id, 70 }; 71 } 72 73 pub fn deinit(self: *View, allocator: std.mem.Allocator) void { 74 self.center.deinit(allocator); 75 } 76 77 pub fn build(self: *View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 78 try self.center.build(allocator, constraint, root_focus); 79 } 80 81 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 82 _ = allocator; 83 switch (key) { 84 .enter => { 85 try self.logout(root_focus); 86 return; 87 }, 88 .mouse => |mouse| { 89 if (inp.leftClickOn(root_focus, self.button_id, mouse)) { 90 try self.logout(root_focus); 91 return; 92 } 93 }, 94 else => {}, 95 } 96 } 97 98 fn logout(self: *View, root_focus: *Focus) !void { 99 self.session.data.user_id = null; 100 // jump focus back to the users tab — the logout button is about to 101 // be hidden by the tab-label swap. 102 root_focus.setFocus(self.users_tab_id); 103 } 104 105 pub fn clearGrid(self: *View) void { 106 self.center.clearGrid(); 107 } 108 109 pub fn getGrid(self: View) ?Grid { 110 return self.center.getGrid(); 111 } 112 113 pub fn getFocus(self: *View) *Focus { 114 return self.center.getFocus(); 115 } 116 117 pub fn getSelectedIndex(self: View) ?usize { 118 _ = self; 119 return 0; 120 } 121 }; 122