250 lines
9.4 KiB
Dart
250 lines
9.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'utils/level_manager.dart';
|
|
import 'game/level1_islam.dart';
|
|
import 'game/level2_islam.dart';
|
|
import 'game/level3_islam.dart';
|
|
import 'utils/audio_manager.dart';
|
|
|
|
class IslamLevelPage extends StatefulWidget {
|
|
const IslamLevelPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<IslamLevelPage> createState() => _IslamLevelPageState();
|
|
}
|
|
|
|
class _IslamLevelPageState extends State<IslamLevelPage> {
|
|
bool isLevel1Completed = false;
|
|
bool isLevel2Completed = false;
|
|
bool isLevel3Completed = false;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_loadLevelStatus();
|
|
}
|
|
|
|
Future<void> _loadLevelStatus() async {
|
|
final level1Status = await LevelManager.isLevelCompleted(1, 'islam');
|
|
final level2Status = await LevelManager.isLevelCompleted(2, 'islam');
|
|
final level3Status = await LevelManager.isLevelCompleted(3, 'islam');
|
|
|
|
setState(() {
|
|
isLevel1Completed = level1Status;
|
|
isLevel2Completed = level2Status;
|
|
isLevel3Completed = level3Status;
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: Container(
|
|
decoration: const BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage('assets/images/background.jpg'),
|
|
fit: BoxFit.cover, // Menutupi seluruh layar
|
|
),
|
|
),
|
|
child: Stack(
|
|
children: [
|
|
|
|
// Tombol Setting dan Petunjuk
|
|
Positioned(
|
|
top: 10,
|
|
right: 10,
|
|
child: IconButton(
|
|
icon: Image.asset(
|
|
'assets/icons/exit.png',
|
|
width: 40,
|
|
height: 40,
|
|
),
|
|
onPressed: () {
|
|
AudioManager.playClickSound();
|
|
Navigator.pop(context);
|
|
},
|
|
),
|
|
),
|
|
|
|
// Konten Utama
|
|
Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage('assets/icons/title_small.png'),
|
|
fit: BoxFit.cover,
|
|
),
|
|
// Opsional: tambahkan border radius jika ingin sudut melengkung
|
|
borderRadius: BorderRadius.circular(10),
|
|
),
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal:48, vertical: 15),
|
|
child: Text(
|
|
'ISLAM',
|
|
style: TextStyle(
|
|
fontSize: 25,
|
|
fontFamily: 'Bestime',
|
|
color: Color.fromARGB(225, 193,138,83),
|
|
// Opsional: tambahkan shadow jika teks kurang terlihat
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 30),
|
|
|
|
// Level 1
|
|
Container(
|
|
width: 300,
|
|
height: 70,
|
|
decoration: BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage('assets/icons/button.png'),
|
|
fit: BoxFit.contain,
|
|
),
|
|
),
|
|
child: ElevatedButton(
|
|
onPressed: () {
|
|
AudioManager.playClickSound();
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => const Level1Islam(),
|
|
),
|
|
);
|
|
},
|
|
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(
|
|
'Level 1',
|
|
style: TextStyle(
|
|
color: Color.fromARGB(255, 103, 75, 47),
|
|
fontFamily: 'Bestime',
|
|
fontSize: 14,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 20),
|
|
|
|
// Level 2
|
|
Container(
|
|
width: 300,
|
|
height: 70,
|
|
decoration: BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage('assets/icons/button.png'),
|
|
fit: BoxFit.contain,
|
|
),
|
|
),
|
|
child: ElevatedButton(
|
|
onPressed: isLevel1Completed? () {
|
|
AudioManager.playClickSound();
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => const Level2Islam(),
|
|
),
|
|
);
|
|
}
|
|
: null,
|
|
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: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Text(
|
|
'Level 2',
|
|
style: TextStyle(
|
|
color: isLevel1Completed ? Color.fromARGB(255, 103, 75, 47) : Color.fromARGB(255, 103, 75, 47).withOpacity(0.5),
|
|
fontFamily: 'Bestime',
|
|
fontSize: 14,
|
|
),
|
|
),
|
|
if (!isLevel1Completed)
|
|
Icon(
|
|
Icons.lock,
|
|
color: Colors.white.withOpacity(0.7),
|
|
size: 24,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 20),
|
|
|
|
// Level 3
|
|
Container(
|
|
width: 300,
|
|
height: 70,
|
|
decoration: BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage('assets/icons/button.png'),
|
|
fit: BoxFit.contain,
|
|
),
|
|
),
|
|
child: ElevatedButton(
|
|
onPressed: isLevel2Completed? () {
|
|
AudioManager.playClickSound();
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => const Level3Islam(),
|
|
),
|
|
);
|
|
}
|
|
: null,
|
|
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: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Text(
|
|
'Level 3',
|
|
style: TextStyle(
|
|
color: isLevel2Completed ? Color.fromARGB(255, 103, 75, 47) : Color.fromARGB(255, 103, 75, 47).withOpacity(0.5),
|
|
fontFamily: 'Bestime',
|
|
fontSize: 14,
|
|
),
|
|
),
|
|
if (!isLevel2Completed)
|
|
Icon(
|
|
Icons.lock,
|
|
color: Colors.white.withOpacity(0.7),
|
|
size: 24,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|