구조색 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 키워드만 제거해 수정했다.
172 lines
4.5 KiB
Dart
172 lines
4.5 KiB
Dart
// 🔔 스낵바 대신 쓰는 알약(pill) 모양 알림. 기능 타일을 누를 때 뜨는
|
|
// "OO로 이동합니다" 같은 짧은 안내용. 푸시 알림(FCM)과는 무관 — 그건 그대로 동작한다.
|
|
// 웹에서는 왼쪽 위(알림창 자리)에, 폰 앱에서는 기존 스낵바처럼 아래쪽에 뜬다.
|
|
import 'package:flutter/foundation.dart' show kIsWeb;
|
|
import 'package:flutter/material.dart';
|
|
import '../theme/app_palette.dart';
|
|
|
|
class AppNotice {
|
|
static final List<_QueuedNotice> _queue = [];
|
|
static bool _showing = false;
|
|
|
|
static void show(
|
|
BuildContext context,
|
|
String message, {
|
|
IconData? icon,
|
|
Color? color,
|
|
}) {
|
|
_queue.add(_QueuedNotice(context, message, icon, color));
|
|
_tryShowNext();
|
|
}
|
|
|
|
static void _tryShowNext() {
|
|
if (_showing || _queue.isEmpty) return;
|
|
final next = _queue.removeAt(0);
|
|
if (!next.context.mounted) {
|
|
_tryShowNext();
|
|
return;
|
|
}
|
|
_showing = true;
|
|
final overlay = Overlay.of(next.context);
|
|
late OverlayEntry entry;
|
|
entry = OverlayEntry(
|
|
builder: (context) => _NoticeBanner(
|
|
message: next.message,
|
|
icon: next.icon,
|
|
color: next.color,
|
|
onDone: () {
|
|
entry.remove();
|
|
_showing = false;
|
|
_tryShowNext();
|
|
},
|
|
),
|
|
);
|
|
overlay.insert(entry);
|
|
}
|
|
}
|
|
|
|
class _QueuedNotice {
|
|
final BuildContext context;
|
|
final String message;
|
|
final IconData? icon;
|
|
final Color? color;
|
|
_QueuedNotice(this.context, this.message, this.icon, this.color);
|
|
}
|
|
|
|
class _NoticeBanner extends StatefulWidget {
|
|
final String message;
|
|
final IconData? icon;
|
|
final Color? color;
|
|
final VoidCallback onDone;
|
|
|
|
const _NoticeBanner({
|
|
required this.message,
|
|
required this.icon,
|
|
required this.color,
|
|
required this.onDone,
|
|
});
|
|
|
|
@override
|
|
State<_NoticeBanner> createState() => _NoticeBannerState();
|
|
}
|
|
|
|
class _NoticeBannerState extends State<_NoticeBanner>
|
|
with SingleTickerProviderStateMixin {
|
|
late final AnimationController _controller;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_controller = AnimationController(
|
|
vsync: this,
|
|
duration: const Duration(milliseconds: 220),
|
|
reverseDuration: const Duration(milliseconds: 180),
|
|
);
|
|
_controller.forward();
|
|
Future.delayed(const Duration(milliseconds: 2600), () async {
|
|
if (!mounted) return;
|
|
await _controller.reverse();
|
|
widget.onDone();
|
|
});
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_controller.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final curved = CurvedAnimation(
|
|
parent: _controller,
|
|
curve: Curves.easeOutCubic,
|
|
reverseCurve: Curves.easeInCubic,
|
|
);
|
|
final media = MediaQuery.of(context);
|
|
|
|
final pill = Material(
|
|
color: Colors.transparent,
|
|
child: Container(
|
|
constraints: const BoxConstraints(maxWidth: 360),
|
|
padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 14),
|
|
decoration: BoxDecoration(
|
|
color: widget.color ?? AppPalette.ink,
|
|
borderRadius: BorderRadius.circular(999),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withValues(alpha: 0.25),
|
|
blurRadius: 16,
|
|
offset: const Offset(0, 6),
|
|
),
|
|
],
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
if (widget.icon != null) ...[
|
|
Icon(widget.icon, color: AppPalette.paper, size: 18),
|
|
const SizedBox(width: 8),
|
|
],
|
|
Flexible(
|
|
child: Text(
|
|
widget.message,
|
|
style: TextStyle(
|
|
color: AppPalette.paper,
|
|
fontSize: 13.5,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
|
|
final animatedPill = FadeTransition(
|
|
opacity: curved,
|
|
child: SlideTransition(
|
|
position: Tween<Offset>(
|
|
begin: kIsWeb ? const Offset(0, -0.3) : const Offset(0, 0.3),
|
|
end: Offset.zero,
|
|
).animate(curved),
|
|
child: pill,
|
|
),
|
|
);
|
|
|
|
if (kIsWeb) {
|
|
return Positioned(
|
|
top: media.padding.top + 16,
|
|
left: 16,
|
|
child: IgnorePointer(child: animatedPill),
|
|
);
|
|
}
|
|
return Positioned(
|
|
left: 16,
|
|
right: 16,
|
|
bottom: media.padding.bottom + 24,
|
|
child: IgnorePointer(child: Center(child: animatedPill)),
|
|
);
|
|
}
|
|
}
|