1
0
forked from baron/baron-sso

활성 RP 홈페이지 이동 기능 추가

This commit is contained in:
2026-02-04 11:20:25 +09:00
parent 12b3d21da6
commit 3de77ef681

View File

@@ -4,6 +4,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../../../core/notifiers/auth_notifier.dart'; import '../../../../core/notifiers/auth_notifier.dart';
import '../../../../core/services/auth_token_store.dart'; import '../../../../core/services/auth_token_store.dart';
import '../../../../core/services/http_client.dart'; import '../../../../core/services/http_client.dart';
@@ -106,6 +107,7 @@ class LinkedRp {
final String id; final String id;
final String name; final String name;
final String logo; final String logo;
final String url;
final String status; final String status;
final List<String> scopes; final List<String> scopes;
final DateTime? lastAuthenticatedAt; final DateTime? lastAuthenticatedAt;
@@ -114,6 +116,7 @@ class LinkedRp {
required this.id, required this.id,
required this.name, required this.name,
required this.logo, required this.logo,
required this.url,
required this.status, required this.status,
required this.scopes, required this.scopes,
required this.lastAuthenticatedAt, required this.lastAuthenticatedAt,
@@ -134,6 +137,7 @@ class LinkedRp {
id: json['id']?.toString() ?? '', id: json['id']?.toString() ?? '',
name: json['name']?.toString() ?? '', name: json['name']?.toString() ?? '',
logo: json['logo']?.toString() ?? '', logo: json['logo']?.toString() ?? '',
url: json['url']?.toString() ?? '',
status: json['status']?.toString() ?? '', status: json['status']?.toString() ?? '',
scopes: (json['scopes'] as List?)?.whereType<String>().toList() ?? [], scopes: (json['scopes'] as List?)?.whereType<String>().toList() ?? [],
lastAuthenticatedAt: parsedLastAuth, lastAuthenticatedAt: parsedLastAuth,
@@ -887,6 +891,7 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
canLogout: false, canLogout: false,
isRevoked: isRevoked, isRevoked: isRevoked,
onRevoke: isRevoked ? null : () => _onRevokeLink(rp.id, name), onRevoke: isRevoked ? null : () => _onRevokeLink(rp.id, name),
url: rp.url, // URL 전달
), ),
); );
} }
@@ -945,96 +950,135 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
final borderColor = isActive ? Colors.green.withOpacity(0.5) : _border; final borderColor = isActive ? Colors.green.withOpacity(0.5) : _border;
final borderWidth = isActive ? 1.5 : 1.0; final borderWidth = isActive ? 1.5 : 1.0;
return Opacity( // 활성 상태면 클릭 가능 (URL 유무와 관계없이)
opacity: item.isRevoked ? 0.6 : 1.0, final isClickable = isActive;
child: Container(
width: 260, // 카드 컨텐츠
padding: const EdgeInsets.all(16), final cardContent = Container(
decoration: BoxDecoration( width: 260,
color: _surface, padding: const EdgeInsets.all(16),
borderRadius: BorderRadius.circular(14), decoration: BoxDecoration(
border: Border.all(color: borderColor, width: borderWidth), color: _surface,
boxShadow: isActive ? [ borderRadius: BorderRadius.circular(14),
BoxShadow( border: Border.all(color: borderColor, width: borderWidth),
color: Colors.green.withOpacity(0.05), boxShadow: isActive ? [
blurRadius: 10, BoxShadow(
offset: const Offset(0, 4), color: Colors.green.withOpacity(0.05),
) blurRadius: 10,
] : null, offset: const Offset(0, 4),
), )
child: Column( ] : null,
crossAxisAlignment: CrossAxisAlignment.start, ),
children: [ child: Column(
Row( crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Expanded( Row(
child: Text( children: [
item.appName, Expanded(
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: _ink), child: Text(
), item.appName,
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: _ink),
), ),
Container( ),
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), Container(
decoration: BoxDecoration( padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
color: statusColor.withOpacity(0.12), decoration: BoxDecoration(
borderRadius: BorderRadius.circular(999), color: statusColor.withOpacity(0.12),
), borderRadius: BorderRadius.circular(999),
child: Text(
item.status,
style: TextStyle(fontSize: 11, color: statusColor, fontWeight: FontWeight.w600),
),
), ),
], child: Text(
), item.status,
const SizedBox(height: 12), style: TextStyle(fontSize: 11, color: statusColor, fontWeight: FontWeight.w600),
Text( ),
'최근 인증', ),
style: TextStyle(fontSize: 12, color: Colors.grey[600]), ],
), ),
const SizedBox(height: 4), const SizedBox(height: 12),
Text( Text(
item.lastAuthAt, '최근 인증',
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: _ink), style: TextStyle(fontSize: 12, color: Colors.grey[600]),
), ),
const SizedBox(height: 16), const SizedBox(height: 4),
Row( Text(
children: [ item.lastAuthAt,
if (item.canLogout) style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: _ink),
Expanded( ),
child: OutlinedButton( const SizedBox(height: 16),
onPressed: item.onLogout, Row(
style: OutlinedButton.styleFrom( children: [
foregroundColor: _ink, if (item.canLogout)
side: const BorderSide(color: _border),
padding: const EdgeInsets.symmetric(vertical: 8),
),
child: const Text('로그아웃', style: TextStyle(fontSize: 13)),
),
),
if (item.canLogout) const SizedBox(width: 8),
Expanded( Expanded(
child: OutlinedButton( child: OutlinedButton(
onPressed: (_isRevoking || item.isRevoked) ? null : item.onRevoke, onPressed: item.onLogout,
style: OutlinedButton.styleFrom( style: OutlinedButton.styleFrom(
foregroundColor: item.isRevoked ? Colors.grey : Colors.redAccent, foregroundColor: _ink,
side: BorderSide(color: item.isRevoked ? Colors.grey : Colors.redAccent, width: 0.5), side: const BorderSide(color: _border),
padding: const EdgeInsets.symmetric(vertical: 8), padding: const EdgeInsets.symmetric(vertical: 8),
), ),
child: _isRevoking && !item.isRevoked child: const Text('로그아웃', style: TextStyle(fontSize: 13)),
? const SizedBox(
width: 14,
height: 14,
child: CircularProgressIndicator(strokeWidth: 2, color: Colors.redAccent),
)
: Text(item.isRevoked ? '해지됨' : '연동 해지', style: const TextStyle(fontSize: 13)),
), ),
), ),
], if (item.canLogout) const SizedBox(width: 8),
), Expanded(
], child: OutlinedButton(
), onPressed: (_isRevoking || item.isRevoked) ? null : item.onRevoke,
style: OutlinedButton.styleFrom(
foregroundColor: item.isRevoked ? Colors.grey : Colors.redAccent,
side: BorderSide(color: item.isRevoked ? Colors.grey : Colors.redAccent, width: 0.5),
padding: const EdgeInsets.symmetric(vertical: 8),
),
child: _isRevoking && !item.isRevoked
? const SizedBox(
width: 14,
height: 14,
child: CircularProgressIndicator(strokeWidth: 2, color: Colors.redAccent),
)
: Text(item.isRevoked ? '해지됨' : '연동 해지', style: const TextStyle(fontSize: 13)),
),
),
],
),
],
), ),
); );
// Opacity 적용
final opaqueCard = Opacity(
opacity: item.isRevoked ? 0.6 : 1.0,
child: cardContent,
);
// 클릭 가능한 경우 InkWell로 감싸기
if (isClickable) {
return MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
onTap: () async {
if (item.url != null && item.url!.isNotEmpty) {
final uri = Uri.parse(item.url!);
if (await canLaunchUrl(uri)) {
await launchUrl(uri);
} else {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('해당 링크를 열 수 없습니다.')),
);
}
}
} else {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('이동할 페이지 주소(Client URI)가 설정되지 않았습니다.')),
);
}
}
},
child: opaqueCard,
),
);
}
return opaqueCard;
} }
Widget _buildAccessHistory(bool isWide) { Widget _buildAccessHistory(bool isWide) {
@@ -1232,6 +1276,7 @@ class _ActivityItem {
final String appName; final String appName;
final String lastAuthAt; final String lastAuthAt;
final String status; final String status;
final String? url;
final bool canLogout; final bool canLogout;
final bool isRevoked; final bool isRevoked;
final VoidCallback? onLogout; final VoidCallback? onLogout;
@@ -1243,6 +1288,7 @@ class _ActivityItem {
required this.lastAuthAt, required this.lastAuthAt,
required this.status, required this.status,
required this.canLogout, required this.canLogout,
this.url,
this.isRevoked = false, this.isRevoked = false,
this.onLogout, this.onLogout,
this.onRevoke, this.onRevoke,