241 lines
8.5 KiB
Dart
241 lines
8.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'setting_page.dart';
|
|
import 'instruction_page.dart';
|
|
import 'start_page.dart';
|
|
import 'stats_page.dart';
|
|
import 'utils/audio_manager.dart';
|
|
|
|
class LandingPage extends StatefulWidget {
|
|
final Function()? onStart;
|
|
final Function()? onStats;
|
|
|
|
LandingPage({required this.onStart, required this.onStats, Key? key}): super(key: key);
|
|
|
|
@override
|
|
_LandingPageState createState() => _LandingPageState();
|
|
}
|
|
|
|
class _LandingPageState extends State<LandingPage> {
|
|
bool isMusicPlaying = true;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
AudioManager.initAudio();
|
|
AudioManager.instance.startBackgroundMusic();
|
|
AudioManager.instance.setSoundEnabled(true);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: Container(
|
|
decoration: const BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage('assets/images/background.jpg'),
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
child: Stack(
|
|
children: [
|
|
// Tombol Info dan Setting di pojok kanan atas
|
|
Positioned(
|
|
top: 20,
|
|
right: 30,
|
|
child: Row(
|
|
children: [
|
|
|
|
GestureDetector(
|
|
onTap: () {
|
|
AudioManager.playClickSound();
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(builder: (context) => SettingsPage()),
|
|
);
|
|
},
|
|
child: SizedBox(
|
|
width: 40,
|
|
height: 40,
|
|
child: Image.asset(
|
|
'assets/icons/profile.png',
|
|
fit: BoxFit.contain,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
|
|
Positioned(
|
|
top: 20,
|
|
left: 30,
|
|
child: Row(
|
|
children: [
|
|
GestureDetector(
|
|
onTap: () {
|
|
AudioManager.playClickSound();
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => const InstructionsPage()),
|
|
);
|
|
},
|
|
child: SizedBox(
|
|
width: 40,
|
|
height: 40,
|
|
child: Image.asset(
|
|
'assets/icons/info.png',
|
|
fit: BoxFit.contain,
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(width: 5),
|
|
GestureDetector(
|
|
onTap: () {
|
|
AudioManager.playClickSound();
|
|
setState(() {
|
|
isMusicPlaying = !isMusicPlaying;
|
|
if (isMusicPlaying) {
|
|
AudioManager.instance.startBackgroundMusic();
|
|
} else {
|
|
AudioManager.stopBackgroundMusic();
|
|
}
|
|
});
|
|
},
|
|
child: Container(
|
|
width: 40,
|
|
height: 40,
|
|
child: Image.asset(
|
|
isMusicPlaying
|
|
? 'assets/icons/music.png'
|
|
: 'assets/icons/music_off.png',
|
|
fit: BoxFit.contain,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
|
|
// Konten Tengah
|
|
Align(
|
|
alignment: const Alignment(0, -0.2),
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
// Judul Game (misalnya "HEIRNUSA")
|
|
Container(
|
|
width: 250,
|
|
height: 170,
|
|
decoration: const BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage('assets/icons/title_game.png'),
|
|
fit: BoxFit.fill,
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 25),
|
|
|
|
// Tombol Start
|
|
Container(
|
|
width: 300,
|
|
height: 75,
|
|
decoration: BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage('assets/icons/button.png'),
|
|
fit: BoxFit.contain,
|
|
),
|
|
),
|
|
child: ElevatedButton(
|
|
onPressed: () {
|
|
AudioManager.playClickSound();
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => StartPage(
|
|
onKingdomSelected: (kingdom) {
|
|
print('Kerajaan yang dipilih: $kingdom');
|
|
},
|
|
),
|
|
),
|
|
);
|
|
},
|
|
style: ButtonStyle(
|
|
minimumSize:
|
|
MaterialStateProperty.all(const Size(0, 0)),
|
|
backgroundColor:
|
|
MaterialStateProperty.all(Colors.transparent),
|
|
elevation: MaterialStateProperty.all(0),
|
|
shape:
|
|
MaterialStateProperty.all(RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.zero,
|
|
)),
|
|
overlayColor:
|
|
MaterialStateProperty.all(Colors.transparent),
|
|
),
|
|
child: const Text(
|
|
'MULAI',
|
|
style: TextStyle(
|
|
color: Color.fromARGB(255, 103, 75, 47),
|
|
fontFamily: 'Bestime',
|
|
fontSize: 15,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 15),
|
|
|
|
Container(
|
|
width: 300,
|
|
height: 75,
|
|
decoration: BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage('assets/icons/button.png'),
|
|
fit: BoxFit.contain,
|
|
),
|
|
),
|
|
child: ElevatedButton(
|
|
onPressed: () {
|
|
AudioManager.playClickSound();
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => StatsPage(),
|
|
),
|
|
);
|
|
},
|
|
style: ButtonStyle(
|
|
minimumSize:
|
|
MaterialStateProperty.all(const Size(0, 0)),
|
|
backgroundColor:
|
|
MaterialStateProperty.all(Colors.transparent),
|
|
elevation: MaterialStateProperty.all(0),
|
|
shape:
|
|
MaterialStateProperty.all(RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.zero,
|
|
)),
|
|
overlayColor:
|
|
MaterialStateProperty.all(Colors.transparent),
|
|
),
|
|
child: const Text(
|
|
'STATISTIK',
|
|
style: TextStyle(
|
|
color: Color.fromARGB(255, 103, 75, 47),
|
|
fontFamily: 'Bestime',
|
|
fontSize: 13,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|