90 lines
2.2 KiB
Dart
90 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../constants/app_colors.dart';
|
|
|
|
/// 로딩 인디케이터 위젯
|
|
///
|
|
/// 앱 전체에서 일관된 로딩 표시를 위한 공통 위젯
|
|
class LoadingIndicator extends StatelessWidget {
|
|
/// 로딩 메시지 (선택사항)
|
|
final String? message;
|
|
|
|
/// 인디케이터 크기
|
|
final double size;
|
|
|
|
/// 스트로크 너비
|
|
final double strokeWidth;
|
|
|
|
const LoadingIndicator({
|
|
super.key,
|
|
this.message,
|
|
this.size = 40.0,
|
|
this.strokeWidth = 4.0,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final isDark = Theme.of(context).brightness == Brightness.dark;
|
|
|
|
return Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
SizedBox(
|
|
width: size,
|
|
height: size,
|
|
child: CircularProgressIndicator(
|
|
strokeWidth: strokeWidth,
|
|
valueColor: AlwaysStoppedAnimation<Color>(
|
|
isDark ? AppColors.darkPrimary : AppColors.lightPrimary,
|
|
),
|
|
),
|
|
),
|
|
if (message != null) ...[
|
|
const SizedBox(height: 16),
|
|
Text(
|
|
message!,
|
|
style: TextStyle(
|
|
fontSize: 14,
|
|
color: isDark
|
|
? AppColors.darkTextSecondary
|
|
: AppColors.lightTextSecondary,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
],
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// 전체 화면 로딩 인디케이터
|
|
///
|
|
/// 화면 전체를 덮는 로딩 표시를 위한 위젯
|
|
class FullScreenLoadingIndicator extends StatelessWidget {
|
|
/// 로딩 메시지 (선택사항)
|
|
final String? message;
|
|
|
|
/// 배경 투명도
|
|
final double backgroundOpacity;
|
|
|
|
const FullScreenLoadingIndicator({
|
|
super.key,
|
|
this.message,
|
|
this.backgroundOpacity = 0.5,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final isDark = Theme.of(context).brightness == Brightness.dark;
|
|
|
|
return Container(
|
|
color: (isDark ? Colors.black : Colors.white).withValues(
|
|
alpha: backgroundOpacity,
|
|
),
|
|
child: LoadingIndicator(message: message),
|
|
);
|
|
}
|
|
}
|