╭ changed ─────────────╮ │src/ui/Home/Header.zig│ ╰──────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────╮ │ 9 const Grid = xitui.grid.Grid; │ │10 const Focus = xitui.focus.Focus; │ │11 │ │12 +const about_tab_label = "about"; │ │13 const repos_tab_label = "repos"; │ │14 const users_tab_label = "users"; │ │15 const settings_tab_label = "settings";│ ╰──────────────────────────────────────────╯ ╭────────────────────────────────────────────────────╮ │16 │ │17 pub const AuthTab = @import("./../AuthTab.zig");│ │18 │ │18 -title: ui.Title, │ │19 +// null hides the title │ │20 +title: ?ui.Title, │ │21 │ │22 const Self = @This(); │ │23 │ ╰────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────╮ │22 -pub fn init(arena: *std.heap.ArenaAllocator) !Self { │ │24 +pub fn init(arena: *std.heap.ArenaAllocator, title: ?[]const u8) !Self { │ │25 return .{ │ │24 - .title = try ui.Title.init(arena, "haxy", .scanlines), │ │26 + .title = if (title) |t| try ui.Title.init(arena, t, .scanlines) else null,│ │27 }; │ │28 } │ │29 │ ╰──────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────╮ │51 errdefer tab_ids.deinit(allocator); │ │52 │ │53 // the leading space plus the title │ │52 - const first_group_width = 1 + try data.title.width(); │ │54 + const first_group_width = if (data.title) |title| 1 + try title.width() else 0;│ │55 │ │56 try ui.widget.addBackButton(allocator, &title_box, session); │ │57 │ ╰───────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────╮ │56 - { │ │57 - var text = try wgt.Text.init(allocator, " "); │ │58 - errdefer text.deinit(allocator); │ │59 - try title_box.children.put(allocator, text.getFocus().id, .{ │ │60 - .widget = .{ .text = text }, │ │61 - .rect = null, │ │62 - .min_size = .{ .width = 1, .height = null }, │ │63 - }); │ │64 - } │ │58 + // title sits to the left of the tabs │ │59 + if (data.title) |*title| { │ │60 + { │ │61 + var text = try wgt.Text.init(allocator, " "); │ │62 + errdefer text.deinit(allocator); │ │63 + try title_box.children.put(allocator, text.getFocus().id, .{ │ │64 + .widget = .{ .text = text }, │ │65 + .rect = null, │ │66 + .min_size = .{ .width = 1, .height = null }, │ │67 + }); │ │68 + } │ │69 │ │66 - // title sits to the left of the tabs │ │67 - { │ │68 - var title_view = try ui.Title.View.init(allocator, &data.title); │ │70 + var title_view = try ui.Title.View.init(allocator, title); │ │71 errdefer title_view.deinit(allocator); │ │72 try title_box.children.put(allocator, title_view.getFocus().id, .{│ │73 .widget = .{ .title = title_view }, │ ╰──────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │90 // the tab matching the current page is focused initially; matching by │ │91 // link (rather than position) keeps this robust to tab changes. │ │92 const current_tag = std.meta.activeTag(session.data.current_page); │ │93 + const about_link = try ui.inPageTabLink(session, .home_about, current_tag == .home_about); │ │94 const repos_link = try ui.inPageTabLink(session, .{ .home_repos = 0 }, current_tag == .home_repos);│ │95 const users_link = try ui.inPageTabLink(session, .{ .home_users = 0 }, current_tag == .home_users);│ │96 const settings_link = try ui.inPageTabLink(session, .home_settings, current_tag == .home_settings);│ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 97 const auth_link = try ui.inPageTabLink(session, .home_auth, current_tag == .home_auth);│ │ 98 const current_link: []const u8 = switch (current_tag) { │ │ 99 + .home_repos => repos_link, │ │100 .home_users => users_link, │ │101 .home_settings => settings_link, │ │102 .home_auth => auth_link, │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 99 - else => repos_link, │ │103 + else => about_link, │ │104 }; │ │105 var selected_tab: ?usize = null; │ │106 + │ │107 + // about tab │ │108 + { │ │109 + var text_box = try wgt.TextBox.init(allocator, about_tab_label, .{ .border_style = .single, .round_corners = true, .wrap_kind = .none });│ │110 + errdefer text_box.deinit(allocator); │ │111 + text_box.getFocus().mode = .all; │ │112 + text_box.getFocus().kind = .{ .custom = about_link }; │ │113 + try tab_ids.put(allocator, text_box.getFocus().id, {}); │ │114 + if (std.mem.eql(u8, about_link, current_link)) selected_tab = text_box.getFocus().id; │ │115 + try tabs_box.children.put(allocator, text_box.getFocus().id, .{ │ │116 + .widget = .{ .text_box = text_box }, │ │117 + .rect = null, │ │118 + .min_size = .{ .width = about_tab_label.len + 2, .height = null }, │ │119 + }); │ │120 + } │ │121 │ │122 // repos tab │ │123 { │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯