Improve donation defaults and light contrast
This commit is contained in:
@@ -5,7 +5,7 @@ const Style := preload("res://scripts/ui/ui_style.gd")
|
|||||||
const DonationAmount := preload("res://scripts/ui/donation_amount.gd")
|
const DonationAmount := preload("res://scripts/ui/donation_amount.gd")
|
||||||
const MINIMUM_CENTS := 500
|
const MINIMUM_CENTS := 500
|
||||||
const MAXIMUM_CENTS := 1000000
|
const MAXIMUM_CENTS := 1000000
|
||||||
const DEFAULT_CENTS := 2500
|
const DEFAULT_CENTS := 500
|
||||||
|
|
||||||
var main: Control
|
var main: Control
|
||||||
var content_grid: GridContainer
|
var content_grid: GridContainer
|
||||||
@@ -13,6 +13,7 @@ var mission_panel: PanelContainer
|
|||||||
var contribution_panel: PanelContainer
|
var contribution_panel: PanelContainer
|
||||||
var preset_grid: GridContainer
|
var preset_grid: GridContainer
|
||||||
var amount_buttons: Array[Button] = []
|
var amount_buttons: Array[Button] = []
|
||||||
|
var muted_labels: Array[Label] = []
|
||||||
var amount_group := ButtonGroup.new()
|
var amount_group := ButtonGroup.new()
|
||||||
var custom_amount: LineEdit
|
var custom_amount: LineEdit
|
||||||
var donate_button: Button
|
var donate_button: Button
|
||||||
@@ -61,6 +62,7 @@ func _build_ui() -> void:
|
|||||||
subtitle.add_theme_font_size_override("font_size", 18)
|
subtitle.add_theme_font_size_override("font_size", 18)
|
||||||
subtitle.add_theme_color_override("font_color", Brand.muted_color(UIThemeService.is_dark_mode()))
|
subtitle.add_theme_color_override("font_color", Brand.muted_color(UIThemeService.is_dark_mode()))
|
||||||
subtitle.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
subtitle.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||||
|
muted_labels.append(subtitle)
|
||||||
page.add_child(subtitle)
|
page.add_child(subtitle)
|
||||||
|
|
||||||
content_grid = GridContainer.new()
|
content_grid = GridContainer.new()
|
||||||
@@ -141,7 +143,7 @@ func _build_ui() -> void:
|
|||||||
contribution.add_child(custom_amount)
|
contribution.add_child(custom_amount)
|
||||||
|
|
||||||
donate_button = Button.new()
|
donate_button = Button.new()
|
||||||
donate_button.text = "Donate $25 securely"
|
donate_button.text = "Donate $5 securely"
|
||||||
donate_button.custom_minimum_size = Vector2(0, 58)
|
donate_button.custom_minimum_size = Vector2(0, 58)
|
||||||
donate_button.pressed.connect(_on_donate_pressed)
|
donate_button.pressed.connect(_on_donate_pressed)
|
||||||
contribution.add_child(donate_button)
|
contribution.add_child(donate_button)
|
||||||
@@ -270,6 +272,7 @@ func _body(value: String) -> Label:
|
|||||||
label.add_theme_font_size_override("font_size", 17)
|
label.add_theme_font_size_override("font_size", 17)
|
||||||
label.add_theme_color_override("font_color", Brand.muted_color(UIThemeService.is_dark_mode()))
|
label.add_theme_color_override("font_color", Brand.muted_color(UIThemeService.is_dark_mode()))
|
||||||
label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||||
|
muted_labels.append(label)
|
||||||
return label
|
return label
|
||||||
|
|
||||||
|
|
||||||
@@ -282,6 +285,8 @@ func _update_layout() -> void:
|
|||||||
|
|
||||||
func refresh_theme_controls() -> void:
|
func refresh_theme_controls() -> void:
|
||||||
var dark := UIThemeService.is_dark_mode()
|
var dark := UIThemeService.is_dark_mode()
|
||||||
|
for label in muted_labels:
|
||||||
|
label.add_theme_color_override("font_color", Brand.muted_color(dark))
|
||||||
for panel in [mission_panel, contribution_panel]:
|
for panel in [mission_panel, contribution_panel]:
|
||||||
if panel != null:
|
if panel != null:
|
||||||
var box := Brand.content_card_box(dark, false)
|
var box := Brand.content_card_box(dark, false)
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ func _run() -> void:
|
|||||||
host.add_child(screen)
|
host.add_child(screen)
|
||||||
await process_frame
|
await process_frame
|
||||||
_assert(screen.content_grid.columns == 2, "wide donation layouts should use two columns")
|
_assert(screen.content_grid.columns == 2, "wide donation layouts should use two columns")
|
||||||
_assert(screen.selected_amount_cents == 2500, "the default preset should be $25")
|
_assert(screen.selected_amount_cents == 500, "the default preset should be $5")
|
||||||
_assert(screen.donate_button.text.contains("$25.00"), "the donation action should state the selected amount")
|
_assert(screen.donate_button.text.contains("$5.00"), "the donation action should state the selected amount")
|
||||||
screen.size = Vector2(760, 800)
|
screen.size = Vector2(760, 800)
|
||||||
screen._update_layout()
|
screen._update_layout()
|
||||||
_assert(screen.content_grid.columns == 1, "narrow donation layouts should stack")
|
_assert(screen.content_grid.columns == 1, "narrow donation layouts should stack")
|
||||||
@@ -34,6 +34,8 @@ func _run() -> void:
|
|||||||
await process_frame
|
await process_frame
|
||||||
var light_box := screen.mission_panel.get_theme_stylebox("panel") as StyleBoxFlat
|
var light_box := screen.mission_panel.get_theme_stylebox("panel") as StyleBoxFlat
|
||||||
_assert(light_box.bg_color.is_equal_approx(Color.WHITE), "donation cards should use light surfaces in light mode")
|
_assert(light_box.bg_color.is_equal_approx(Color.WHITE), "donation cards should use light surfaces in light mode")
|
||||||
|
_assert(screen.muted_labels[0].get_theme_color("font_color").is_equal_approx(Color("64748b")),
|
||||||
|
"secondary donation text should use the readable light-mode color")
|
||||||
host.queue_free()
|
host.queue_free()
|
||||||
await process_frame
|
await process_frame
|
||||||
theme_service.set_dark_mode(prior_dark_mode)
|
theme_service.set_dark_mode(prior_dark_mode)
|
||||||
|
|||||||
Reference in New Issue
Block a user