Add live RZ Points balance widget to question and shell headers
Wires the recently-merged question-completion-credits backend (GET /api/credits) into the client for the first time: a new CreditsService autoload fetches/caches the balance, and the embedded credits field on first-answer responses updates it instantly with no extra round trip. A shared CreditsBadge widget (star icon, balance, decorative chevron per mockup) surfaces it in both the question screen toolbar and the main shell header. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
@@ -3,6 +3,7 @@ extends Control
|
||||
const Style := preload("res://scripts/ui/ui_style.gd")
|
||||
const Brand := preload("res://scripts/ui/medmind_style.gd")
|
||||
const NavigationRoutes := preload("res://scripts/ui/navigation_routes.gd")
|
||||
const CreditsBadge := preload("res://scripts/ui/credits_badge.gd")
|
||||
|
||||
var screens := {}
|
||||
var _account_profile_synced := false
|
||||
@@ -29,6 +30,7 @@ var drawer_open := false
|
||||
var menu_button: Button
|
||||
var account_button: Button
|
||||
var account_chevron_button: Button
|
||||
var credits_badge: PanelContainer
|
||||
var account_menu: PanelContainer
|
||||
var nav_buttons: Dictionary = {}
|
||||
var current_nav_key := "home"
|
||||
@@ -204,6 +206,9 @@ func _build_ui() -> void:
|
||||
_style_account_chevron(account_chevron_button)
|
||||
header.add_child(account_chevron_button)
|
||||
|
||||
credits_badge = CreditsBadge.new()
|
||||
header.add_child(credits_badge)
|
||||
|
||||
var screens_container := MarginContainer.new()
|
||||
screens_margin = screens_container
|
||||
screens_host = screens_container
|
||||
@@ -769,6 +774,7 @@ func _on_auth_changed() -> void:
|
||||
if not _account_profile_synced:
|
||||
_account_profile_synced = true
|
||||
AccountProfileService.refresh()
|
||||
CreditsService.refresh()
|
||||
else:
|
||||
_account_profile_synced = false
|
||||
if AuthState.is_logged_in and AuthState.requires_legal_acceptance and current_screen_name not in ["login", "legal_consent"]:
|
||||
@@ -797,6 +803,8 @@ func _on_theme_changed(is_dark_mode: bool) -> void:
|
||||
_style_account_avatar(account_button)
|
||||
if account_chevron_button != null:
|
||||
_style_account_chevron(account_chevron_button)
|
||||
if credits_badge != null:
|
||||
credits_badge.refresh_theme_controls()
|
||||
if sidebar != null:
|
||||
sidebar.add_theme_stylebox_override("panel", _sidebar_box())
|
||||
if header_panel != null:
|
||||
|
||||
Reference in New Issue
Block a user