╭ changed ───────────────╮ │src/ui/widget/thread.zig│ ╰────────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1959 const action = try aa.print("form:{s}", .{page_url}); │ │1960 const event_name = if (data.comment_id.len == 0) thread_name else "comment"; │ │1961 var label_buf: ["remove ".len + @max(thread_name.len, "comment".len)]u8 = undefined;│ │1962 - var buttons: [2]ConfirmationButton = undefined; │ │1962 + var buttons: [2]widget.ConfirmationButton = undefined; │ │1963 buttons[0] = .{ .label = switch (confirmation_kind) { │ │1964 .remove => try std.fmt.bufPrint(&label_buf, "remove {s}", .{event_name}), │ │1965 .publish => "publish patch", │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1982 button_count += 1; │ │1983 } else unreachable; │ │1984 } │ │1985 - var center = try initConfirmationForm(allocator, action, buttons[0..button_count]); │ │1985 + var center = try widget.initConfirmationForm(allocator, action, buttons[0..button_count]);│ │1986 errdefer center.deinit(allocator); │ │1987 try stack.children.put(allocator, center.getFocus().id, .{ .center = center }); │ │1988 } else if (data.view == .new_comment or data.view == .edit_comment) { │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │2241 try addSubmitButtonLabeled(allocator, &box, "submit"); │ │2242 return box; │ │2243 } │ │2244 - │ │2245 - const ConfirmationButton = struct { │ │2246 - label: []const u8, │ │2247 - bottom_label: []const u8 = "", │ │2248 - action: []const u8 = "submit", │ │2249 - }; │ │2250 - │ │2251 - fn initConfirmationForm(allocator: std.mem.Allocator, action: []const u8, buttons: []const ConfirmationButton) !Center { │ │2252 - var box = try wgt.Box(Widget).init(allocator, .{ .border = null, .round_corners = true, .direction = .vert }); │ │2253 - errdefer box.deinit(allocator); │ │2254 - box.getFocus().kind = .{ .custom = action }; │ │2244 │ │2256 - var prompt = try wgt.Text.init(allocator, "are you sure?"); │ │2257 - errdefer prompt.deinit(allocator); │ │2258 - try box.children.put(allocator, prompt.getFocus().id, .{ .widget = .{ .text = prompt }, .rect = null, .min_size = null }); │ │2259 - │ │2260 - for (buttons, 0..) |options, index| { │ │2261 - var button = try wgt.TextBox.init(allocator, options.label, .{ .border = .single, .round_corners = true, .wrap_kind = .none, .bottom_label = .{ .text = options.bottom_label } });│ │2262 - errdefer button.deinit(allocator); │ │2263 - button.getFocus().mode = .all; │ │2264 - button.getFocus().kind = .{ .custom = options.action }; │ │2265 - try box.children.put(allocator, button.getFocus().id, .{ .widget = .{ .text_box = button }, .rect = null, .min_size = null }); │ │2266 - if (index == 0) box.getFocus().child_id = button.getFocus().id; │ │2267 - } │ │2268 - │ │2269 - return Center.init(allocator, .{ .box = box }); │ │2270 - } │ │2271 - │ │2245 // a form's submit button, then a spacer absorbing the leftover │ │2246 // min-height the box hands its last child, so the button keeps its │ │2247 // natural height │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯