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