╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Logout.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
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.data.user_id = null; 96 self.session.data.user_name = null; 97 // leave the auth tab for the page it belongs to, where the web's 98 // /logout redirect also lands 99 try self.session.navigate(self.session.data.current_page.pageRoot()); 100 } 101 102 pub fn clearGrid(self: *View) void { 103 self.center.clearGrid(); 104 } 105 106 pub fn getGrid(self: View) ?Grid { 107 return self.center.getGrid(); 108 } 109 110 pub fn getFocus(self: *View) *Focus { 111 return self.center.getFocus(); 112 } 113 114 pub fn getSelectedIndex(self: View) ?usize { 115 _ = self; 116 return 0; 117 } 118 }; 119