Simplify application header
This commit is contained in:
+3
-40
@@ -5,9 +5,7 @@ const Brand := preload("res://scripts/ui/medmind_style.gd")
|
||||
const NavigationRoutes := preload("res://scripts/ui/navigation_routes.gd")
|
||||
|
||||
var screens := {}
|
||||
var header_stats: Label
|
||||
var header_panel: PanelContainer
|
||||
var user_label: Label
|
||||
var app_menu: PanelContainer
|
||||
var menu_exit_button: Button
|
||||
var sound_toggle: CheckButton
|
||||
@@ -49,10 +47,6 @@ func _update_responsive_layout() -> void:
|
||||
if menu_button != null:
|
||||
menu_button.visible = AuthState.is_logged_in and compact_shell and _screen_uses_shell(current_screen_name)
|
||||
_apply_screen_margins(current_screen_name)
|
||||
if header_stats != null:
|
||||
header_stats.visible = size.x >= 720.0
|
||||
if user_label != null:
|
||||
user_label.visible = size.x >= 760.0
|
||||
if feedback_button != null:
|
||||
feedback_button.visible = AuthState.is_logged_in and size.x >= 560.0
|
||||
if account_chevron_button != null:
|
||||
@@ -148,19 +142,6 @@ func _build_ui() -> void:
|
||||
header_spacer.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
header.add_child(header_spacer)
|
||||
|
||||
header_stats = Label.new()
|
||||
header_stats.name = "HeaderStats"
|
||||
Style.set_label(header_stats, 15, Style.MUTED)
|
||||
header_stats.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
||||
header_stats.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||
header.add_child(header_stats)
|
||||
|
||||
user_label = Label.new()
|
||||
Style.set_label(user_label, 15, Style.CYAN)
|
||||
user_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
||||
user_label.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||
header.add_child(user_label)
|
||||
|
||||
feedback_button = Button.new()
|
||||
feedback_button.text = "Feedback"
|
||||
feedback_button.tooltip_text = "Send general feedback or report a bug"
|
||||
@@ -307,10 +288,8 @@ func _build_ui() -> void:
|
||||
_build_account_menu()
|
||||
_build_drawer()
|
||||
|
||||
ProfileService.profile_changed.connect(_refresh_header_stats)
|
||||
QuestionBankService.ratings_changed.connect(_refresh_header_stats)
|
||||
AuthState.auth_changed.connect(_refresh_header_stats)
|
||||
_refresh_header_stats()
|
||||
AuthState.auth_changed.connect(_refresh_header_controls)
|
||||
_refresh_header_controls()
|
||||
_build_app_menu()
|
||||
|
||||
|
||||
@@ -636,12 +615,7 @@ func _input(event: InputEvent) -> void:
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
|
||||
func _refresh_header_stats() -> void:
|
||||
if header_stats == null:
|
||||
return
|
||||
header_stats.text = "Rating: %d" % QuestionBankService.overall_elo
|
||||
if user_label != null:
|
||||
user_label.text = AuthState.role.to_upper() if AuthState.is_logged_in and not AuthState.role.is_empty() else ""
|
||||
func _refresh_header_controls() -> void:
|
||||
if account_button != null:
|
||||
account_button.text = _account_initials(AuthState.username)
|
||||
if feedback_button != null:
|
||||
@@ -820,14 +794,3 @@ func _open_profile_from_menu() -> void:
|
||||
elif BlockSessionService.session_kind == "simulation":
|
||||
BlockSessionService.block_started = false
|
||||
show_screen("profile")
|
||||
|
||||
|
||||
func _on_user_label_gui_input(event: InputEvent) -> void:
|
||||
if not AuthState.is_logged_in:
|
||||
return
|
||||
var mouse_event := event as InputEventMouseButton
|
||||
if mouse_event == null or mouse_event.button_index != MOUSE_BUTTON_LEFT or not mouse_event.pressed:
|
||||
return
|
||||
_close_app_menu()
|
||||
if current_screen_name != "profile":
|
||||
show_screen("profile")
|
||||
|
||||
@@ -372,7 +372,11 @@ func _build_history_row(summary: Dictionary) -> Control:
|
||||
_add_table_cell(row, _plain_cell("%d / %d" % [completed_blocks(summary), int(summary.get("totalBlocks", 12))], dark), 0.8)
|
||||
_add_table_cell(row, _plain_cell(_score_text(summary), dark), 1.15)
|
||||
_add_table_cell(row, _plain_cell(_pass_chance_text(summary), dark), 1.0)
|
||||
var action: Control = _review_button(summary, dark) if state == "completed" else _plain_cell("—", dark)
|
||||
var action: Control
|
||||
if state == "completed":
|
||||
action = _review_button(summary, dark)
|
||||
else:
|
||||
action = _plain_cell("-", dark)
|
||||
_add_table_cell(row, action, 1.0)
|
||||
return panel
|
||||
|
||||
|
||||
@@ -41,7 +41,8 @@ func _run() -> void:
|
||||
_assert(main_screen.theme_button.custom_minimum_size == Vector2(44, 44), "the theme toggle should keep a stable square footprint")
|
||||
_assert(main_screen.theme_button.size.x >= 44.0 and main_screen.theme_button.size.y >= 44.0, "the theme toggle should not collapse into an oval")
|
||||
_assert(main_screen.theme_button.icon_alignment == HORIZONTAL_ALIGNMENT_CENTER, "the theme toggle icon should remain centered")
|
||||
_assert(not main_screen.user_label.visible and not main_screen.account_chevron_button.visible, "nonessential account controls should collapse on phone-width headers")
|
||||
_assert(main_screen.header_panel.find_child("HeaderStats", true, false) == null, "the application header should not display rating or role labels")
|
||||
_assert(not main_screen.account_chevron_button.visible, "nonessential account controls should collapse on phone-width headers")
|
||||
|
||||
host.queue_free()
|
||||
await process_frame
|
||||
|
||||
Reference in New Issue
Block a user