╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Auth.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
41 { 42 var logout = try Logout.View.init(allocator, &data.logout, session); 43 errdefer logout.deinit(allocator); 44 try stack.children.put(allocator, logout.getFocus().id, .{ .auth_logout = logout }); 45 } 46 return .{ 47 .stack = stack, 48 .session = session, 49 }; 50 } 51 52 pub fn deinit(self: *View, allocator: std.mem.Allocator) void { 53 self.stack.deinit(allocator); 54 } 55 56 pub fn build(self: *View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 57 const index: usize = if (self.session.data.user_id != null) logout_index else login_index; 58 self.stack.getFocus().child_id = self.stack.children.keys()[index]; 59 try self.stack.build(allocator, constraint, root_focus); 60 } 61 62 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 63 try self.stack.input(allocator, key, root_focus); 64 } 65 66 pub fn clearGrid(self: *View) void { 67 self.stack.clearGrid(); 68 } 69 70 pub fn getGrid(self: View) ?Grid { 71 return self.stack.getGrid(); 72 } 73 74 pub fn getFocus(self: *View) *Focus { 75 return self.stack.getFocus(); 76 } 77 78 pub fn atTop(self: View, root_focus: *Focus) bool { 79 const selected = self.stack.getSelected() orelse return false; 80 return selected.atTop(root_focus); 81 } 82 }; 83