53 lines
1.5 KiB
Dart
53 lines
1.5 KiB
Dart
|
|
// packages/feature_common/lib/widgets/common_game_shell.dart
|
||
|
|
import 'package:flutter/material.dart';
|
||
|
|
import '../screens/ranking_screen.dart';
|
||
|
|
import '../screens/settings_screen.dart';
|
||
|
|
import 'ad_banner_widget.dart';
|
||
|
|
|
||
|
|
/// 모든 게임 앱이 공유하는 '공통 셸' 위젯
|
||
|
|
/// (AppBar, 설정/랭킹 버튼, 하단 광고 배너 포함)
|
||
|
|
class CommonGameShell extends StatelessWidget {
|
||
|
|
final Widget body;
|
||
|
|
final String title;
|
||
|
|
|
||
|
|
/// 랭킹 버튼을 눌렀을 때 실행될 함수 (외부 주입)
|
||
|
|
/// null을 전달하면 랭킹 버튼이 비활성화됩니다.
|
||
|
|
final VoidCallback? onRankingPressed;
|
||
|
|
|
||
|
|
const CommonGameShell({
|
||
|
|
super.key,
|
||
|
|
required this.body,
|
||
|
|
required this.title,
|
||
|
|
this.onRankingPressed,
|
||
|
|
});
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
return Scaffold(
|
||
|
|
appBar: AppBar(
|
||
|
|
title: Text(title),
|
||
|
|
actions: [
|
||
|
|
// 랭킹 버튼
|
||
|
|
IconButton(
|
||
|
|
icon: const Icon(Icons.leaderboard_outlined),
|
||
|
|
onPressed: onRankingPressed, // 👈 주입받은 함수 실행
|
||
|
|
),
|
||
|
|
// 설정 버튼
|
||
|
|
IconButton(
|
||
|
|
icon: const Icon(Icons.settings_outlined),
|
||
|
|
onPressed: () {
|
||
|
|
Navigator.push(
|
||
|
|
context,
|
||
|
|
MaterialPageRoute(
|
||
|
|
builder: (context) => const SettingsScreen(),
|
||
|
|
),
|
||
|
|
);
|
||
|
|
},
|
||
|
|
),
|
||
|
|
],
|
||
|
|
),
|
||
|
|
body: body, // 👈 주입받은 내용물
|
||
|
|
bottomNavigationBar: const AdBannerWidget(),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|