템플릿 테마를 앱 전체로 확장 - 제목 알약, 백품타, 모든 화면 배경/카드색
구조색 4종(mist/paper/linen/sage)을 const에서 뺀 뒤 AppPalette.applyTemplateTheme() 으로 템플릿 장착/해제 시 한 번에 바꿔치기하게 했다. 이 4개는 전부 "배경/카드/ 구분선" 용도로만 쓰이던 색이라, 장착 즉시 거의 모든 화면(백품타 포함, AppPalette.mist/ paper/sage를 쓰는 화면이면 코드 수정 없이 자동 반영)의 배경·카드·테두리가 테마를 따라간다. ink는 텍스트/버튼 등 너무 광범위하게 쓰여서 그대로 고정. 제목 알약(TitlePill, 24개 화면이 공유)은 ink를 직접 바꾸면 안 되므로 별도로 globalProfileTheme(ValueNotifier) 하나를 구독해서 배경을 theme.secondary로 바꾸게 했다 - 이 위젯 하나만 고쳐서 모든 화면의 제목 배경에 한 번에 적용. 백품타(study_timer_screen)는 시작/재개 버튼과 큰 타이머 숫자처럼 "중립" 요소만 테마 강조색(accent)으로 바꾸고, 일시정지(warning)/종료(danger) 같은 경고성 색은 의미가 있어서 그대로 뒀다. main_dashboard/profile_customize_screen은 실제로 장착이 바뀔 때마다 applyGlobalProfileTheme()을 호출해 위 두 전역 상태를 동기화한다. 구조색을 const에서 빼면서 기존에 const로 선언돼 있던 지점 몇 곳 (app_notice, device_checkout_ledger_page, group_detail_screen, main_dashboard, teacher_attendance_page)에서 const 컴파일 에러가 나서 해당 const 키워드만 제거해 수정했다.
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import '../function/profile_shop_controller.dart';
|
||||
import '../theme/app_palette.dart';
|
||||
import '../theme/profile_themes.dart';
|
||||
import '../theme/theme_sync.dart';
|
||||
import 'app_notice.dart';
|
||||
import 'title_pill.dart';
|
||||
|
||||
@@ -35,7 +36,21 @@ class _ProfileCustomizeScreenState extends State<ProfileCustomizeScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller.loadCatalog(widget.studentId);
|
||||
_initialize();
|
||||
}
|
||||
|
||||
/// 상점 화면을 열 때마다 서버의 실제 장착 상태로 전역 테마를 다시 맞춰둔다
|
||||
/// (딴 데서 장착 상태가 바뀌었을 수도 있는 엣지 케이스 보호용).
|
||||
Future<void> _initialize() async {
|
||||
await _controller.loadCatalog(widget.studentId);
|
||||
if (!mounted) return;
|
||||
for (final t in _controller.templates) {
|
||||
if (t.equipped) {
|
||||
_syncGlobalTheme(t.id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
_syncGlobalTheme(null);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -88,6 +103,7 @@ class _ProfileCustomizeScreenState extends State<ProfileCustomizeScreen> {
|
||||
widget.studentId,
|
||||
templateId,
|
||||
);
|
||||
if (success) _syncGlobalTheme(templateId);
|
||||
if (!mounted) return;
|
||||
AppNotice.show(
|
||||
context,
|
||||
@@ -96,6 +112,21 @@ class _ProfileCustomizeScreenState extends State<ProfileCustomizeScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
/// 💡 커스텀창 안에서의 "미리보기"와 달리, 실제로 장착이 끝난 뒤에는 앱 전체
|
||||
/// (TitlePill, 다른 화면의 배경/카드색)도 같이 바뀌도록 전역에 반영한다.
|
||||
void _syncGlobalTheme(int? equippedTemplateId) {
|
||||
if (equippedTemplateId == null) {
|
||||
applyGlobalProfileTheme(null);
|
||||
return;
|
||||
}
|
||||
for (final t in _controller.templates) {
|
||||
if (t.id == equippedTemplateId) {
|
||||
applyGlobalProfileTheme(profileThemes[t.code]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
|
||||
Reference in New Issue
Block a user