feat(accessibility): add reduceMotion scaling and minimize animations; apply RepaintBoundary to heavy widgets
This commit is contained in:
34
lib/utils/reduce_motion.dart
Normal file
34
lib/utils/reduce_motion.dart
Normal file
@@ -0,0 +1,34 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
/// 접근성 설정에 따른 모션 축소 여부 헬퍼
|
||||
class ReduceMotion {
|
||||
/// 플랫폼 접근성 설정을 기반으로 모션 축소 여부 반환 (context 없이 사용)
|
||||
static bool platform() {
|
||||
final features =
|
||||
WidgetsBinding.instance.platformDispatcher.accessibilityFeatures;
|
||||
// disableAnimations 신뢰
|
||||
return features.disableAnimations;
|
||||
}
|
||||
|
||||
/// MediaQuery/플랫폼 정보를 활용해 런타임에서 모션 축소 여부 반환
|
||||
static bool isEnabled(BuildContext context) {
|
||||
final mq = MediaQuery.maybeOf(context);
|
||||
if (mq != null) {
|
||||
// accessibleNavigation == 사용자가 단순한 네비게이션/애니메이션 선호
|
||||
if (mq.accessibleNavigation) return true;
|
||||
}
|
||||
return platform();
|
||||
}
|
||||
|
||||
/// 모션 강도 스케일 유틸리티
|
||||
static double scale(BuildContext context,
|
||||
{required double normal, required double reduced}) {
|
||||
return isEnabled(context) ? reduced : normal;
|
||||
}
|
||||
|
||||
/// 파티클 개수 등 정수 스케일링
|
||||
static int count(BuildContext context,
|
||||
{required int normal, required int reduced}) {
|
||||
return isEnabled(context) ? reduced : normal;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user