feat(permissions): add SMS permission screen and settings button; route from splash on Android
This commit is contained in:
@@ -12,6 +12,8 @@ import '../widgets/native_ad_widget.dart';
|
||||
import '../widgets/common/snackbar/app_snackbar.dart';
|
||||
import '../l10n/app_localizations.dart';
|
||||
import '../providers/locale_provider.dart';
|
||||
import 'package:permission_handler/permission_handler.dart' as permission;
|
||||
import '../services/sms_service.dart';
|
||||
|
||||
class SettingsScreen extends StatelessWidget {
|
||||
const SettingsScreen({super.key});
|
||||
@@ -476,6 +478,60 @@ class SettingsScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
|
||||
// SMS 권한 설정
|
||||
if (!kIsWeb && Platform.isAndroid)
|
||||
GlassmorphismCard(
|
||||
margin:
|
||||
const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: FutureBuilder<bool>(
|
||||
future: SMSService.hasSMSPermission(),
|
||||
builder: (context, snapshot) {
|
||||
final hasPermission = snapshot.data ?? false;
|
||||
return ListTile(
|
||||
leading: const Icon(
|
||||
Icons.sms,
|
||||
color: AppColors.textSecondary,
|
||||
),
|
||||
title: const Text(
|
||||
'SMS 권한',
|
||||
style: TextStyle(color: AppColors.textPrimary),
|
||||
),
|
||||
subtitle: Text(
|
||||
AppLocalizations.of(context).smsPermissionRequired,
|
||||
style:
|
||||
const TextStyle(color: AppColors.textSecondary),
|
||||
),
|
||||
trailing: hasPermission
|
||||
? const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: Icon(Icons.check_circle,
|
||||
color: Colors.green),
|
||||
)
|
||||
: ElevatedButton(
|
||||
onPressed: () async {
|
||||
final granted =
|
||||
await SMSService.requestSMSPermission();
|
||||
if (!granted) {
|
||||
final status =
|
||||
await permission.Permission.sms.status;
|
||||
if (status.isPermanentlyDenied) {
|
||||
await permission.openAppSettings();
|
||||
}
|
||||
}
|
||||
if (context.mounted) {
|
||||
// 상태 갱신을 위해 다시 build 트리거
|
||||
(context as Element).markNeedsBuild();
|
||||
}
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)
|
||||
.requestPermission),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
// 앱 정보
|
||||
GlassmorphismCard(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
|
||||
Reference in New Issue
Block a user