Upload project absensi

This commit is contained in:
quryamelia 2026-07-28 13:43:34 +07:00
commit 1775688e35
156 changed files with 11704 additions and 0 deletions

45
.gitignore vendored Normal file
View File

@ -0,0 +1,45 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.build/
.buildlog/
.history
.svn/
.swiftpm/
migrate_working_dir/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/
/coverage/
# Symbolication related
app.*.symbols
# Obfuscation related
app.*.map.json
# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release

45
.metadata Normal file
View File

@ -0,0 +1,45 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.
version:
revision: "adc901062556672b4138e18a4dc62a4be8f4b3c2"
channel: "stable"
project_type: app
# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: adc901062556672b4138e18a4dc62a4be8f4b3c2
base_revision: adc901062556672b4138e18a4dc62a4be8f4b3c2
- platform: android
create_revision: adc901062556672b4138e18a4dc62a4be8f4b3c2
base_revision: adc901062556672b4138e18a4dc62a4be8f4b3c2
- platform: ios
create_revision: adc901062556672b4138e18a4dc62a4be8f4b3c2
base_revision: adc901062556672b4138e18a4dc62a4be8f4b3c2
- platform: linux
create_revision: adc901062556672b4138e18a4dc62a4be8f4b3c2
base_revision: adc901062556672b4138e18a4dc62a4be8f4b3c2
- platform: macos
create_revision: adc901062556672b4138e18a4dc62a4be8f4b3c2
base_revision: adc901062556672b4138e18a4dc62a4be8f4b3c2
- platform: web
create_revision: adc901062556672b4138e18a4dc62a4be8f4b3c2
base_revision: adc901062556672b4138e18a4dc62a4be8f4b3c2
- platform: windows
create_revision: adc901062556672b4138e18a4dc62a4be8f4b3c2
base_revision: adc901062556672b4138e18a4dc62a4be8f4b3c2
# User provided section
# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'

144
CRASH_FIX_GUIDE.md Normal file
View File

@ -0,0 +1,144 @@
# 📱 Fix Crash APK di Android 13 Vivo
## 🔍 Penyebab Crash Ditemukan:
### 1. **Missing Permission: SCHEDULE_EXACT_ALARM** ❌ → ✅
- **Masalah**: Background service & notification crash karena permission tidak dideklarasikan
- **Solusi**: Tambah permission di `AndroidManifest.xml`
```xml
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
```
### 2. **Runtime Permission POST_NOTIFICATIONS** ❌ → ✅
- **Masalah**: Android 13+ memerlukan runtime permission untuk POST_NOTIFICATIONS
- **Solusi**: Tambah permission handler & request saat app launch
```dart
if (Platform.isAndroid) {
await Permission.notification.request();
await Permission.scheduleExactAlarm.request();
}
```
### 3. **Double Firebase Initialization** ❌ → ✅
- **Masalah**: Firebase diinit di main() DAN di onStart() → memory leak & crash
- **Solusi**: Hapus Firebase.initializeApp() di background service onStart()
### 4. **Null Safety Issue** ❌ → ✅
- **Masalah**: Akses field tanpa null check → NullPointerException
- **File**: `lib/data_siswa.dart`
- **Solusi**: Cek null sebelum akses
```dart
final rfidData = siswa['rfid'];
if (rfidData == null) continue;
final rfid = rfidData as String;
```
### 5. **Missing Error Handling** ❌ → ✅
- **Masalah**: Exception di Firestore listener tidak ditangani → app crash
- **Solusi**: Wrap dengan try-catch & onError callback
```dart
.listen((event) async {
try {
// ...
} catch (e) {
debugPrint('Error notif: $e');
}
}, onError: (error) {
debugPrint('Error listen absensi: $error');
});
```
---
## 📝 File yang Diubah:
### ✏️ `android/app/src/main/AndroidManifest.xml`
- [x] Tambah `SCHEDULE_EXACT_ALARM` permission
### ✏️ `lib/main.dart`
- [x] Import `permission_handler` dan `dart:io`
- [x] Request permission di main()
- [x] Hapus Firebase init di background service
- [x] Tambah try-catch di Firestore listener
- [x] Tambah null safety checks untuk siswa data
### ✏️ `lib/data_siswa.dart`
- [x] Cek null sebelum akses field
- [x] Skip row jika ortu_uid kosong
### ✏️ `pubspec.yaml`
- [x] Tambah dependency: `permission_handler: ^11.4.4`
---
## 🚀 Langkah Selanjutnya:
1. **Run flutter pub get**
```bash
flutter pub get
```
2. **Clean build**
```bash
flutter clean
flutter pub get
```
3. **Build APK baru**
```bash
flutter build apk --release
```
4. **Test di Vivo Android 13**
- Uninstall APK lama
- Install APK baru
- Tunggu 5-10 menit untuk background service berjalan
- Cek logcat untuk error messages:
```bash
flutter logs
```
---
## 🔧 Testing Background Service:
Untuk test apakah background service jalan:
1. Buka app
2. Login dengan akun parent
3. Keluar dari app
4. Tunggu 1-2 menit
5. Cek notification - seharusnya muncul "Absensi Aktif"
---
## 📊 Logcat Debug:
Jika masih ada crash, check logcat:
```bash
flutter logs | grep -E "Error|Exception|Crash"
```
Atau di Android Studio:
- Logcat → Filter: `absensi`
---
## ⚠️ Catatan Penting:
1. **Permission Request**: User harus approve notification permission saat app launch
2. **Background Service**: Tidak akan jalan jika app tidak pernah di-login
3. **Android 13+**: Foreground service notif wajib ada
4. **Debugging**: Gunakan `debugPrint()` bukan `print()` untuk log
---
## ✅ Checklist Fix:
- [x] SCHEDULE_EXACT_ALARM permission ditambah
- [x] Runtime permission request ditambah
- [x] Firebase double init dihapus
- [x] Null safety checks ditambah
- [x] Error handling ditambah
- [x] Permission_handler dependency ditambah
**Status**: Siap di-test! 🎉

16
README.md Normal file
View File

@ -0,0 +1,16 @@
# absensi
A new Flutter project.
## Getting Started
This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.

28
analysis_options.yaml Normal file
View File

@ -0,0 +1,28 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.
# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml
linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at https://dart.dev/lints.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options

14
android/.gitignore vendored Normal file
View File

@ -0,0 +1,14 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java
.cxx/
# Remember to never publicly share your keystore.
# See https://flutter.dev/to/reference-keystore
key.properties
**/*.keystore
**/*.jks

View File

@ -0,0 +1,118 @@
plugins {
id("com.android.application")
// =====================================================
// FIREBASE
// =====================================================
id("com.google.gms.google-services")
// =====================================================
// KOTLIN
// =====================================================
id("kotlin-android")
// =====================================================
// FLUTTER
// =====================================================
id("dev.flutter.flutter-gradle-plugin")
}
android {
// =====================================================
// NAMESPACE
// =====================================================
namespace = "com.example.absensi"
// =====================================================
// SDK
// =====================================================
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion
// =====================================================
// JAVA + DESUGARING
// =====================================================
compileOptions {
// 🔥 WAJIB UNTUK flutter_local_notifications
isCoreLibraryDesugaringEnabled = true
sourceCompatibility =
JavaVersion.VERSION_11
targetCompatibility =
JavaVersion.VERSION_11
}
// =====================================================
// KOTLIN JVM
// =====================================================
kotlinOptions {
jvmTarget =
JavaVersion.VERSION_11.toString()
}
// =====================================================
// DEFAULT CONFIG
// =====================================================
defaultConfig {
// PACKAGE NAME
applicationId =
"com.example.absensi"
// 🔥 MIN SDK
minSdk = flutter.minSdkVersion
// TARGET SDK
targetSdk =
flutter.targetSdkVersion
// VERSION
versionCode =
flutter.versionCode
versionName =
flutter.versionName
}
// =====================================================
// BUILD TYPES
// =====================================================
buildTypes {
release {
// 🔥 SEMENTARA DEBUG SIGNING
signingConfig =
signingConfigs.getByName("debug")
// OPTIONAL
isMinifyEnabled = false
isShrinkResources = false
}
}
}
// =====================================================
// FLUTTER
// =====================================================
flutter {
source = "../.."
}
// =====================================================
// DEPENDENCIES
// =====================================================
dependencies {
// 🔥 FIX flutter_local_notifications
coreLibraryDesugaring(
"com.android.tools:desugar_jdk_libs:2.1.4"
)
}

View File

@ -0,0 +1,30 @@
{
"project_info": {
"project_number": "729195667113",
"firebase_url": "https://absensi-febe3-default-rtdb.firebaseio.com",
"project_id": "absensi-febe3",
"storage_bucket": "absensi-febe3.firebasestorage.app"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:729195667113:android:02251dfb48de22a8bd13b8",
"android_client_info": {
"package_name": "com.example.absensi"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyDu-NE4S2JFSt5V0vbXJyeqe__c8nwvs_s"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"
}

View File

@ -0,0 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>

View File

@ -0,0 +1,82 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<!-- ===================================================== -->
<!-- PERMISSION -->
<!-- ===================================================== -->
<!-- Android 13+ -->
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<!-- Android 12 ke bawah -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<!-- Kamera -->
<uses-permission android:name="android.permission.CAMERA"/>
<!-- FOREGROUND SERVICE -->
<!-- NOTIFIKASI -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<!-- SCHEDULE EXACT ALARM untuk Android 13+ -->
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
<!-- AGAR SERVICE TETAP HIDUP -->
<application
android:label="absensi"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<!-- ===================================================== -->
<!-- MAIN ACTIVITY -->
<!-- ===================================================== -->
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:taskAffinity=""
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Splash -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- ===================================================== -->
<!-- FLUTTER -->
<!-- ===================================================== -->
<meta-data
android:name="flutterEmbedding"
android:value="2"/>
</application>
<!-- ===================================================== -->
<!-- QUERY -->
<!-- ===================================================== -->
<queries>
<intent>
<action android:name="android.intent.action.PROCESS_TEXT"/>
<data android:mimeType="text/plain"/>
</intent>
</queries>
</manifest>

View File

@ -0,0 +1,5 @@
package com.example.absensi
import io.flutter.embedding.android.FlutterActivity
class MainActivity : FlutterActivity()

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="?android:colorBackground" />
<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>

View File

@ -0,0 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>

24
android/build.gradle.kts Normal file
View File

@ -0,0 +1,24 @@
allprojects {
repositories {
google()
mavenCentral()
}
}
val newBuildDir: Directory =
rootProject.layout.buildDirectory
.dir("../../build")
.get()
rootProject.layout.buildDirectory.value(newBuildDir)
subprojects {
val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
project.layout.buildDirectory.value(newSubprojectBuildDir)
}
subprojects {
project.evaluationDependsOn(":app")
}
tasks.register<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}

View File

@ -0,0 +1,3 @@
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
android.enableJetifier=true

View File

@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip

View File

@ -0,0 +1,29 @@
pluginManagement {
val flutterSdkPath =
run {
val properties = java.util.Properties()
file("local.properties").inputStream().use { properties.load(it) }
val flutterSdkPath = properties.getProperty("flutter.sdk")
require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" }
flutterSdkPath
}
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
id("com.android.application") version "8.9.1" apply false
// START: FlutterFire Configuration
id("com.google.gms.google-services") version("4.3.15") apply false
// END: FlutterFire Configuration
id("org.jetbrains.kotlin.android") version "2.1.0" apply false
}
include(":app")

1
firebase.json Normal file
View File

@ -0,0 +1 @@
{"flutter":{"platforms":{"android":{"default":{"projectId":"absensi-febe3","appId":"1:729195667113:android:02251dfb48de22a8bd13b8","fileOutput":"android/app/google-services.json"}},"dart":{"lib/firebase_options.dart":{"projectId":"absensi-febe3","configurations":{"android":"1:729195667113:android:02251dfb48de22a8bd13b8","web":"1:729195667113:web:c73cb6383975ddfabd13b8"}}}}}}

34
ios/.gitignore vendored Normal file
View File

@ -0,0 +1,34 @@
**/dgph
*.mode1v3
*.mode2v3
*.moved-aside
*.pbxuser
*.perspectivev3
**/*sync/
.sconsign.dblite
.tags*
**/.vagrant/
**/DerivedData/
Icon?
**/Pods/
**/.symlinks/
profile
xcuserdata
**/.generated/
Flutter/App.framework
Flutter/Flutter.framework
Flutter/Flutter.podspec
Flutter/Generated.xcconfig
Flutter/ephemeral/
Flutter/app.flx
Flutter/app.zip
Flutter/flutter_assets/
Flutter/flutter_export_environment.sh
ServiceDefinitions.json
Runner/GeneratedPluginRegistrant.*
# Exceptions to above rules.
!default.mode1v3
!default.mode2v3
!default.pbxuser
!default.perspectivev3

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>App</string>
<key>CFBundleIdentifier</key>
<string>io.flutter.flutter.app</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>App</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>13.0</string>
</dict>
</plist>

View File

@ -0,0 +1 @@
#include "Generated.xcconfig"

View File

@ -0,0 +1 @@
#include "Generated.xcconfig"

View File

@ -0,0 +1,616 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 54;
objects = {
/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
331C8085294A63A400263BE5 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 97C146E61CF9000F007C117D /* Project object */;
proxyType = 1;
remoteGlobalIDString = 97C146ED1CF9000F007C117D;
remoteInfo = Runner;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
9705A1C41CF9048500538489 /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = "<group>"; };
331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
97C146EB1CF9000F007C117D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
331C8082294A63A400263BE5 /* RunnerTests */ = {
isa = PBXGroup;
children = (
331C807B294A618700263BE5 /* RunnerTests.swift */,
);
path = RunnerTests;
sourceTree = "<group>";
};
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
9740EEB21CF90195004384FC /* Debug.xcconfig */,
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
9740EEB31CF90195004384FC /* Generated.xcconfig */,
);
name = Flutter;
sourceTree = "<group>";
};
97C146E51CF9000F007C117D = {
isa = PBXGroup;
children = (
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
331C8082294A63A400263BE5 /* RunnerTests */,
);
sourceTree = "<group>";
};
97C146EF1CF9000F007C117D /* Products */ = {
isa = PBXGroup;
children = (
97C146EE1CF9000F007C117D /* Runner.app */,
331C8081294A63A400263BE5 /* RunnerTests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
97C146F01CF9000F007C117D /* Runner */ = {
isa = PBXGroup;
children = (
97C146FA1CF9000F007C117D /* Main.storyboard */,
97C146FD1CF9000F007C117D /* Assets.xcassets */,
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
97C147021CF9000F007C117D /* Info.plist */,
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
);
path = Runner;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
331C8080294A63A400263BE5 /* RunnerTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */;
buildPhases = (
331C807D294A63A400263BE5 /* Sources */,
331C807F294A63A400263BE5 /* Resources */,
);
buildRules = (
);
dependencies = (
331C8086294A63A400263BE5 /* PBXTargetDependency */,
);
name = RunnerTests;
productName = RunnerTests;
productReference = 331C8081294A63A400263BE5 /* RunnerTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
97C146ED1CF9000F007C117D /* Runner */ = {
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
);
buildRules = (
);
dependencies = (
);
name = Runner;
productName = Runner;
productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
331C8080294A63A400263BE5 = {
CreatedOnToolsVersion = 14.0;
TestTargetID = 97C146ED1CF9000F007C117D;
};
97C146ED1CF9000F007C117D = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 1100;
};
};
};
buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */;
compatibilityVersion = "Xcode 9.3";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 97C146E51CF9000F007C117D;
productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
97C146ED1CF9000F007C117D /* Runner */,
331C8080294A63A400263BE5 /* RunnerTests */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
331C807F294A63A400263BE5 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
97C146EC1CF9000F007C117D /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Run Script";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
331C807D294A63A400263BE5 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
97C146EA1CF9000F007C117D /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
331C8086294A63A400263BE5 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 97C146ED1CF9000F007C117D /* Runner */;
targetProxy = 331C8085294A63A400263BE5 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
97C146FA1CF9000F007C117D /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
97C146FB1CF9000F007C117D /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
97C147001CF9000F007C117D /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
249021D3217E4FDB00AE95B9 /* Profile */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Profile;
};
249021D4217E4FDB00AE95B9 /* Profile */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.absensi;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
};
name = Profile;
};
331C8088294A63A400263BE5 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.absensi.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
};
name = Debug;
};
331C8089294A63A400263BE5 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.absensi.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
};
name = Release;
};
331C808A294A63A400263BE5 /* Profile */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.absensi.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
};
name = Profile;
};
97C147031CF9000F007C117D /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
97C147041CF9000F007C117D /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
97C147061CF9000F007C117D /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.absensi;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
};
name = Debug;
};
97C147071CF9000F007C117D /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.absensi;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
331C8088294A63A400263BE5 /* Debug */,
331C8089294A63A400263BE5 /* Release */,
331C808A294A63A400263BE5 /* Profile */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = {
isa = XCConfigurationList;
buildConfigurations = (
97C147031CF9000F007C117D /* Debug */,
97C147041CF9000F007C117D /* Release */,
249021D3217E4FDB00AE95B9 /* Profile */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = {
isa = XCConfigurationList;
buildConfigurations = (
97C147061CF9000F007C117D /* Debug */,
97C147071CF9000F007C117D /* Release */,
249021D4217E4FDB00AE95B9 /* Profile */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 97C146E61CF9000F007C117D /* Project object */;
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreviewsEnabled</key>
<false/>
</dict>
</plist>

View File

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "331C8080294A63A400263BE5"
BuildableName = "RunnerTests.xctest"
BlueprintName = "RunnerTests"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
enableGPUValidationMode = "1"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Profile"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:Runner.xcodeproj">
</FileRef>
</Workspace>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreviewsEnabled</key>
<false/>
</dict>
</plist>

View File

@ -0,0 +1,13 @@
import Flutter
import UIKit
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}

View File

@ -0,0 +1,122 @@
{
"images" : [
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-App-20x20@2x.png",
"scale" : "2x"
},
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-App-20x20@3x.png",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@1x.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@3x.png",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-App-40x40@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-App-40x40@3x.png",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-App-60x60@2x.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-App-60x60@3x.png",
"scale" : "3x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-App-20x20@1x.png",
"scale" : "1x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-App-20x20@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-App-29x29@1x.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-App-29x29@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-App-40x40@1x.png",
"scale" : "1x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-App-40x40@2x.png",
"scale" : "2x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-App-76x76@1x.png",
"scale" : "1x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-App-76x76@2x.png",
"scale" : "2x"
},
{
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "Icon-App-83.5x83.5@2x.png",
"scale" : "2x"
},
{
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "Icon-App-1024x1024@1x.png",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 678 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "LaunchImage.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "LaunchImage@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "LaunchImage@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 B

View File

@ -0,0 +1,5 @@
# Launch Screen Assets
You can customize the launch screen with your own desired assets by replacing the image files in this directory.
You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Ydg-fD-yQy"/>
<viewControllerLayoutGuide type="bottom" id="xbc-2k-c8Z"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" image="LaunchImage" translatesAutoresizingMaskIntoConstraints="NO" id="YRO-k0-Ey4">
</imageView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="YRO-k0-Ey4" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="1a2-6s-vTC"/>
<constraint firstItem="YRO-k0-Ey4" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" id="4X2-HB-R7a"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
<resources>
<image name="LaunchImage" width="168" height="185"/>
</resources>
</document>

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<scenes>
<!--Flutter View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="FlutterViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>

49
ios/Runner/Info.plist Normal file
View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>Absensi</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>absensi</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>

View File

@ -0,0 +1 @@
#import "GeneratedPluginRegistrant.h"

View File

@ -0,0 +1,12 @@
import Flutter
import UIKit
import XCTest
class RunnerTests: XCTestCase {
func testExample() {
// If you add code to the Runner application, consider adding tests here.
// See https://developer.apple.com/documentation/xctest for more information about using XCTest.
}
}

873
lib/absensi_page.dart Normal file
View File

@ -0,0 +1,873 @@
import 'dart:convert';
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:firebase_database/firebase_database.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
class AbsensiPage extends StatefulWidget {
const AbsensiPage({super.key});
@override
State<AbsensiPage> createState() => _AbsensiPageState();
}
class _AbsensiPageState extends State<AbsensiPage> {
final refAbsen = FirebaseDatabase.instance.ref("absensi");
final refJadwal = FirebaseDatabase.instance.ref("jadwal/absen");
final refIzin = FirebaseDatabase.instance.ref("izin");
final jamMasuk = TextEditingController();
final jamPulang = TextEditingController();
String today = DateTime.now().toString().substring(0, 10);
List siswaList = [];
@override
void initState() {
super.initState();
loadJadwal();
loadSiswa();
}
@override
void dispose() {
jamMasuk.dispose();
jamPulang.dispose();
super.dispose();
}
// ================= LOAD DATA BACKEND =================
Future<void> loadSiswa() async {
final snap = await FirebaseFirestore.instance.collection('siswa').get();
setState(() {
siswaList = snap.docs;
});
}
Future<void> loadJadwal() async {
final snap = await refJadwal.get();
if (snap.exists) {
final data = snap.value as Map;
jamMasuk.text = data['jam_masuk'] ?? '';
jamPulang.text = data['jam_pulang'] ?? '';
}
}
Future<void> pilihJam(TextEditingController controller) async {
final picked = await showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
builder: (context, child) {
return Theme(
data: Theme.of(context).copyWith(
colorScheme: const ColorScheme.light(primary: Color(0xff16A34A)),
),
child: child!,
);
},
);
if (picked != null) {
controller.text =
"${picked.hour.toString().padLeft(2, '0')}:${picked.minute.toString().padLeft(2, '0')}";
setState(() {});
}
}
Future<void> simpanJadwal() async {
await refJadwal.set({
"jam_masuk": jamMasuk.text,
"jam_pulang": jamPulang.text,
});
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("Jadwal berhasil disimpan"),
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10))),
),
);
}
}
// ================= DEKORASI WARNA STATUS =================
Color getStatusTextColor(String status) {
switch (status) {
case "tepat_waktu":
return const Color(0xff16A34A);
case "telat":
return const Color(0xffEA580C);
case "pulang":
return const Color(0xff0284C7);
case "izin":
return const Color(0xff7C3AED);
case "sakit":
return const Color(0xff9333EA);
default:
return const Color(0xffDC2626);
}
}
Color getStatusBgColor(String status) {
switch (status) {
case "tepat_waktu":
return const Color(0xffF0FDF4);
case "telat":
return const Color(0xffFFF7ED);
case "pulang":
return const Color(0xffF0F9FF);
case "izin":
return const Color(0xffFAF5FF);
case "sakit":
return const Color(0xffF3E8FF);
default:
return const Color(0xffFEF2F2);
}
}
// ================= ACC / TOLAK LOGIC =================
Future<void> acc(String key, Map data) async {
if (data['rfid'] == null) return;
final uid = data['rfid'];
final now = DateTime.now();
final jam = "${now.hour.toString().padLeft(2, '0')}:${now.minute.toString().padLeft(2, '0')}";
await refAbsen.child("$uid/$today/masuk").set({
"jam": jam,
"status": data['jenis'],
});
await refIzin.child(key).remove();
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text("${data['nama']} telah disetujui"),
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10))),
),
);
}
}
Future<void> tolak(String key) async {
await refIzin.child(key).remove();
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("Permintaan izin ditolak"),
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10))),
),
);
}
}
void bukaFoto(String? base64String) {
showDialog(
context: context,
builder: (_) => Dialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: double.infinity,
padding: const EdgeInsets.all(16),
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [Color(0xffE6DFFF), Color(0xffCCBFFF)],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(24),
topRight: Radius.circular(24),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
"Surat Izin",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Color(0xff12175E),
),
),
InkWell(
onTap: () => Navigator.pop(context),
child: const Icon(Icons.close, color: Color(0xff12175E)),
),
],
),
),
Padding(
padding: const EdgeInsets.all(20),
child: (base64String == null || base64String.isEmpty)
? const Text(
"Tidak ada gambar surat izin",
style: TextStyle(color: Color(0xff12175E), fontSize: 15),
)
: Builder(
builder: (_) {
try {
Uint8List bytes = base64Decode(base64String);
return ClipRRect(
borderRadius: BorderRadius.circular(12),
child: Image.memory(bytes, fit: BoxFit.contain),
);
} catch (e) {
return const Text(
"Gagal memuat gambar",
style: TextStyle(color: Color(0xffDC2626), fontSize: 15),
);
}
},
),
),
],
),
),
);
}
Widget header(BuildContext context) {
final screenHeight = MediaQuery.of(context).size.height;
return Container(
width: double.infinity,
height: screenHeight * 0.24,
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [
Color(0xffE6DFFF),
Color(0xffCCBFFF),
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(40),
bottomRight: Radius.circular(40),
),
boxShadow: [
BoxShadow(
color: Color(0xff7F56D9),
blurRadius: 24,
offset: Offset(0, 8),
),
],
),
child: ClipRRect(
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(40),
bottomRight: Radius.circular(40),
),
child: Stack(
children: [
Positioned(
top: -30,
left: -20,
child: Container(
width: 150,
height: 150,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white.withOpacity(0.15),
),
),
),
Positioned.fill(
child: CustomPaint(painter: HeaderWavePainter()),
),
Positioned(top: 40, left: 24, child: _buildGridDots()),
Positioned(top: 60, right: 60, child: _buildGridDots()),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 20),
child: Row(
children: [
Container(
height: 44,
width: 44,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(14),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.06),
blurRadius: 12,
offset: const Offset(0, 4),
)
],
),
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(14),
onTap: () => Navigator.pop(context),
child: const Icon(Icons.arrow_back_ios_new, color: Color(0xff7F56D9), size: 18),
),
),
),
const SizedBox(width: 16),
Image.asset(
'lib/assets/sekolah.png',
width: 50,
height: 50,
fit: BoxFit.contain,
errorBuilder: (_, __, ___) => const Icon(Icons.school, size: 40, color: Color(0xff7F56D9)),
),
const SizedBox(width: 12),
const Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Absensi Harian",
style: TextStyle(
color: Color(0xff12175E),
fontSize: 22,
fontWeight: FontWeight.bold,
letterSpacing: -0.5,
),
),
SizedBox(height: 4),
Text(
"Kelola kehadiran siswa hari ini",
style: TextStyle(
color: Color(0xff12175E),
fontSize: 14,
fontWeight: FontWeight.w500,
height: 0.7,
),
),
],
),
),
Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.4),
borderRadius: BorderRadius.circular(14),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.04),
blurRadius: 8,
offset: const Offset(0, 2),
)
],
),
child: const Icon(
Icons.assignment_turned_in_rounded,
color: Color(0xff16A34A),
size: 26,
),
),
],
),
),
],
),
),
);
}
Widget _buildGridDots() {
return Opacity(
opacity: 0.25,
child: Column(
children: List.generate(4, (index) => Row(
children: List.generate(4, (index) => Container(
width: 2.5,
height: 2.5,
margin: const EdgeInsets.all(2.5),
decoration: const BoxDecoration(color: Color(0xff12175E), shape: BoxShape.circle),
)),
)),
),
);
}
Widget sectionTitle(String title) {
return Padding(
padding: const EdgeInsets.only(left: 24, bottom: 12, top: 16),
child: Row(
children: [
Container(width: 24, height: 3, decoration: BoxDecoration(color: const Color(0xff16A34A), borderRadius: BorderRadius.circular(1.5))),
const SizedBox(width: 3),
Container(width: 3, height: 3, decoration: const BoxDecoration(color: Color(0xff16A34A), shape: BoxShape.circle)),
const SizedBox(width: 8),
Text(
title.toUpperCase(),
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: Color(0xff12175E),
letterSpacing: 0.5,
),
),
],
),
);
}
Widget jamInput({
required TextEditingController controller,
required String label,
required VoidCallback onTap,
}) {
return Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
boxShadow: [
BoxShadow(
color: const Color(0xff16A34A).withOpacity(0.08),
blurRadius: 16,
spreadRadius: 0,
offset: const Offset(0, 6),
),
],
),
child: TextField(
controller: controller,
readOnly: true,
onTap: onTap,
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold,
color: Color(0xff12175E),
),
decoration: InputDecoration(
border: InputBorder.none,
contentPadding: const EdgeInsets.symmetric(vertical: 20),
prefixIcon: Container(
margin: const EdgeInsets.all(8),
width: 40,
height: 40,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: const Color(0xff16A34A).withOpacity(0.12),
),
child: const Icon(Icons.access_time_rounded, color: Color(0xff16A34A)),
),
hintText: "--:--",
hintStyle: TextStyle(color: const Color(0xff12175E).withOpacity(0.3)),
),
),
);
}
Widget izinCard(Map<String, dynamic> data, String key) {
return Container(
width: 260,
margin: const EdgeInsets.all(8),
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(24),
boxShadow: [
BoxShadow(
color: const Color(0xff7F56D9).withOpacity(0.08),
blurRadius: 20,
spreadRadius: 0,
offset: const Offset(0, 8),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Container(
width: 40,
height: 40,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: const Color(0xff7C3AED).withOpacity(0.12),
),
child: const Icon(Icons.description_rounded, color: Color(0xff7C3AED), size: 20),
),
const SizedBox(width: 10),
Expanded(
child: Text(
data['nama'] ?? 'Tidak ada nama',
style: const TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: Color(0xff12175E),
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
],
),
const SizedBox(height: 12),
Text(
"Jenis: ${data['jenis'] ?? '-'}",
style: TextStyle(
fontSize: 13,
color: const Color(0xff12175E).withOpacity(0.6),
),
),
const Spacer(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
TextButton(
onPressed: () => bukaFoto(data['foto']),
style: TextButton.styleFrom(
padding: EdgeInsets.zero,
minimumSize: const Size(60, 30),
),
child: const Text(
"Lihat Surat",
style: TextStyle(color: Color(0xff7F56D9), fontSize: 13, fontWeight: FontWeight.w600),
),
),
Row(
children: [
SizedBox(
height: 32,
child: ElevatedButton(
onPressed: () => acc(key, data),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xff16A34A),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
padding: const EdgeInsets.symmetric(horizontal: 10),
),
child: const Text("ACC", style: TextStyle(fontSize: 12, fontWeight: FontWeight.bold)),
),
),
const SizedBox(width: 6),
SizedBox(
height: 32,
child: ElevatedButton(
onPressed: () => tolak(key),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xffDC2626),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
padding: const EdgeInsets.symmetric(horizontal: 10),
),
child: const Text("Tolak", style: TextStyle(fontSize: 12, fontWeight: FontWeight.bold)),
),
),
],
)
],
)
],
),
);
}
Widget absensiCard({
required String nama,
required String jamMasuk,
required String jamPulang,
required String statusMasuk,
required String statusPulang,
}) {
return Container(
margin: const EdgeInsets.only(bottom: 16, left: 24, right: 24),
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(24),
boxShadow: [
BoxShadow(
color: const Color(0xff16A34A).withOpacity(0.08),
blurRadius: 20,
spreadRadius: 0,
offset: const Offset(0, 8),
),
],
),
child: Row(
children: [
Container(
width: 56,
height: 56,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: const Color(0xff16A34A).withOpacity(0.12),
boxShadow: [
BoxShadow(
color: const Color(0xff16A34A).withOpacity(0.15),
blurRadius: 12,
spreadRadius: 2,
),
],
),
child: const Icon(Icons.person_rounded, color: Color(0xff16A34A), size: 26),
),
const SizedBox(width: 16),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
nama,
style: const TextStyle(
fontSize: 17,
fontWeight: FontWeight.bold,
color: Color(0xff12175E),
),
),
const SizedBox(height: 6),
Text(
"Masuk: $jamMasuk",
style: TextStyle(
fontSize: 14,
color: const Color(0xff12175E).withOpacity(0.6),
),
),
Text(
"Pulang: $jamPulang",
style: TextStyle(
fontSize: 14,
color: const Color(0xff12175E).withOpacity(0.6),
),
),
],
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Container(
margin: const EdgeInsets.only(bottom: 6),
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(
color: getStatusBgColor(statusMasuk),
borderRadius: BorderRadius.circular(12),
),
child: Text(
statusMasuk == "tidak_hadir" ? "BELUM" : statusMasuk.toUpperCase(),
style: TextStyle(
color: getStatusTextColor(statusMasuk),
fontWeight: FontWeight.bold,
fontSize: 11,
),
),
),
Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(
color: getStatusBgColor(statusPulang),
borderRadius: BorderRadius.circular(12),
),
child: Text(
statusPulang == "tidak_hadir" ? "BELUM" : statusPulang.toUpperCase(),
style: TextStyle(
color: getStatusTextColor(statusPulang),
fontWeight: FontWeight.bold,
fontSize: 11,
),
),
),
],
)
],
),
);
}
Widget gradientButton({
required String title,
required VoidCallback onTap,
}) {
return SizedBox(
height: 52,
width: double.infinity,
child: DecoratedBox(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
gradient: const LinearGradient(
colors: [Color(0xff16A34A), Color(0xff22C55E)],
),
boxShadow: [
BoxShadow(
color: const Color(0xff16A34A).withOpacity(0.3),
blurRadius: 10,
offset: const Offset(0, 4),
),
],
),
child: ElevatedButton(
onPressed: onTap,
style: ElevatedButton.styleFrom(
elevation: 0,
backgroundColor: Colors.transparent,
shadowColor: Colors.transparent,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
),
child: Text(
title,
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Colors.white),
),
),
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xffF6F5FB),
body: SafeArea(
child: Column(
children: [
header(context),
Expanded(
child: SingleChildScrollView(
physics: const BouncingScrollPhysics(),
child: Column(
children: [
sectionTitle("Jadwal Kehadiran"),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Row(
children: [
Expanded(child: jamInput(controller: jamMasuk, label: "Jam Masuk", onTap: () => pilihJam(jamMasuk))),
const SizedBox(width: 16),
Expanded(child: jamInput(controller: jamPulang, label: "Jam Pulang", onTap: () => pilihJam(jamPulang))),
],
),
),
const SizedBox(height: 20),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 80),
child: gradientButton(title: "Simpan Jadwal", onTap: simpanJadwal),
),
sectionTitle("Permintaan Izin"),
StreamBuilder(
stream: refIzin.onValue,
builder: (context, snapshot) {
if (!snapshot.hasData) return const SizedBox(height: 150);
final data = snapshot.data!.snapshot.value as Map? ?? {};
if (data.isEmpty) {
return SizedBox(
height: 150,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.check_circle_outline, size: 40, color: const Color(0xff12175E).withOpacity(0.3)),
const SizedBox(height: 8),
Text(
"Tidak ada permintaan izin",
style: TextStyle(color: const Color(0xff12175E).withOpacity(0.5)),
),
],
),
),
);
}
return SizedBox(
height: 170,
child: ListView(
scrollDirection: Axis.horizontal,
padding: const EdgeInsets.symmetric(horizontal: 16),
children: data.entries.map((e) {
return izinCard(Map<String, dynamic>.from(e.value), e.key);
}).toList(),
),
);
},
),
sectionTitle("Daftar Kehadiran Hari Ini"),
StreamBuilder(
stream: refAbsen.onValue,
builder: (context, snapshot) {
if (!snapshot.hasData) {
return const Padding(
padding: EdgeInsets.all(30.0),
child: Center(child: CircularProgressIndicator(color: Color(0xff7F56D9))),
);
}
final absen = snapshot.data!.snapshot.value as Map? ?? {};
if (siswaList.isEmpty) {
return const Center(child: Padding(padding: EdgeInsets.all(20), child: Text("Memuat data siswa...")));
}
return ListView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: siswaList.length,
itemBuilder: (c, i) {
final doc = siswaList[i];
final uid = doc['rfid'];
final nama = doc['nama'];
String statusMasuk = "tidak_hadir";
String jamMasukSiswa = "-";
String statusPulang = "tidak_hadir";
String jamPulangSiswa = "-";
if (absen[uid] != null && absen[uid][today] != null) {
final dataHariIni = absen[uid][today] as Map;
if (dataHariIni['masuk'] != null) {
statusMasuk = dataHariIni['masuk']['status'] ?? "tidak_hadir";
jamMasukSiswa = dataHariIni['masuk']['jam'] ?? "-";
}
if (dataHariIni['pulang'] != null) {
statusPulang = dataHariIni['pulang']['status'] ?? "tidak_hadir";
jamPulangSiswa = dataHariIni['pulang']['jam'] ?? "-";
}
}
return absensiCard(
nama: nama,
jamMasuk: jamMasukSiswa,
jamPulang: jamPulangSiswa,
statusMasuk: statusMasuk,
statusPulang: statusPulang,
);
},
);
},
),
const SizedBox(height: 20),
],
),
),
),
],
),
),
);
}
}
class HeaderWavePainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()
..color = Colors.white.withOpacity(0.3)
..style = PaintingStyle.stroke
..strokeWidth = 1.8;
final path = Path();
path.moveTo(0, size.height * 0.4);
path.quadraticBezierTo(size.width * 0.5, size.height * 0.1, size.width, size.height * 0.3);
canvas.drawPath(path, paint);
final path2 = Path();
path2.moveTo(0, size.height * 0.6);
path2.quadraticBezierTo(size.width * 0.6, size.height * 0.2, size.width, size.height * 0.5);
canvas.drawPath(path2, paint);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
}

BIN
lib/assets/anak_rfid.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 KiB

BIN
lib/assets/icon_guru.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 KiB

BIN
lib/assets/jti.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
lib/assets/logo absensi.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 904 KiB

BIN
lib/assets/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 441 KiB

BIN
lib/assets/rfidlogin.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

BIN
lib/assets/sekolah.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

485
lib/dashboard_admin.dart Normal file
View File

@ -0,0 +1,485 @@
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cloud_functions/cloud_functions.dart';
import 'login_page.dart';
import 'tambah_user.dart';
import 'tambah_siswa.dart';
class DashboardAdmin extends StatelessWidget {
const DashboardAdmin({super.key});
Future<void> logout(BuildContext context) async {
await FirebaseAuth.instance.signOut();
if (!context.mounted) return;
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(builder: (_) => const LoginPage()),
(route) => false,
);
}
Future<void> hapusUser(String uid) async {
await FirebaseFunctions.instance
.httpsCallable('deleteUserAndSiswa')
.call({'uid': uid});
}
void showHapusDialog(BuildContext context, String role) {
showDialog(
context: context,
builder: (_) => AlertDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
title: Text(
'Hapus Akun ${role.toUpperCase()}',
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18,
color: Color(0xff12175E),
),
),
content: Container(
width: MediaQuery.of(context).size.width * 0.85,
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height * 0.55,
),
child: StreamBuilder<QuerySnapshot>(
stream: FirebaseFirestore.instance
.collection('users')
.where('role', isEqualTo: role)
.snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return const Center(
child: CircularProgressIndicator(color: Color(0xff7F56D9)),
);
}
final data = snapshot.data!.docs;
if (data.isEmpty) {
return const Center(
child: Text(
'Tidak ada akun',
style: TextStyle(color: Color(0xff12175E), fontSize: 15),
),
);
}
return ListView.builder(
shrinkWrap: true,
itemCount: data.length,
itemBuilder: (context, index) {
final user = data[index].data() as Map<String, dynamic>;
return Container(
margin: const EdgeInsets.symmetric(vertical: 6),
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: const Color(0xffF6F5FB),
borderRadius: BorderRadius.circular(14),
),
child: Row(
children: [
CircleAvatar(
backgroundColor: const Color(0xff7F56D9).withOpacity(0.12),
child: const Icon(Icons.person, color: Color(0xff7F56D9)),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
user['nama'] ?? '-',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontWeight: FontWeight.w600,
color: Color(0xff12175E),
),
),
const SizedBox(height: 2),
Text(
user['email'] ?? '-',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 13,
color: const Color(0xff12175E).withOpacity(0.6),
),
),
],
),
),
IconButton(
icon: const Icon(Icons.delete_outline, color: Color(0xffDC2626)),
onPressed: () async {
await hapusUser(data[index].id);
if (!context.mounted) return;
Navigator.pop(context);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Akun berhasil dihapus'),
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10))),
),
);
},
),
],
),
);
},
);
},
),
),
),
);
}
Widget menuCard({
required String title,
required String subtitle,
required IconData icon,
required Color startColor,
required Color iconBg,
required Color btnColor,
required VoidCallback onTap,
}) {
return GestureDetector(
onTap: onTap,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(24),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.04),
blurRadius: 16,
spreadRadius: 1,
offset: const Offset(0, 6),
),
],
),
child: Stack(
children: [
Positioned(
top: 0,
left: 0,
child: CustomPaint(
size: const Size(85, 85),
painter: CornerCurvePainter(color: startColor),
),
),
Positioned(
top: 20,
right: 20,
child: Column(
children: List.generate(3, (_) => Row(
children: List.generate(3, (_) => Container(
width: 3.5,
height: 3.5,
margin: const EdgeInsets.all(2),
decoration: BoxDecoration(
color: startColor.withOpacity(0.25),
shape: BoxShape.circle,
),
)),
)),
),
),
Padding(
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: 54,
height: 54,
decoration: BoxDecoration(
color: iconBg,
shape: BoxShape.circle,
),
child: Icon(icon, size: 26, color: startColor),
),
const SizedBox(height: 16),
Text(
title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Color(0xff12175E),
height: 1.2,
),
),
const SizedBox(height: 6),
Expanded(
child: Text(
subtitle,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 12,
color: const Color(0xff12175E).withOpacity(0.6),
height: 1.4,
),
),
),
Align(
alignment: Alignment.bottomRight,
child: Container(
width: 36,
height: 36,
decoration: BoxDecoration(
color: btnColor,
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: btnColor.withOpacity(0.2),
blurRadius: 6,
offset: const Offset(0, 2),
),
],
),
child: const Icon(
Icons.arrow_forward,
color: Colors.white,
size: 18,
),
),
),
],
),
),
],
),
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xffF8F5FF),
body: SingleChildScrollView(
physics: const BouncingScrollPhysics(),
child: Column(
children: [
// HEADER DENGAN WARNA GRADASI SEPERTI HALAMAN HOME
Container(
width: double.infinity,
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xffEDE9FF), // Ungu sangat muda
Color(0xffDCD4FF), // Ungu lembut
Color(0xffCBBEFF), // Ungu sedikit lebih tua
],
),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(36),
bottomRight: Radius.circular(36),
),
),
child: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 28),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Baris Logo & Tombol Logout
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Image.asset(
'lib/assets/sekolah.png',
width: 56,
height: 56,
fit: BoxFit.contain,
errorBuilder: (_, __, ___) => const Icon(
Icons.school,
size: 52,
color: Color(0xff7F56D9),
),
),
const SizedBox(width: 12),
const Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"TK PGRI",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Color(0xff12175E),
height: 1.1,
),
),
Text(
"BHAKTI LESTARI",
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w500,
color: Color(0xff12175E),
height: 1.1,
),
),
],
),
],
),
ElevatedButton.icon(
onPressed: () => logout(context),
icon: const Icon(Icons.logout_rounded, size: 16),
label: const Text("Logout", style: TextStyle(fontSize: 14)),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white,
foregroundColor: const Color(0xff7F56D9),
elevation: 1,
shadowColor: Colors.black.withOpacity(0.08),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
minimumSize: const Size(0, 40),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
),
],
),
const SizedBox(height: 32),
// Teks Sambutan
const Text(
"Selamat Datang 👋",
style: TextStyle(
fontSize: 16,
color: Color(0xff4B39EF),
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 8),
const Text(
"Dashboard Admin",
style: TextStyle(
fontSize: 32,
fontWeight: FontWeight.bold,
color: Color(0xff12175E),
height: 1.1,
),
),
const SizedBox(height: 14),
Container(
width: 60,
height: 4,
decoration: BoxDecoration(
color: const Color(0xff7F56D9),
borderRadius: BorderRadius.circular(2),
),
),
const SizedBox(height: 20),
const Text(
"Kelola akun guru dan orang tua\ndengan mudah, cepat, dan aman.",
style: TextStyle(
fontSize: 16,
color: Color(0xff6B7280),
height: 1.5,
),
),
],
),
),
),
),
// BAGIAN MENU
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 28),
child: GridView.count(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
crossAxisCount: 2,
crossAxisSpacing: 18,
mainAxisSpacing: 18,
childAspectRatio: 0.82,
children: [
menuCard(
title: "Tambah Guru",
subtitle: "Tambahkan akun guru baru ke dalam sistem.",
icon: Icons.person_add_rounded,
startColor: const Color(0xff7F56D9),
iconBg: const Color(0xffF0EBFF),
btnColor: const Color(0xff7F56D9),
onTap: () => Navigator.push(
context,
MaterialPageRoute(builder: (_) => const TambahUser(role: 'guru')),
),
),
menuCard(
title: "Hapus Akun Guru",
subtitle: "Manajemen atau hapus akun guru dari sistem.",
icon: Icons.person_remove_rounded,
startColor: const Color(0xffF472B6),
iconBg: const Color(0xffFEEFF8),
btnColor: const Color(0xffF472B6),
onTap: () => showHapusDialog(context, 'guru'),
),
menuCard(
title: "Tambah Orang Tua",
subtitle: "Tambahkan akun orang tua baru ke dalam sistem.",
icon: Icons.family_restroom_rounded,
startColor: const Color(0xff3B82F6),
iconBg: const Color(0xffEFF6FF),
btnColor: const Color(0xff3B82F6),
onTap: () => Navigator.push(
context,
MaterialPageRoute(builder: (_) => const TambahSiswa()),
),
),
menuCard(
title: "Hapus Akun Orang Tua",
subtitle: "Manajemen atau hapus akun orang tua dari sistem.",
icon: Icons.delete_rounded,
startColor: const Color(0xffF97316),
iconBg: const Color(0xffFFF7ED),
btnColor: const Color(0xffF97316),
onTap: () => showHapusDialog(context, 'ortu'),
),
],
),
),
],
),
),
);
}
}
class CornerCurvePainter extends CustomPainter {
final Color color;
CornerCurvePainter({required this.color});
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()
..color = color.withOpacity(0.15)
..style = PaintingStyle.fill;
final path = Path();
path.moveTo(0, 0);
path.lineTo(size.width, 0);
path.quadraticBezierTo(size.width * 0.6, size.height * 0.45, size.width * 0.5, size.height);
path.lineTo(0, size.height);
path.close();
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
}

498
lib/dashboard_guru.dart Normal file
View File

@ -0,0 +1,498 @@
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'dart:ui'; // Diperlukan untuk efek Glassmorphism BackdropFilter
import 'login_page.dart';
import 'tambah_siswa.dart';
import 'data_siswa.dart';
import 'absensi_page.dart';
import 'laporan_page.dart';
class DashboardGuru extends StatelessWidget {
const DashboardGuru({super.key});
void logout(BuildContext context) async {
await FirebaseAuth.instance.signOut();
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(builder: (_) => const LoginPage()),
(route) => false,
);
}
/// Komponen Kartu Menu Utama - Ukuran Super Ringkas & Anti Overflow
Widget menuCard({
required IconData icon,
required Color baseColor,
required String title,
required String subtitle,
required List<Color> cardGradients,
required VoidCallback onTap,
bool hasExtraNode = false,
}) {
return Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20), // Diperkecil dari 24 ke 20
boxShadow: [
BoxShadow(
color: baseColor.withOpacity(0.06),
blurRadius: 16,
spreadRadius: 0,
offset: const Offset(0, 8),
),
],
),
child: ClipRRect(
borderRadius: BorderRadius.circular(20),
child: Stack(
children: [
// Lengkungan pojok kiri atas (diperkecil ukurannya)
Positioned(
top: 0,
left: 0,
child: CustomPaint(
size: const Size(65, 65), // Diperkecil dari 85 ke 65
painter: CornerCurvePainter(color: baseColor),
),
),
// Titik-titik hiasan di pojok kanan atas
Positioned(
top: 14,
right: 14,
child: Column(
children: List.generate(3, (_) => Row(
children: List.generate(3, (_) => Container(
width: 3,
height: 3,
margin: const EdgeInsets.all(1.5),
decoration: BoxDecoration(
color: baseColor.withOpacity(0.2),
shape: BoxShape.circle,
),
)),
)),
),
),
if (hasExtraNode)
Positioned(
top: 18,
right: 28,
child: Opacity(
opacity: 0.25,
child: Icon(Icons.mediation_rounded, size: 16, color: baseColor),
),
),
Material(
color: Colors.transparent,
child: InkWell(
onTap: onTap,
child: Padding(
padding: const EdgeInsets.all(14.0), // Padding diperkecil agar ruang makin lega
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Lingkaran Icon Lebih Kecil
Container(
height: 40, // Diperkecil dari 48 ke 40
width: 40,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: baseColor.withOpacity(0.1),
),
child: Icon(icon, size: 20, color: baseColor),
),
const SizedBox(height: 10),
// Teks dengan ukuran lebih ketat
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min, // Memaksa layout mengambil ruang sekecil mungkin
children: [
Text(
title,
style: const TextStyle(
fontSize: 14, // Diperkecil ke 14
fontWeight: FontWeight.bold,
color: Color(0xff12175E),
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 2),
Text(
subtitle,
style: TextStyle(
fontSize: 10.5, // Diperkecil ke 10.5
color: const Color(0xff12175E).withOpacity(0.55),
height: 1.2,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
],
),
),
// Tombol Panah Aksi Lebih Kecil
Align(
alignment: Alignment.bottomRight,
child: Container(
height: 26, // Diperkecil dari 32 ke 26
width: 26,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: baseColor,
),
child: const Icon(Icons.arrow_forward_rounded, color: Colors.white, size: 14),
),
),
],
),
),
),
),
],
),
),
);
}
@override
Widget build(BuildContext context) {
final user = FirebaseAuth.instance.currentUser;
if (user == null) {
return const Scaffold(body: Center(child: Text("User belum login")));
}
final screenHeight = MediaQuery.of(context).size.height;
final screenWidth = MediaQuery.of(context).size.width;
return Scaffold(
backgroundColor: const Color(0xffF6F5FB),
body: StreamBuilder<DocumentSnapshot>(
stream: FirebaseFirestore.instance.collection('users').doc(user.uid).snapshots(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: CircularProgressIndicator());
}
final data = snapshot.hasData && snapshot.data!.exists
? snapshot.data!.data() as Map<String, dynamic>
: {};
final nama = data['nama'] ?? 'Guru';
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
/// ==================== 1. HEADER AREA ====================
Container(
width: double.infinity,
height: screenHeight * 0.38,
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [Color(0xffE6DFFF), Color(0xffCCBFFF)],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(40),
bottomRight: Radius.circular(40),
),
boxShadow: [
BoxShadow(
color: Color(0xff7F56D9),
blurRadius: 24,
offset: Offset(0, 8),
),
],
),
child: ClipRRect(
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(40),
bottomRight: Radius.circular(40),
),
child: Stack(
children: [
Positioned(
top: -40,
left: -20,
child: Container(
width: 180,
height: 180,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white.withOpacity(0.15),
),
),
),
Positioned.fill(
child: CustomPaint(painter: HeaderWavePainter()),
),
Positioned(top: 50, left: 24, child: _buildGridDots()),
Positioned(top: 70, left: screenWidth * 0.46, child: _buildGridDots()),
// Tombol Logout
Positioned(
top: 50,
right: 24,
child: Container(
height: 44,
width: 44,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(14),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.06),
blurRadius: 12,
offset: const Offset(0, 4),
)
],
),
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(14),
onTap: () => logout(context),
child: const Icon(Icons.logout_rounded, color: Color(0xff7F56D9), size: 20),
),
),
),
),
// Gambar Guru
Positioned(
right: -22,
bottom: -10,
child: Image.asset(
'lib/assets/icon_guru.png',
height: screenHeight * 0.30,
fit: BoxFit.contain,
errorBuilder: (_, __, ___) => Container(
padding: const EdgeInsets.only(right: 30, bottom: 20),
child: const Icon(Icons.account_box_rounded, size: 130, color: Color(0xff9181F4)),
),
),
),
// Kartu Glassmorphic Welcome
Positioned(
left: 20,
bottom: 24,
child: ClipRRect(
borderRadius: BorderRadius.circular(24),
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 12, sigmaY: 12),
child: Container(
width: screenWidth * 0.40,
padding: const EdgeInsets.all(18),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.45),
borderRadius: BorderRadius.circular(24),
border: Border.all(color: Colors.white.withOpacity(0.5), width: 1.5),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Image.asset(
'lib/assets/sekolah.png',
height: 50,
fit: BoxFit.contain,
errorBuilder: (_, __, ___) => const Icon(Icons.school, size: 40, color: Colors.green),
),
const SizedBox(height: 12),
const Text(
"Selamat Datang di",
style: TextStyle(color: Color(0xff12175E), fontSize: 13, fontWeight: FontWeight.w600),
),
const SizedBox(height: 2),
Text(
"Dashboard\nGuru $nama",
style: const TextStyle(
color: Color(0xff12175E),
fontSize: 22,
fontWeight: FontWeight.bold,
height: 1.2,
letterSpacing: -0.5,
),
),
const SizedBox(height: 10),
Row(
children: [
Container(width: 35, height: 4, decoration: BoxDecoration(color: const Color(0xff7F56D9), borderRadius: BorderRadius.circular(2))),
const SizedBox(width: 4),
Container(width: 4, height: 4, decoration: const BoxDecoration(color: Color(0xff7F56D9), shape: BoxShape.circle)),
],
),
],
),
),
),
),
),
],
),
),
),
const SizedBox(height: 24),
/// ==================== 2. TITLE MENU UTAMA ====================
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Icon(Icons.grid_view_rounded, color: const Color(0xff7F56D9), size: 22),
const SizedBox(width: 8),
const Text(
"Menu Utama",
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Color(0xff12175E)),
),
],
),
const SizedBox(height: 6),
Row(
children: [
Container(width: 24, height: 3, decoration: BoxDecoration(color: const Color(0xff7F56D9), borderRadius: BorderRadius.circular(1.5))),
const SizedBox(width: 3),
Container(width: 3, height: 3, decoration: const BoxDecoration(color: Color(0xff7F56D9), shape: BoxShape.circle)),
],
),
],
),
),
const SizedBox(height: 16),
/// ==================== 3. GRID MENU UTAMA ====================
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: GridView(
physics: const NeverScrollableScrollPhysics(),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 16,
mainAxisSpacing: 16,
childAspectRatio: 0.92, // Diubah ke 0.92 agar rasio kotak lebih pendek & aman overflow
),
children: [
menuCard(
icon: Icons.person_add_alt_1_rounded,
baseColor: const Color(0xff7F56D9),
title: "Tambah Siswa",
subtitle: "Tambah data siswa baru ke sistem",
cardGradients: [const Color(0xffF9F5FF), const Color(0xffF3E8FF)],
hasExtraNode: true,
onTap: () => Navigator.push(context, MaterialPageRoute(builder: (_) => const TambahSiswa())),
),
menuCard(
icon: Icons.groups_rounded,
baseColor: const Color(0xff0284C7),
title: "Data Siswa",
subtitle: "Lihat & kelola informasi siswa",
cardGradients: [const Color(0xffF0F9FF), const Color(0xffE0F2FE)],
onTap: () => Navigator.push(context, MaterialPageRoute(builder: (_) => const DataSiswa())),
),
menuCard(
icon: Icons.assignment_turned_in_rounded,
baseColor: const Color(0xff16A34A),
title: "Absensi",
subtitle: "Catat & periksa kehadiran siswa",
cardGradients: [const Color(0xffF0FDF4), const Color(0xffDCFCE7)],
onTap: () => Navigator.push(context, MaterialPageRoute(builder: (_) => const AbsensiPage())),
),
menuCard(
icon: Icons.bar_chart_rounded,
baseColor: const Color(0xffEA580C),
title: "Laporan Absensi",
subtitle: "Lihat ringkasan laporan kehadiran",
cardGradients: [const Color(0xffFFF7ED), const Color(0xffFFEDD5)],
onTap: () => Navigator.push(context, MaterialPageRoute(builder: (_) => const LaporanPage())),
),
],
),
),
),
const SizedBox(height: 12),
],
);
},
),
);
}
Widget _buildGridDots() {
return Opacity(
opacity: 0.25,
child: Column(
children: List.generate(4, (_) => Row(
children: List.generate(4, (_) => Container(
width: 2.5,
height: 2.5,
margin: const EdgeInsets.all(2.5),
decoration: const BoxDecoration(color: Color(0xff12175E), shape: BoxShape.circle),
)),
)),
),
);
}
}
class CornerCurvePainter extends CustomPainter {
final Color color;
CornerCurvePainter({required this.color});
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()
..color = color.withOpacity(0.15)
..style = PaintingStyle.fill;
final path = Path();
path.moveTo(0, 0);
path.lineTo(size.width, 0);
path.quadraticBezierTo(size.width * 0.6, size.height * 0.45, size.width * 0.5, size.height);
path.lineTo(0, size.height);
path.close();
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
}
class HeaderWavePainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()
..color = Colors.white.withOpacity(0.18)
..style = PaintingStyle.stroke
..strokeWidth = 2.0;
final path1 = Path();
path1.moveTo(0, size.height * 0.3);
path1.cubicTo(size.width * 0.25, size.height * 0.1, size.width * 0.6, size.height * 0.5, size.width, size.height * 0.25);
canvas.drawPath(path1, paint);
final path2 = Path();
path2.moveTo(0, size.height * 0.5);
path2.cubicTo(size.width * 0.35, size.height * 0.2, size.width * 0.7, size.height * 0.6, size.width, size.height * 0.4);
canvas.drawPath(path2, paint);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
}

826
lib/dashboard_ortu.dart Normal file
View File

@ -0,0 +1,826 @@
import 'dart:io';
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_database/firebase_database.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:image_picker/image_picker.dart';
import 'login_page.dart';
class DashboardOrtu extends StatefulWidget {
const DashboardOrtu({super.key});
@override
State<DashboardOrtu> createState() => _DashboardOrtuState();
}
class _DashboardOrtuState extends State<DashboardOrtu> {
final refAbsen = FirebaseDatabase.instance.ref("absensi");
final refIzin = FirebaseDatabase.instance.ref("izin");
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
final Set<String> notified = {};
String today() => DateTime.now().toString().substring(0, 10);
@override
void initState() {
super.initState();
initNotif();
}
Future<void> initNotif() async {
const android = AndroidInitializationSettings('@mipmap/ic_launcher');
const settings = InitializationSettings(android: android);
await flutterLocalNotificationsPlugin.initialize(settings: settings);
}
Future<void> showNotif(String title, String body) async {
const androidDetails = AndroidNotificationDetails(
'absensi_channel',
'Absensi',
importance: Importance.max,
priority: Priority.high,
);
const details = NotificationDetails(android: androidDetails);
await flutterLocalNotificationsPlugin.show(
id: 0,
title: title,
body: body,
notificationDetails: details,
);
}
Color warnaBgStatus(String status) {
if (status == "tepat_waktu") return const Color(0xffE8F5E9);
if (status == "telat") return const Color(0xffFFF3E0);
if (status == "pulang") return const Color(0xffE3F2FD);
if (status == "izin") return const Color(0xffE0F2FE);
if (status == "sakit") return const Color(0xffF3E5F5);
return const Color(0xffFFEBEE);
}
Color warnaTeksStatus(String status) {
if (status == "tepat_waktu") return const Color(0xff2E7D32);
if (status == "telat") return const Color(0xffEF6C00);
if (status == "pulang") return const Color(0xff1565C0);
if (status == "izin") return const Color(0xff0284C7);
if (status == "sakit") return const Color(0xff8E24AA);
return const Color(0xffD32F2F);
}
IconData iconStatus(String status) {
if (status == "tepat_waktu") return Icons.check_circle_rounded;
if (status == "telat") return Icons.warning_rounded;
if (status == "pulang") return Icons.exit_to_app_rounded;
if (status == "izin") return Icons.info_rounded;
if (status == "sakit") return Icons.local_hospital_rounded;
return Icons.cancel_rounded;
}
void kirimIzin(String nama, String rfid) {
final jenis = ValueNotifier("izin");
File? imageFile;
showDialog(
context: context,
builder: (_) => StatefulBuilder(
builder: (context, setStateDialog) {
return AlertDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
title: const Text(
"Ajukan Izin / Sakit",
style: TextStyle(fontWeight: FontWeight.bold, color: Color(0xff1E1B4B)),
),
content: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ValueListenableBuilder(
valueListenable: jenis,
builder: (_, val, __) {
return DropdownButtonFormField<String>(
value: val,
decoration: InputDecoration(
labelText: "Pilih Keterangan",
labelStyle: const TextStyle(color: Color(0xff6B7280)),
border: OutlineInputBorder(borderRadius: BorderRadius.circular(16)),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: const BorderSide(color: Color(0xffE5E7EB)),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: const BorderSide(color: Color(0xff7F56D9), width: 2),
),
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
),
items: const [
DropdownMenuItem(value: "izin", child: Text("Izin / Berhalangan")),
DropdownMenuItem(value: "sakit", child: Text("Sakit")),
],
onChanged: (v) => jenis.value = v!,
);
},
),
const SizedBox(height: 20),
ElevatedButton.icon(
onPressed: () async {
final picker = ImagePicker();
final picked = await picker.pickImage(source: ImageSource.gallery, imageQuality: 50);
if (picked != null) {
setStateDialog(() => imageFile = File(picked.path));
}
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xffF3E8FF),
foregroundColor: const Color(0xff7F56D9),
elevation: 0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
minimumSize: const Size(double.infinity, 50),
),
icon: const Icon(Icons.image_rounded),
label: const Text("Pilih Foto Surat Dokter / Wali", style: TextStyle(fontWeight: FontWeight.w600)),
),
if (imageFile != null) ...[
const SizedBox(height: 16),
Stack(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(16),
child: Image.file(imageFile!, height: 160, width: double.infinity, fit: BoxFit.cover),
),
Positioned(
top: 8,
right: 8,
child: GestureDetector(
onTap: () => setStateDialog(() => imageFile = null),
child: Container(
padding: const EdgeInsets.all(4),
decoration: const BoxDecoration(color: Colors.black54, shape: BoxShape.circle),
child: const Icon(Icons.close, color: Colors.white, size: 18),
),
),
)
],
)
]
],
),
),
actionsPadding: const EdgeInsets.only(bottom: 16, right: 16, left: 16),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text("Batal", style: TextStyle(color: Color(0xff6B7280), fontWeight: FontWeight.w600)),
),
ElevatedButton(
onPressed: () async {
if (imageFile == null) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("Pilih foto surat terlebih dahulu"), backgroundColor: Colors.amber),
);
return;
}
try {
final bytes = await imageFile!.readAsBytes();
final base64 = base64Encode(bytes);
await refIzin.push().set({
"nama": nama,
"rfid": rfid,
"jenis": jenis.value,
"foto": base64,
"tanggal": today(),
"waktu": ServerValue.timestamp,
});
if (context.mounted) Navigator.pop(context);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("Izin berhasil dikirim"), backgroundColor: Colors.green),
);
} catch (e) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text("Gagal: $e")));
}
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xff7F56D9),
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
),
child: const Text("Kirim Permohonan", style: TextStyle(fontWeight: FontWeight.w600)),
)
],
);
},
),
);
}
/// Fungsi Reset Data Lama
Future<void> resetDataLama(String rfid) async {
try {
final now = DateTime.now();
final batas = DateTime(now.year, now.month, now.day - 30); // Simpan hanya 30 hari terakhir
final snapshot = await refAbsen.child(rfid).get();
if (snapshot.exists) {
final data = Map<String, dynamic>.from(snapshot.value as Map);
for (final tanggal in data.keys) {
try {
final tgl = DateTime.parse(tanggal);
if (tgl.isBefore(batas)) {
await refAbsen.child("$rfid/$tanggal").remove();
}
} catch (_) {}
}
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("Data lama berhasil dibersihkan"), backgroundColor: Colors.blue),
);
}
}
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text("Gagal bersihkan data: $e"), backgroundColor: Colors.red),
);
}
}
}
/// Tampilkan Riwayat Absen
void lihatRiwayatAbsen(String rfid, String nama) {
showModalBottomSheet(
context: context,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(28)),
),
isScrollControlled: true,
builder: (_) => DraggableScrollableSheet(
initialChildSize: 0.75,
maxChildSize: 0.9,
minChildSize: 0.5,
expand: false,
builder: (_, scrollController) => Padding(
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Riwayat Absen: $nama",
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: Color(0xff1E1B4B)),
),
IconButton(
onPressed: () => Navigator.pop(context),
icon: const Icon(Icons.close, color: Color(0xff6B7280)),
)
],
),
const Divider(),
const SizedBox(height: 8),
Expanded(
child: StreamBuilder(
stream: refAbsen.child(rfid).orderByKey().limitToLast(30).onValue,
builder: (_, snap) {
if (!snap.hasData || snap.data?.snapshot.value == null) {
return const Center(child: Text("Belum ada riwayat absen"));
}
final data = Map<String, dynamic>.from(snap.data!.snapshot.value as Map);
final daftarTanggal = data.keys.toList()..sort((a, b) => b.compareTo(a));
return ListView.builder(
controller: scrollController,
itemCount: daftarTanggal.length,
itemBuilder: (_, i) {
final tgl = daftarTanggal[i];
final absen = Map<String, dynamic>.from(data[tgl]);
String jamMasuk = "-", statusMasuk = "tidak_hadir";
String jamPulang = "-", statusPulang = "tidak_hadir";
if (absen['masuk'] != null) {
final m = Map<String, dynamic>.from(absen['masuk']);
jamMasuk = m['jam'] ?? "-";
statusMasuk = m['status'] ?? "tidak_hadir";
} else {
jamMasuk = absen['jam'] ?? "-";
statusMasuk = absen['status'] ?? "tidak_hadir";
}
if (absen['pulang'] != null) {
final p = Map<String, dynamic>.from(absen['pulang']);
jamPulang = p['jam'] ?? "-";
statusPulang = p['status'] ?? "tidak_hadir";
}
return Container(
margin: const EdgeInsets.only(bottom: 12),
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
boxShadow: const [BoxShadow(color: Color(0x0A000000), blurRadius: 6)],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
tgl,
style: const TextStyle(fontWeight: FontWeight.bold, color: Color(0xff1E1B4B)),
),
const SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
_buildRiwayatItem("Masuk", jamMasuk, statusMasuk),
_buildRiwayatItem("Pulang", jamPulang, statusPulang),
],
)
],
),
);
},
);
},
),
),
const SizedBox(height: 12),
SizedBox(
width: double.infinity,
child: ElevatedButton.icon(
onPressed: () async {
Navigator.pop(context);
await resetDataLama(rfid);
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xffEF4444),
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
padding: const EdgeInsets.symmetric(vertical: 12),
),
icon: const Icon(Icons.delete_sweep),
label: const Text("Bersihkan Data Lama (>30 Hari)"),
),
)
],
),
),
),
);
}
Widget _buildRiwayatItem(String label, String jam, String status) {
return Row(
children: [
Icon(iconStatus(status), size: 18, color: warnaTeksStatus(status)),
const SizedBox(width: 6),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(label, style: const TextStyle(fontSize: 12, color: Color(0xff6B7280), fontWeight: FontWeight.w500)),
Text(jam, style: const TextStyle(fontWeight: FontWeight.bold)),
],
)
],
);
}
/// Langsung buka riwayat tanpa pilih anak
void bukaRiwayatLangsung() async {
final uidUser = FirebaseAuth.instance.currentUser!.uid;
final snap = await FirebaseFirestore.instance
.collection('siswa')
.where('ortu_uid', isEqualTo: uidUser)
.limit(1) // Ambil data anak pertama saja
.get();
if (!mounted) return;
if (snap.docs.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("Belum ada data anak terdaftar")),
);
return;
}
final data = snap.docs.first.data();
final nama = data['nama'] ?? 'Tidak ada nama';
final rfid = data['rfid'] ?? '';
lihatRiwayatAbsen(rfid, nama);
}
@override
Widget build(BuildContext context) {
final uidUser = FirebaseAuth.instance.currentUser!.uid;
final screen = MediaQuery.of(context);
return Scaffold(
backgroundColor: const Color(0xffF9FAFB),
body: SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: Stack(
children: [
// Background Header Gradasi Melengkung Halus
Container(
width: double.infinity,
height: screen.size.height * 0.38,
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [Color(0xffECE7FF), Color(0xffF9FAFB)],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(40),
bottomRight: Radius.circular(40),
),
),
),
// Konten Utama
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 50),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Top Bar: Brand Logo & Aksi Tombol
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Image.asset(
'lib/assets/sekolah.png',
width: 50,
height: 50,
fit: BoxFit.contain,
errorBuilder: (_, __, ___) => const Icon(Icons.school_rounded, size: 45, color: Color(0xff7F56D9)),
),
const SizedBox(width: 12),
const Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("E-Absensi", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16, color: Color(0xff1E1B4B))),
Text("Sistem Pemantauan", style: TextStyle(fontSize: 12, color: Color(0xff6B7280))),
],
)
],
),
Row(
children: [
// Klik lonceng langsung ke riwayat
_buildIconButton(Icons.notifications_none_rounded, bukaRiwayatLangsung),
const SizedBox(width: 10),
_buildIconButton(Icons.logout_rounded, () async {
await FirebaseAuth.instance.signOut();
if (context.mounted) {
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(builder: (_) => const LoginPage()),
(_) => false,
);
}
}),
],
)
],
),
const SizedBox(height: 32),
// Banner Selamat Datang Terintegrasi Ilustrasi
Container(
width: double.infinity,
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
gradient: const LinearGradient(
colors: [Color(0xff7F56D9), Color(0xff633BB3)],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.circular(28),
boxShadow: [
BoxShadow(color: const Color(0xff7F56D9).withOpacity(0.2), blurRadius: 15, offset: const Offset(0, 8))
],
),
child: Stack(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text("Selamat Datang Kembali,", style: TextStyle(fontSize: 14, color: Color(0xffE2D6FF))),
const SizedBox(height: 4),
const Text(
"Dashboard\nWali Murid",
style: TextStyle(fontSize: 26, fontWeight: FontWeight.bold, color: Colors.white, height: 1.2),
),
const SizedBox(height: 12),
Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(color: Colors.white.withOpacity(0.15), borderRadius: BorderRadius.circular(100)),
child: Text(
today(),
style: const TextStyle(color: Colors.white, fontSize: 12, fontWeight: FontWeight.w500),
),
)
],
),
Positioned(
right: -10,
bottom: -10,
child: Opacity(
opacity: 0.9,
child: Image.asset(
'lib/assets/anak_rfid.png',
width: screen.size.width * 0.38,
height: 130,
fit: BoxFit.contain,
errorBuilder: (_, __, ___) => const SizedBox(),
),
),
)
],
),
),
const SizedBox(height: 32),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
"Daftar Kehadiran Anak",
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Color(0xff1E1B4B)),
),
],
),
const SizedBox(height: 16),
// Data Siswa & Log Stream Builder
StreamBuilder(
stream: FirebaseFirestore.instance
.collection('siswa')
.where('ortu_uid', isEqualTo: uidUser)
.snapshots(),
builder: (_, siswaSnap) {
if (!siswaSnap.hasData) {
return const Center(child: CircularProgressIndicator(color: Color(0xff7F56D9)));
}
final siswaList = siswaSnap.data!.docs;
if (siswaList.isEmpty) {
return Container(
width: double.infinity,
padding: const EdgeInsets.all(32),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(24),
border: Border.all(color: const Color(0xffF3E5F5)),
),
child: const Column(
children: [
Icon(Icons.child_care_rounded, size: 48, color: Color(0xff9CA3AF)),
SizedBox(height: 12),
Text("Belum ada data relasi anak terdaftar.", style: TextStyle(color: Color(0xff6B7280))),
],
),
);
}
return Column(
children: siswaList.map((doc) {
final data = doc.data();
final rfid = data['rfid'] ?? '';
final nama = data['nama'] ?? 'Nama Siswa';
final kelas = data['kelas'] ?? '-';
final namaOrtu = data['nama_orang_tua'] ?? 'Nama Orang Tua';
return StreamBuilder(
stream: refAbsen.child("$rfid/${today()}").onValue,
builder: (_, absenSnap) {
String statusMasuk = "tidak_hadir";
String jamMasuk = "-";
String statusPulang = "tidak_hadir";
String jamPulang = "-";
String statusUtama = "tidak_hadir";
if (absenSnap.hasData && absenSnap.data!.snapshot.value != null) {
final raw = absenSnap.data!.snapshot.value as Map;
final absenData = Map<String, dynamic>.from(raw);
if (absenData['masuk'] != null) {
final m = Map<String, dynamic>.from(absenData['masuk']);
statusMasuk = m['status'] ?? "tidak_hadir";
jamMasuk = m['jam'] ?? "-";
} else {
statusMasuk = absenData['status'] ?? "tidak_hadir";
jamMasuk = absenData['jam'] ?? "-";
}
if (absenData['pulang'] != null) {
final p = Map<String, dynamic>.from(absenData['pulang']);
statusPulang = p['status'] ?? "tidak_hadir";
jamPulang = p['jam'] ?? "-";
}
if (statusPulang != "tidak_hadir") {
statusUtama = statusPulang;
} else {
statusUtama = statusMasuk;
}
// Pengkondisian Notifikasi Pemicu Lokal
final keyMasuk = "$rfid-masuk-$statusMasuk-$jamMasuk";
if (!notified.contains(keyMasuk) && statusMasuk != "tidak_hadir") {
notified.add(keyMasuk);
WidgetsBinding.instance.addPostFrameCallback((_) {
showNotif("Absen Masuk $nama", "Status: ${statusMasuk.replaceAll('_', ' ')} • Jam: $jamMasuk");
});
}
final keyPulang = "$rfid-pulang-$statusPulang-$jamPulang";
if (!notified.contains(keyPulang) && statusPulang != "tidak_hadir") {
notified.add(keyPulang);
WidgetsBinding.instance.addPostFrameCallback((_) {
showNotif("Absen Pulang $nama", "Status: $statusPulang • Jam: $jamPulang");
});
}
}
return Container(
width: double.infinity,
margin: const EdgeInsets.only(bottom: 24),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(24),
boxShadow: [
BoxShadow(color: const Color(0xff1E1B4B).withOpacity(0.04), blurRadius: 16, offset: const Offset(0, 4))
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Header Info Siswa Di Dalam Kartu
Padding(
padding: const EdgeInsets.all(20),
child: Row(
children: [
Container(
width: 48,
height: 48,
decoration: BoxDecoration(
color: const Color(0xffF3E8FF),
borderRadius: BorderRadius.circular(16),
),
child: const Icon(Icons.face_rounded, color: Color(0xff7F56D9), size: 26),
),
const SizedBox(width: 14),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
nama,
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Color(0xff1E1B4B)),
),
Text(
"Kelas $kelas",
style: const TextStyle(fontSize: 13, color: Color(0xff6B7280), fontWeight: FontWeight.w500),
),
const SizedBox(height: 4),
Text(
"👨‍👩‍👧 $namaOrtu",
style: const TextStyle(fontSize: 12, color: Color(0xff7F56D9), fontWeight: FontWeight.w600),
),
],
),
),
Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(
color: warnaBgStatus(statusUtama),
borderRadius: BorderRadius.circular(100),
),
child: Text(
statusUtama.toUpperCase().replaceAll('_', ' '),
style: TextStyle(fontSize: 11, fontWeight: FontWeight.bold, color: warnaTeksStatus(statusUtama)),
),
)
],
),
),
// Linimasa Detail Alur Absensi Masuk & Pulang
Container(
margin: const EdgeInsets.symmetric(horizontal: 20),
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: const Color(0xffF9FAFB),
borderRadius: BorderRadius.circular(20),
),
child: Row(
children: [
_buildTimeLogTile("Masuk Sekolah", jamMasuk, statusMasuk),
Container(width: 1, height: 45, color: const Color(0xffE5E7EB)),
_buildTimeLogTile("Pulang Sekolah", jamPulang, statusPulang),
],
),
),
Padding(
padding: const EdgeInsets.all(20),
child: Row(
children: [
Expanded(
child: ElevatedButton(
onPressed: () => kirimIzin(nama, rfid),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white,
foregroundColor: const Color(0xff7F56D9),
elevation: 0,
side: const BorderSide(color: Color(0xffE5E7EB)),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
minimumSize: const Size(double.infinity, 48),
),
child: const Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.edit_document, size: 18),
SizedBox(width: 8),
Text("Ajukan Izin / Sakit", style: TextStyle(fontWeight: FontWeight.w600, fontSize: 14)),
],
),
),
),
],
),
)
],
),
);
},
);
}).toList(),
);
},
),
],
),
),
],
),
),
);
}
Widget _buildIconButton(IconData icon, VoidCallback onTap) {
return Container(
width: 44,
height: 44,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(14),
boxShadow: [
BoxShadow(color: const Color(0xff1E1B4B).withOpacity(0.04), blurRadius: 8, offset: const Offset(0, 2))
],
),
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(14),
onTap: onTap,
child: Icon(icon, color: const Color(0xff7F56D9), size: 22),
),
),
);
}
Widget _buildTimeLogTile(String label, String time, String status) {
return Expanded(
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(iconStatus(status), size: 16, color: warnaTeksStatus(status)),
const SizedBox(width: 6),
Text(label, style: const TextStyle(fontSize: 12, color: Color(0xff6B7280), fontWeight: FontWeight.w500)),
],
),
const SizedBox(height: 6),
Text(
time,
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: Color(0xff1E1B4B)),
),
],
),
);
}
}

511
lib/data_siswa.dart Normal file
View File

@ -0,0 +1,511 @@
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_database/firebase_database.dart';
class DataSiswa extends StatelessWidget {
const DataSiswa({super.key});
Future<void> hapusSiswa(
String docId,
String rfid,
String ortuUid,
BuildContext context,
) async {
try {
await FirebaseFirestore.instance
.collection('siswa')
.doc(docId)
.delete();
await FirebaseFirestore.instance
.collection('users')
.doc(ortuUid)
.delete();
await FirebaseDatabase.instance
.ref("siswa/$rfid")
.remove();
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Data siswa berhasil dihapus'),
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10))),
),
);
}
} catch (e) {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text("Error : $e"),
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10))),
),
);
}
}
}
Widget siswaCard(
BuildContext context,
String docId,
String nama,
String kelas,
String namaOrtu,
String nomorAbsen,
String rfid,
String ortuUid,
) {
return Container(
margin: const EdgeInsets.only(left: 24, right: 24, bottom: 20),
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(24),
boxShadow: [
BoxShadow(
color: const Color(0xff0284C7).withOpacity(0.08),
blurRadius: 24,
spreadRadius: 0,
offset: const Offset(0, 12),
),
],
),
child: Row(
children: [
// Avatar lingkaran dengan warna sesuai tema
Container(
width: 60,
height: 60,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: const Color(0xff0284C7).withOpacity(0.12),
boxShadow: [
BoxShadow(
color: const Color(0xff0284C7).withOpacity(0.15),
blurRadius: 12,
spreadRadius: 2,
),
],
),
child: const Icon(
Icons.person_rounded,
color: Color(0xff0284C7),
size: 28,
),
),
const SizedBox(width: 16),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
nama,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontSize: 17,
fontWeight: FontWeight.bold,
color: Color(0xff12175E),
),
),
const SizedBox(height: 6),
Text(
"Kelas: $kelas",
style: TextStyle(
fontSize: 14,
color: const Color(0xff12175E).withOpacity(0.6),
),
),
const SizedBox(height: 4),
Text(
"Orang Tua: $namaOrtu",
style: TextStyle(
fontSize: 14,
color: const Color(0xff12175E).withOpacity(0.6),
),
),
const SizedBox(height: 4),
Text(
"No. Absen: $nomorAbsen",
style: TextStyle(
fontSize: 14,
color: const Color(0xff12175E).withOpacity(0.6),
),
),
const SizedBox(height: 4),
Text(
"RFID: $rfid",
style: TextStyle(
fontSize: 14,
color: const Color(0xff12175E).withOpacity(0.6),
),
),
],
),
),
// Tombol hapus dengan gaya konsisten
Container(
width: 44,
height: 44,
decoration: BoxDecoration(
color: Colors.red.withOpacity(0.1),
borderRadius: BorderRadius.circular(14),
),
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(14),
onTap: () {
showDialog(
context: context,
builder: (_) => AlertDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
title: const Text(
"Hapus Data Siswa",
style: TextStyle(color: Color(0xff12175E), fontWeight: FontWeight.bold),
),
content: Text(
"Yakin ingin menghapus data siswa:\n\n$nama ?",
style: TextStyle(color: const Color(0xff12175E).withOpacity(0.7)),
),
actionsPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text(
"Batal",
style: TextStyle(color: Colors.grey, fontWeight: FontWeight.w600),
),
),
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.red,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
elevation: 2,
),
onPressed: () {
Navigator.pop(context);
hapusSiswa(docId, rfid, ortuUid, context);
},
child: const Text(
"Hapus",
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
),
),
],
),
);
},
child: const Icon(
Icons.delete_rounded,
color: Colors.red,
size: 22,
),
),
),
),
],
),
);
}
Widget header(BuildContext context) {
final screenHeight = MediaQuery.of(context).size.height;
return Container(
width: double.infinity,
height: screenHeight * 0.24,
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [
Color(0xffE6DFFF),
Color(0xffCCBFFF),
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(40),
bottomRight: Radius.circular(40),
),
boxShadow: [
BoxShadow(
color: Color(0xff7F56D9),
blurRadius: 24,
offset: Offset(0, 8),
),
],
),
child: ClipRRect(
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(40),
bottomRight: Radius.circular(40),
),
child: Stack(
children: [
// Ornamen lingkaran
Positioned(
top: -30,
left: -20,
child: Container(
width: 150,
height: 150,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white.withOpacity(0.15),
),
),
),
// Garis gelombang
Positioned.fill(
child: CustomPaint(painter: HeaderWavePainter()),
),
// Pola titik grid
Positioned(top: 40, left: 24, child: _buildGridDots()),
Positioned(top: 60, right: 60, child: _buildGridDots()),
// Konten header
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 20),
child: Row(
children: [
// Tombol kembali
Container(
height: 44,
width: 44,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(14),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.06),
blurRadius: 12,
offset: const Offset(0, 4),
)
],
),
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(14),
onTap: () => Navigator.pop(context),
child: const Icon(Icons.arrow_back_ios_new, color: Color(0xff7F56D9), size: 18),
),
),
),
const SizedBox(width: 16),
Image.asset(
'lib/assets/sekolah.png',
width: 50,
height: 50,
fit: BoxFit.contain,
errorBuilder: (_, __, ___) => const Icon(Icons.school, size: 40, color: Color(0xff7F56D9)),
),
const SizedBox(width: 12),
const Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Data Siswa",
style: TextStyle(
color: Color(0xff12175E),
fontSize: 22,
fontWeight: FontWeight.bold,
letterSpacing: -0.5,
),
),
SizedBox(height: 4),
Text(
"Daftar seluruh siswa terdaftar",
style: TextStyle(
color: Color(0xff12175E),
fontSize: 14,
fontWeight: FontWeight.w500,
height: 0.7,
),
),
],
),
),
Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.4),
borderRadius: BorderRadius.circular(14),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.04),
blurRadius: 8,
offset: const Offset(0, 2),
)
],
),
child: const Icon(
Icons.groups_rounded,
color: Color(0xff0284C7),
size: 26,
),
),
],
),
),
],
),
),
);
}
Widget _buildGridDots() {
return Opacity(
opacity: 0.25,
child: Column(
children: List.generate(4, (index) => Row(
children: List.generate(4, (index) => Container(
width: 2.5,
height: 2.5,
margin: const EdgeInsets.all(2.5),
decoration: const BoxDecoration(color: Color(0xff12175E), shape: BoxShape.circle),
)),
)),
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xffF6F5FB),
body: SafeArea(
child: Column(
children: [
header(context),
const SizedBox(height: 20),
// Judul bagian
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Row(
children: [
Container(width: 24, height: 3, decoration: BoxDecoration(color: const Color(0xff0284C7), borderRadius: BorderRadius.circular(1.5))),
const SizedBox(width: 3),
Container(width: 3, height: 3, decoration: const BoxDecoration(color: Color(0xff0284C7), shape: BoxShape.circle)),
const SizedBox(width: 8),
const Text(
"DAFTAR SISWA",
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: Color(0xff12175E),
letterSpacing: 0.5,
),
),
],
),
),
const SizedBox(height: 16),
Expanded(
child: StreamBuilder<QuerySnapshot>(
stream: FirebaseFirestore.instance.collection('siswa').snapshots(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator(color: Color(0xff7F56D9)),
);
}
if (!snapshot.hasData || snapshot.data!.docs.isEmpty) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.person_off_rounded,
size: 60,
color: const Color(0xff12175E).withOpacity(0.3),
),
const SizedBox(height: 16),
Text(
"Belum ada data siswa",
style: TextStyle(
fontSize: 16,
color: const Color(0xff12175E).withOpacity(0.5),
fontWeight: FontWeight.w500,
),
),
],
),
);
}
final data = snapshot.data!.docs;
return ListView.builder(
physics: const BouncingScrollPhysics(),
padding: const EdgeInsets.only(bottom: 20),
itemCount: data.length,
itemBuilder: (context, i) {
final s = data[i];
final sMap = (s.data() as Map<String, dynamic>?) ?? {};
final nama = (sMap['nama'] as String?) ?? "Nama Tidak Ada";
final kelas = (sMap['kelas'] as String?) ?? "-";
final namaOrtu = (sMap['nama_orang_tua'] as String?) ?? "-";
final nomorAbsen = (sMap['nomor_absen'] as String?) ?? "-";
final rfid = (sMap['rfid'] as String?) ?? "RFID Tidak Ada";
final ortuUid = sMap['ortu_uid'] as String?;
if (ortuUid == null || ortuUid.isEmpty) return const SizedBox();
return siswaCard(
context,
s.id,
nama,
kelas,
namaOrtu,
nomorAbsen,
rfid,
ortuUid,
);
},
);
},
),
),
],
),
),
);
}
}
// Reusable wave painter (same as dashboard)
class HeaderWavePainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()
..color = Colors.white.withOpacity(0.3)
..style = PaintingStyle.stroke
..strokeWidth = 1.8;
final path = Path();
path.moveTo(0, size.height * 0.4);
path.quadraticBezierTo(size.width * 0.5, size.height * 0.1, size.width, size.height * 0.3);
canvas.drawPath(path, paint);
final path2 = Path();
path2.moveTo(0, size.height * 0.6);
path2.quadraticBezierTo(size.width * 0.6, size.height * 0.2, size.width, size.height * 0.5);
canvas.drawPath(path2, paint);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
}

71
lib/firebase_options.dart Normal file
View File

@ -0,0 +1,71 @@
// File generated by FlutterFire CLI.
// ignore_for_file: type=lint
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
import 'package:flutter/foundation.dart'
show defaultTargetPlatform, kIsWeb, TargetPlatform;
/// Default [FirebaseOptions] for use with your Firebase apps.
///
/// Example:
/// ```dart
/// import 'firebase_options.dart';
/// // ...
/// await Firebase.initializeApp(
/// options: DefaultFirebaseOptions.currentPlatform,
/// );
/// ```
class DefaultFirebaseOptions {
static FirebaseOptions get currentPlatform {
if (kIsWeb) {
return web;
}
switch (defaultTargetPlatform) {
case TargetPlatform.android:
return android;
case TargetPlatform.iOS:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for ios - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
case TargetPlatform.macOS:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for macos - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
case TargetPlatform.windows:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for windows - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
case TargetPlatform.linux:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for linux - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
default:
throw UnsupportedError(
'DefaultFirebaseOptions are not supported for this platform.',
);
}
}
static const FirebaseOptions web = FirebaseOptions(
apiKey: 'AIzaSyDKOMO2dNrHTQymJZlQAZw-sOV4FmP1HLo',
appId: '1:729195667113:web:c73cb6383975ddfabd13b8',
messagingSenderId: '729195667113',
projectId: 'absensi-febe3',
authDomain: 'absensi-febe3.firebaseapp.com',
databaseURL: 'https://absensi-febe3-default-rtdb.firebaseio.com',
storageBucket: 'absensi-febe3.firebasestorage.app',
measurementId: 'G-9703BP5SWY',
);
static const FirebaseOptions android = FirebaseOptions(
apiKey: 'AIzaSyDu-NE4S2JFSt5V0vbXJyeqe__c8nwvs_s',
appId: '1:729195667113:android:02251dfb48de22a8bd13b8',
messagingSenderId: '729195667113',
projectId: 'absensi-febe3',
databaseURL: 'https://absensi-febe3-default-rtdb.firebaseio.com',
storageBucket: 'absensi-febe3.firebasestorage.app',
);
}

979
lib/laporan_page.dart Normal file
View File

@ -0,0 +1,979 @@
import 'dart:io';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:excel/excel.dart';
import 'package:firebase_database/firebase_database.dart';
import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart';
class LaporanPage extends StatefulWidget {
const LaporanPage({super.key});
@override
State<LaporanPage> createState() => _LaporanPageState();
}
class _LaporanPageState extends State<LaporanPage> {
final refAbsen = FirebaseDatabase.instance.ref("absensi");
List siswaList = [];
String selectedFilter = "harian";
DateTime selectedDate = DateTime.now();
DateTime? selectedMonth;
DateTime? selectedYear;
@override
void initState() {
super.initState();
loadSiswa();
}
// ================= LOAD DATA SISWA =================
Future<void> loadSiswa() async {
final snap = await FirebaseFirestore.instance.collection("siswa").get();
setState(() {
siswaList = snap.docs;
});
}
// ================= WARNA STATUS SESUAI TEMA =================
Color getStatusTextColor(String status) {
switch (status) {
case "tepat_waktu":
return const Color(0xff16A34A);
case "telat":
return const Color(0xffEA580C);
case "izin":
return const Color(0xff7C3AED);
case "sakit":
return const Color(0xff9333EA);
case "pulang":
return const Color(0xff0284C7);
default:
return const Color(0xffDC2626);
}
}
Color getStatusBgColor(String status) {
switch (status) {
case "tepat_waktu":
return const Color(0xffF0FDF4);
case "telat":
return const Color(0xffFFF7ED);
case "izin":
return const Color(0xffFAF5FF);
case "sakit":
return const Color(0xffF3E8FF);
case "pulang":
return const Color(0xffF0F9FF);
default:
return const Color(0xffFEF2F2);
}
}
// ================= ICON STATUS =================
IconData getStatusIcon(String status) {
switch (status) {
case "tepat_waktu":
return Icons.check_circle_rounded;
case "telat":
return Icons.warning_rounded;
case "izin":
return Icons.description_rounded;
case "sakit":
return Icons.local_hospital_rounded;
case "pulang":
return Icons.exit_to_app_rounded;
default:
return Icons.cancel_rounded;
}
}
// ================= UBAH NAMA STATUS =================
String getStatusLabel(String status) {
switch (status) {
case "tepat_waktu":
return "Tepat Waktu";
case "telat":
return "Telat";
case "izin":
return "Izin";
case "sakit":
return "Sakit";
case "pulang":
return "Pulang";
default:
return "Tidak Hadir";
}
}
// ================= HAPUS RIWAYAT =================
Future<void> hapusRiwayat() async {
try {
await refAbsen.remove();
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("Semua riwayat absensi berhasil dihapus"),
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10))),
),
);
}
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text("Gagal menghapus riwayat: $e"),
backgroundColor: const Color(0xffDC2626),
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10))),
),
);
}
}
}
// ================= KONFIRMASI HAPUS =================
void showHapusDialog() {
showDialog(
context: context,
builder: (_) => AlertDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
title: const Text(
"Hapus Riwayat Absensi",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Color(0xff12175E),
),
),
content: const Text(
"Apakah Anda yakin ingin menghapus SEMUA riwayat absensi? Tindakan ini tidak dapat dibatalkan.",
style: TextStyle(color: Color(0xff12175E), height: 1.4),
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text(
"Batal",
style: TextStyle(color: Colors.grey, fontWeight: FontWeight.w600),
),
),
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xffDC2626),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
),
onPressed: () {
Navigator.pop(context);
hapusRiwayat();
},
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.delete_rounded, size: 18, color: Colors.white),
SizedBox(width: 6),
Text("Hapus", style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
],
),
),
],
),
);
}
DateTime? parseDateKey(String value) {
final normalized = value.replaceAll('/', '-');
return DateTime.tryParse(normalized);
}
String formatDateKey(DateTime value) {
return "${value.year.toString().padLeft(4, '0')}-${value.month.toString().padLeft(2, '0')}-${value.day.toString().padLeft(2, '0')}";
}
bool isDateInSelectedFilter(String tanggal) {
final parsed = parseDateKey(tanggal);
if (parsed == null) {
return false;
}
switch (selectedFilter) {
case "harian":
return parsed.year == selectedDate.year &&
parsed.month == selectedDate.month &&
parsed.day == selectedDate.day;
case "mingguan": {
final startOfWeek = selectedDate.subtract(Duration(days: selectedDate.weekday - 1));
final endOfWeek = startOfWeek.add(const Duration(days: 6));
return !parsed.isBefore(startOfWeek) && !parsed.isAfter(endOfWeek);
}
case "bulanan":
return parsed.year == selectedDate.year && parsed.month == selectedDate.month;
case "tahunan":
return parsed.year == selectedDate.year;
default:
return true;
}
}
List<String> getFilteredDates(Map<dynamic, dynamic> absen) {
final dates = <String>{};
absen.forEach((uid, value) {
if (value is Map) {
value.forEach((tanggal, detail) {
if (tanggal is String && isDateInSelectedFilter(tanggal)) {
dates.add(tanggal);
}
});
}
});
final sorted = dates.toList()..sort((a, b) => b.compareTo(a));
return sorted;
}
void moveFilter(int step) {
setState(() {
switch (selectedFilter) {
case 'harian':
selectedDate = selectedDate.add(Duration(days: step));
break;
case 'mingguan':
selectedDate = selectedDate.add(Duration(days: step * 7));
break;
case 'bulanan':
selectedDate = DateTime(selectedDate.year, selectedDate.month + step, 1);
break;
case 'tahunan':
selectedDate = DateTime(selectedDate.year + step, 1, 1);
break;
}
});
}
String getFilterLabel() {
switch (selectedFilter) {
case 'harian':
return 'Tanggal ${formatDateKey(selectedDate)}';
case 'mingguan':
final startOfWeek = selectedDate.subtract(Duration(days: selectedDate.weekday - 1));
final endOfWeek = startOfWeek.add(const Duration(days: 6));
return '${formatDateKey(startOfWeek)} - ${formatDateKey(endOfWeek)}';
case 'bulanan':
return '${_monthName(selectedDate.month)} ${selectedDate.year}';
case 'tahunan':
return '${selectedDate.year}';
default:
return 'Filter';
}
}
String _monthName(int month) {
const months = [
'Januari',
'Februari',
'Maret',
'April',
'Mei',
'Juni',
'Juli',
'Agustus',
'September',
'Oktober',
'November',
'Desember',
];
return months[month - 1];
}
Future<void> exportToExcel(Map<dynamic, dynamic> absen) async {
try {
final excel = Excel.createExcel();
final sheet = excel['Laporan Absensi'];
final filteredDates = getFilteredDates(absen);
sheet.appendRow([
TextCellValue('Nama'),
TextCellValue('Kelas'),
TextCellValue('Tanggal'),
TextCellValue('Status Masuk'),
TextCellValue('Jam Masuk'),
TextCellValue('Status Pulang'),
TextCellValue('Jam Pulang'),
]);
for (final tanggal in filteredDates) {
for (final siswa in siswaList) {
final uid = siswa['rfid'];
final nama = siswa['nama'] ?? '-';
final kelas = siswa['kelas'] ?? '-';
String statusMasuk = 'tidak_hadir';
String jamMasuk = '-';
String statusPulang = 'tidak_hadir';
String jamPulang = '-';
if (absen[uid] != null && absen[uid][tanggal] != null) {
final dataHariIni = Map<String, dynamic>.from(absen[uid][tanggal]);
if (dataHariIni['masuk'] != null) {
final masuk = Map<String, dynamic>.from(dataHariIni['masuk']);
statusMasuk = masuk['status'] ?? 'tidak_hadir';
jamMasuk = masuk['jam'] ?? '-';
}
if (dataHariIni['pulang'] != null) {
final pulang = Map<String, dynamic>.from(dataHariIni['pulang']);
statusPulang = pulang['status'] ?? 'tidak_hadir';
jamPulang = pulang['jam'] ?? '-';
}
}
sheet.appendRow([
TextCellValue(nama.toString()),
TextCellValue(kelas.toString()),
TextCellValue(tanggal.toString()),
TextCellValue(getStatusLabel(statusMasuk)),
TextCellValue(jamMasuk),
TextCellValue(getStatusLabel(statusPulang)),
TextCellValue(jamPulang),
]);
}
}
final bytes = excel.encode();
if (bytes == null) {
throw Exception('Gagal membuat file Excel');
}
final dir = await getDownloadsDirectory();
if (dir == null) {
throw Exception('Folder Downloads tidak tersedia');
}
final fileName = 'laporan_absensi_${DateTime.now().millisecondsSinceEpoch}.xlsx';
final file = File('${dir.path}/$fileName');
await file.writeAsBytes(bytes);
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('File Excel berhasil disimpan di ${file.path}'),
behavior: SnackBarBehavior.floating,
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10))),
),
);
}
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Gagal mengekspor Excel: $e'),
backgroundColor: const Color(0xffDC2626),
behavior: SnackBarBehavior.floating,
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10))),
),
);
}
}
}
// ================= HEADER DESAIN SAMA =================
Widget header(BuildContext context) {
final screenHeight = MediaQuery.of(context).size.height;
return Container(
width: double.infinity,
height: screenHeight * 0.24,
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [
Color(0xffE6DFFF),
Color(0xffCCBFFF),
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(40),
bottomRight: Radius.circular(40),
),
boxShadow: [
BoxShadow(
color: Color(0xff7F56D9),
blurRadius: 24,
offset: Offset(0, 8),
),
],
),
child: ClipRRect(
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(40),
bottomRight: Radius.circular(40),
),
child: Stack(
children: [
// Ornamen lingkaran
Positioned(
top: -30,
left: -20,
child: Container(
width: 150,
height: 150,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white.withOpacity(0.15),
),
),
),
// Garis gelombang
Positioned.fill(
child: CustomPaint(painter: HeaderWavePainter()),
),
// Pola titik
Positioned(top: 40, left: 24, child: _buildGridDots()),
Positioned(top: 60, right: 60, child: _buildGridDots()),
// Konten header
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 20),
child: Row(
children: [
// Tombol kembali
Container(
height: 44,
width: 44,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(14),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.06),
blurRadius: 12,
offset: const Offset(0, 4),
)
],
),
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(14),
onTap: () => Navigator.pop(context),
child: const Icon(Icons.arrow_back_ios_new, color: Color(0xff7F56D9), size: 18),
),
),
),
const SizedBox(width: 16),
Image.asset(
'lib/assets/sekolah.png',
width: 50,
height: 50,
fit: BoxFit.contain,
errorBuilder: (_, __, ___) => const Icon(Icons.school, size: 40, color: Color(0xff7F56D9)),
),
const SizedBox(width: 12),
const Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Laporan Absensi",
style: TextStyle(
color: Color(0xff12175E),
fontSize: 22,
fontWeight: FontWeight.bold,
letterSpacing: -0.5,
),
),
SizedBox(height: 4),
Text(
"Riwayat kehadiran siswa",
style: TextStyle(
color: Color(0xff12175E),
fontSize: 14,
fontWeight: FontWeight.w500,
height: 0.7,
),
),
],
),
),
],
),
),
],
),
),
);
}
Widget _buildGridDots() {
return Opacity(
opacity: 0.25,
child: Column(
children: List.generate(4, (_) => Row(
children: List.generate(4, (_) => Container(
width: 2.5,
height: 2.5,
margin: const EdgeInsets.all(2.5),
decoration: const BoxDecoration(color: Color(0xff12175E), shape: BoxShape.circle),
)),
)),
),
);
}
Widget sectionTitle(String title) {
return Padding(
padding: const EdgeInsets.only(left: 24, bottom: 12, top: 16),
child: Row(
children: [
Container(width: 24, height: 3, decoration: BoxDecoration(color: const Color(0xff7F56D9), borderRadius: BorderRadius.circular(1.5))),
const SizedBox(width: 3),
Container(width: 3, height: 3, decoration: const BoxDecoration(color: Color(0xff7F56D9), shape: BoxShape.circle)),
const SizedBox(width: 8),
Text(
title.toUpperCase(),
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: Color(0xff12175E),
letterSpacing: 0.5,
),
),
],
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xffF6F5FB),
body: SafeArea(
child: Column(
children: [
header(context),
Expanded(
child: StreamBuilder(
stream: refAbsen.onValue,
builder: (context, snapshot) {
if (!snapshot.hasData) {
return const Center(child: CircularProgressIndicator(color: Color(0xff7F56D9)));
}
final absen = snapshot.data!.snapshot.value as Map? ?? {};
if (siswaList.isEmpty) {
return const Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.person_off_rounded, size: 60, color: Color(0xff12175E)),
SizedBox(height: 12),
Text("Data siswa belum dimuat", style: TextStyle(color: Color(0xff12175E))),
],
),
);
}
final tanggalList = getFilteredDates(absen);
return Column(
children: [
Container(
margin: const EdgeInsets.fromLTRB(24, 16, 24, 8),
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
boxShadow: [
BoxShadow(
color: const Color(0xff7F56D9).withOpacity(0.08),
blurRadius: 16,
offset: const Offset(0, 6),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
const Expanded(
child: Text(
'Filter laporan',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 15,
color: Color(0xff12175E),
),
),
),
IconButton(
onPressed: () => exportToExcel(absen),
icon: const Icon(Icons.download_rounded, color: Color(0xff7F56D9)),
tooltip: 'Download file Excel',
),
],
),
const SizedBox(height: 8),
Wrap(
spacing: 8,
runSpacing: 8,
children: [
ChoiceChip(
label: const Text('Harian'),
selected: selectedFilter == 'harian',
onSelected: (_) => setState(() => selectedFilter = 'harian'),
selectedColor: const Color(0xff7F56D9),
labelStyle: TextStyle(color: selectedFilter == 'harian' ? Colors.white : const Color(0xff12175E)),
),
ChoiceChip(
label: const Text('Mingguan'),
selected: selectedFilter == 'mingguan',
onSelected: (_) => setState(() => selectedFilter = 'mingguan'),
selectedColor: const Color(0xff7F56D9),
labelStyle: TextStyle(color: selectedFilter == 'mingguan' ? Colors.white : const Color(0xff12175E)),
),
ChoiceChip(
label: const Text('Bulanan'),
selected: selectedFilter == 'bulanan',
onSelected: (_) => setState(() => selectedFilter = 'bulanan'),
selectedColor: const Color(0xff7F56D9),
labelStyle: TextStyle(color: selectedFilter == 'bulanan' ? Colors.white : const Color(0xff12175E)),
),
ChoiceChip(
label: const Text('Tahunan'),
selected: selectedFilter == 'tahunan',
onSelected: (_) => setState(() => selectedFilter = 'tahunan'),
selectedColor: const Color(0xff7F56D9),
labelStyle: TextStyle(color: selectedFilter == 'tahunan' ? Colors.white : const Color(0xff12175E)),
),
],
),
const SizedBox(height: 10),
Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
decoration: BoxDecoration(
color: const Color(0xffF6F5FB),
borderRadius: BorderRadius.circular(14),
),
child: Row(
children: [
IconButton(
onPressed: () => moveFilter(-1),
icon: const Icon(Icons.chevron_left_rounded, color: Color(0xff7F56D9)),
),
Expanded(
child: Text(
getFilterLabel(),
textAlign: TextAlign.center,
style: const TextStyle(
fontWeight: FontWeight.bold,
color: Color(0xff12175E),
),
),
),
IconButton(
onPressed: () => moveFilter(1),
icon: const Icon(Icons.chevron_right_rounded, color: Color(0xff7F56D9)),
),
],
),
),
],
),
),
Expanded(
child: tanggalList.isEmpty
? const Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.history_rounded, size: 60, color: Color(0xff12175E)),
SizedBox(height: 12),
Text(
"Belum ada riwayat absensi pada periode ini",
style: TextStyle(color: Color(0xff12175E)),
),
],
),
)
: ListView.builder(
physics: const BouncingScrollPhysics(),
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
itemCount: tanggalList.length,
itemBuilder: (context, index) {
final tanggal = tanggalList[index];
return Container(
margin: const EdgeInsets.only(bottom: 20),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(24),
boxShadow: [
BoxShadow(
color: const Color(0xff7F56D9).withOpacity(0.08),
blurRadius: 20,
spreadRadius: 0,
offset: const Offset(0, 8),
),
],
),
child: Theme(
data: Theme.of(context).copyWith(dividerColor: Colors.transparent),
child: ExpansionTile(
iconColor: const Color(0xff7F56D9),
collapsedIconColor: const Color(0xff7F56D9),
tilePadding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
leading: Container(
width: 48,
height: 48,
decoration: BoxDecoration(
color: const Color(0xff7F56D9).withOpacity(0.12),
borderRadius: BorderRadius.circular(14),
),
child: const Icon(
Icons.calendar_month_rounded,
color: Color(0xff7F56D9),
size: 24,
),
),
title: Text(
tanggal,
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 17,
color: Color(0xff12175E),
),
),
children: siswaList.map((doc) {
final uid = doc['rfid'];
final nama = doc['nama'];
final kelas = doc['kelas'] ?? "-";
String statusMasuk = "tidak_hadir";
String jamMasuk = "-";
String statusPulang = "tidak_hadir";
String jamPulang = "-";
if (absen[uid] != null && absen[uid][tanggal] != null) {
final dataHariIni = Map<String, dynamic>.from(absen[uid][tanggal]);
if (dataHariIni['masuk'] != null) {
final masuk = Map<String, dynamic>.from(dataHariIni['masuk']);
statusMasuk = masuk['status'] ?? "tidak_hadir";
jamMasuk = masuk['jam'] ?? "-";
}
if (dataHariIni['pulang'] != null) {
final pulang = Map<String, dynamic>.from(dataHariIni['pulang']);
statusPulang = pulang['status'] ?? "tidak_hadir";
jamPulang = pulang['jam'] ?? "-";
}
}
return Container(
margin: const EdgeInsets.symmetric(horizontal: 20, vertical: 8),
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: const Color(0xffF6F5FB),
borderRadius: BorderRadius.circular(16),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Container(
width: 40,
height: 40,
decoration: BoxDecoration(
color: getStatusBgColor(statusMasuk),
shape: BoxShape.circle,
),
child: Icon(
getStatusIcon(statusMasuk),
color: getStatusTextColor(statusMasuk),
size: 20,
),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
nama,
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 15,
color: Color(0xff12175E),
),
),
const SizedBox(height: 2),
Text(
"Kelas: $kelas",
style: TextStyle(
fontSize: 13,
color: const Color(0xff12175E).withOpacity(0.6),
),
),
],
),
),
],
),
const SizedBox(height: 14),
Row(
children: [
Expanded(
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
decoration: BoxDecoration(
color: getStatusBgColor(statusMasuk),
borderRadius: BorderRadius.circular(12),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Masuk",
style: TextStyle(
color: getStatusTextColor(statusMasuk).withOpacity(0.8),
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 4),
Text(
getStatusLabel(statusMasuk),
style: TextStyle(
color: getStatusTextColor(statusMasuk),
fontWeight: FontWeight.bold,
fontSize: 13,
),
),
const SizedBox(height: 2),
Text(
jamMasuk,
style: TextStyle(
fontSize: 12,
color: const Color(0xff12175E).withOpacity(0.6),
),
),
],
),
),
),
const SizedBox(width: 10),
Expanded(
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
decoration: BoxDecoration(
color: getStatusBgColor(statusPulang),
borderRadius: BorderRadius.circular(12),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Pulang",
style: TextStyle(
color: getStatusTextColor(statusPulang).withOpacity(0.8),
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 4),
Text(
getStatusLabel(statusPulang),
style: TextStyle(
color: getStatusTextColor(statusPulang),
fontWeight: FontWeight.bold,
fontSize: 13,
),
),
const SizedBox(height: 2),
Text(
jamPulang,
style: TextStyle(
fontSize: 12,
color: const Color(0xff12175E).withOpacity(0.6),
),
),
],
),
),
),
],
),
],
),
);
}).toList(),
),
),
);
},
),
),
// TOMBOL HAPUS DIPINDAH KE BAWAH
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 20),
child: SizedBox(
width: double.infinity,
height: 52,
child: ElevatedButton.icon(
onPressed: showHapusDialog,
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xffDC2626),
foregroundColor: Colors.white,
elevation: 2,
shadowColor: const Color(0xffDC2626).withOpacity(0.3),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14),
),
),
icon: const Icon(Icons.delete_rounded, size: 20),
label: const Text(
"Hapus Semua Riwayat",
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
),
),
),
],
);
},
),
),
],
),
),
);
}
}
// Widget gelombang yang sama
class HeaderWavePainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()
..color = Colors.white.withOpacity(0.3)
..style = PaintingStyle.stroke
..strokeWidth = 1.8;
final path = Path();
path.moveTo(0, size.height * 0.4);
path.quadraticBezierTo(size.width * 0.5, size.height * 0.1, size.width, size.height * 0.3);
canvas.drawPath(path, paint);
final path2 = Path();
path2.moveTo(0, size.height * 0.6);
path2.quadraticBezierTo(size.width * 0.6, size.height * 0.2, size.width, size.height * 0.5);
canvas.drawPath(path2, paint);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
}

453
lib/login_page.dart Normal file
View File

@ -0,0 +1,453 @@
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'dashboard_admin.dart';
import 'dashboard_guru.dart';
import 'dashboard_ortu.dart';
class LoginPage extends StatefulWidget {
const LoginPage({super.key});
@override
State<LoginPage> createState() => _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
final email = TextEditingController();
final password = TextEditingController();
bool isLoading = false;
bool obscurePassword = true;
@override
void dispose() {
email.dispose();
password.dispose();
super.dispose();
}
Future<void> login() async {
if (email.text.trim().isEmpty || password.text.trim().isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Email dan Password wajib diisi'),
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(12))),
),
);
return;
}
setState(() => isLoading = true);
try {
final userCred = await FirebaseAuth.instance.signInWithEmailAndPassword(
email: email.text.trim(),
password: password.text.trim(),
);
final doc = await FirebaseFirestore.instance
.collection('users')
.doc(userCred.user!.uid)
.get();
final data = doc.data();
if (data == null) throw Exception("Data pengguna tidak ditemukan");
final role = data['role'];
if (!mounted) return;
if (role == 'admin') {
Navigator.pushReplacement(context, MaterialPageRoute(builder: (_) => const DashboardAdmin()));
} else if (role == 'guru') {
Navigator.pushReplacement(context, MaterialPageRoute(builder: (_) => const DashboardGuru()));
} else {
Navigator.pushReplacement(context, MaterialPageRoute(builder: (_) => const DashboardOrtu()));
}
} on FirebaseAuthException catch (e) {
String pesan = "Login gagal";
if (e.code == "user-not-found") pesan = "Pengguna tidak ditemukan";
else if (e.code == "wrong-password") pesan = "Kata sandi salah";
else if (e.code == "invalid-email") pesan = "Format email tidak valid";
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(pesan),
behavior: SnackBarBehavior.floating,
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(12))),
),
);
}
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text("Kesalahan: $e"),
behavior: SnackBarBehavior.floating,
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(12))),
),
);
}
}
if (mounted) setState(() => isLoading = false);
}
// 📝 Diperkecil tinggi container field dari 54 menjadi 48
Widget inputField({
required TextEditingController controller,
required String hint,
required IconData icon,
bool obscure = false,
Widget? suffixIcon,
}) {
return Container(
height: 48,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
boxShadow: const [
BoxShadow(
color: Color(0x0F7F56D9),
blurRadius: 8,
offset: Offset(0, 3),
)
],
border: Border.all(color: const Color(0xffE6E0FF), width: 1),
),
child: TextField(
controller: controller,
obscureText: obscure,
style: const TextStyle(fontSize: 14, color: Color(0xff2D2669)),
decoration: InputDecoration(
border: InputBorder.none,
hintText: hint,
hintStyle: const TextStyle(color: Color(0xffA098C7), fontSize: 13),
prefixIcon: Icon(icon, color: const Color(0xff7F56D9), size: 18),
suffixIcon: suffixIcon,
contentPadding: const EdgeInsets.symmetric(horizontal: 14, vertical: 11),
),
),
);
}
@override
Widget build(BuildContext context) {
final screenSize = MediaQuery.of(context).size;
final screenHeight = screenSize.height;
// Penyesuaian proporsi tinggi komponen khusus layar Vivo Y02t agar lebih ringkas
final double illustrationHeight = screenHeight * 0.14; // Diturunkan ke ~14%
final double spacingTop = screenHeight * 0.015;
final double spacingMiddle = screenHeight * 0.018;
return Scaffold(
backgroundColor: const Color(0xffF5F2FF),
resizeToAvoidBottomInset: true,
body: SafeArea(
child: SingleChildScrollView(
physics: const ClampingScrollPhysics(),
child: Stack(
children: [
// DEKORASI LATAR BELAKANG
_buildBackgroundDecorations(screenHeight),
// KONTEN UTAMA
Center(
child: Container(
constraints: const BoxConstraints(maxWidth: 400),
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(height: spacingTop),
// Logo Sekolah (Diperkecil sedikit rasio layarnya)
Image.asset(
'lib/assets/sekolah.png',
height: screenHeight * 0.07,
fit: BoxFit.contain,
errorBuilder: (_, __, ___) => const Icon(
Icons.school,
size: 55,
color: Color(0xff7F56D9),
),
),
const SizedBox(height: 6),
// Ukuran font judul dikurangi agar tidak memakan tempat banyak
const Text(
"ABSENSI",
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
color: Color(0xff2D2669),
letterSpacing: 1.2,
),
),
const Text(
"— SISTEM ABSENSI PGRI —",
style: TextStyle(
fontSize: 11,
color: Color(0xff7F56D9),
fontWeight: FontWeight.w500,
letterSpacing: 0.8,
),
),
const SizedBox(height: 2),
const Text(
"TK PGRI BHAKTI LESTARI",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: Color(0xff2D2669),
),
),
SizedBox(height: spacingMiddle),
// ILUSTRASI ANAK (RESPONSIF & DIBATASI LEBIH KECIL)
_buildStudentIllustration(illustrationHeight),
SizedBox(height: spacingMiddle),
// KOTAK LOGIN (Padding dikurangi)
Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 16),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
boxShadow: const [
BoxShadow(
color: Color(0x127F56D9),
blurRadius: 15,
offset: Offset(0, 4),
)
],
border: Border.all(color: const Color(0xffE6E0FF), width: 1.2),
),
child: Column(
children: [
const Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("", style: TextStyle(fontSize: 16, color: Color(0xff7F56D9), fontWeight: FontWeight.bold)),
Text("Login", style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Color(0xff2D2669))),
Text("", style: TextStyle(fontSize: 16, color: Color(0xff7F56D9), fontWeight: FontWeight.bold)),
],
),
const SizedBox(height: 14),
inputField(
controller: email,
hint: "Email",
icon: Icons.email_outlined,
),
const SizedBox(height: 10),
inputField(
controller: password,
hint: "Password",
icon: Icons.lock_outline,
obscure: obscurePassword,
suffixIcon: IconButton(
icon: Icon(
obscurePassword ? Icons.visibility_off_outlined : Icons.visibility_outlined,
color: const Color(0xffA098C7),
size: 18,
),
onPressed: () => setState(() => obscurePassword = !obscurePassword),
),
),
const SizedBox(height: 16),
// Tombol Login (Tinggi diturunkan dari 50 ke 44)
SizedBox(
width: double.infinity,
height: 44,
child: ElevatedButton(
onPressed: isLoading ? null : login,
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xff7F56D9),
disabledBackgroundColor: const Color(0xffB7A3E8),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
elevation: 1.5,
shadowColor: const Color(0xff7F56D9).withOpacity(0.2),
),
child: isLoading
? const SizedBox(
height: 20,
width: 20,
child: CircularProgressIndicator(color: Colors.white, strokeWidth: 2.2),
)
: const Text(
"Login",
style: TextStyle(fontSize: 15, fontWeight: FontWeight.w600, color: Colors.white),
),
),
),
const SizedBox(height: 10),
const Text(
"Gunakan akun yang telah terdaftar",
style: TextStyle(fontSize: 10, color: Color(0xff7F56D9)),
),
const SizedBox(height: 10),
// Garis pemisah
Row(
children: [
const Expanded(child: Divider(color: Color(0xffE0DBF5), thickness: 1, indent: 6, endIndent: 6)),
Container(
padding: const EdgeInsets.all(5),
decoration: const BoxDecoration(color: Color(0xffF5F2FF), shape: BoxShape.circle),
child: const Icon(Icons.shield_outlined, color: Color(0xff7F56D9), size: 12),
),
const Expanded(child: Divider(color: Color(0xffE0DBF5), thickness: 1, indent: 6, endIndent: 6)),
],
),
],
),
),
const SizedBox(height: 12),
// INFORMASI PENGEMBANG (Diperkecil padding dan ukuran teksnya)
Container(
width: double.infinity,
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: const Color(0xffEDE9FF),
borderRadius: BorderRadius.circular(12),
border: Border.all(color: const Color(0xffDCD4FF)),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("Dikembangkan oleh:", style: TextStyle(fontSize: 9, color: Color(0xff7F56D9), fontWeight: FontWeight.w500)),
SizedBox(height: 1),
Text("Quri Amaliatas Solehah", style: TextStyle(fontSize: 11, fontWeight: FontWeight.bold, color: Color(0xff2D2669))),
SizedBox(height: 1),
Text("Politeknik Negeri Jember", style: TextStyle(fontSize: 10, color: Color(0xff4A4385))),
Text("Jurusan Teknologi Informasi | Teknik Komputer 2023", style: TextStyle(fontSize: 8, color: Color(0xff7F56D9))),
],
),
),
const SizedBox(width: 4),
Image.asset(
'lib/assets/jti.png',
height: 18,
fit: BoxFit.contain,
errorBuilder: (_, __, ___) => const Icon(Icons.school_outlined, size: 18, color: Color(0xff7F56D9)),
),
],
),
),
],
),
),
),
],
),
),
),
);
}
Widget _buildBackgroundDecorations(double height) {
return Positioned.fill(
child: Stack(
children: [
Positioned(
top: -50,
left: -50,
child: Container(width: 140, height: 140, decoration: BoxDecoration(color: const Color(0xff7F56D9).withOpacity(0.05), shape: BoxShape.circle)),
),
Positioned(
top: 40,
right: -25,
child: Container(width: 80, height: 80, decoration: BoxDecoration(color: const Color(0xff7F56D9).withOpacity(0.04), shape: BoxShape.circle)),
),
Positioned(
bottom: -30,
left: -15,
child: Container(width: 100, height: 100, decoration: BoxDecoration(color: const Color(0xff7F56D9).withOpacity(0.04), shape: BoxShape.circle)),
),
Positioned(top: 40, left: 20, child: _buildDotGrid()),
Positioned(top: 60, right: 30, child: _buildDotGrid()),
Positioned(bottom: 80, right: 20, child: _buildDotGrid()),
],
),
);
}
Widget _buildDotGrid() {
return Opacity(
opacity: 0.15,
child: Column(
children: List.generate(3, (_) => Row(
children: List.generate(3, (_) => Container(
width: 2.5,
height: 2.5,
margin: const EdgeInsets.all(2.0),
decoration: const BoxDecoration(color: Color(0xff7F56D9), shape: BoxShape.circle),
)),
)),
),
);
}
Widget _buildStudentIllustration(double dynamicHeight) {
return Container(
width: double.infinity,
height: dynamicHeight.clamp(110.0, 140.0), // Rentang clamp diturunkan agar pas di layar Vivo Y02t
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [const Color(0xffEDE9FF), const Color(0xffDCD4FF).withOpacity(0.5)],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.circular(16),
border: Border.all(color: const Color(0xffD1C8FF), width: 1),
),
child: Stack(
children: [
Positioned(top: 8, left: 12, child: Icon(Icons.cloud_outlined, color: const Color(0xff7F56D9).withOpacity(0.25), size: 18)),
Positioned(bottom: 12, right: 16, child: Icon(Icons.star_border, color: const Color(0xff7F56D9).withOpacity(0.25), size: 16)),
Center(
child: Image.asset(
'lib/assets/anak_rfid.png',
height: (dynamicHeight - 20).clamp(90.0, 120.0),
fit: BoxFit.contain,
errorBuilder: (_, __, ___) => const Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.image_not_supported, size: 35, color: Color(0xff7F56D9)),
SizedBox(height: 2),
Text("Masukkan gambar ilustrasi_anak.png", style: TextStyle(color: Color(0xff7F56D9), fontSize: 10)),
],
),
),
),
],
),
);
}
}

131
lib/main.dart Normal file
View File

@ -0,0 +1,131 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'firebase_options.dart';
import 'login_page.dart';
import 'dashboard_admin.dart';
import 'dashboard_guru.dart';
import 'dashboard_ortu.dart';
// ================= NOTIF =================
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
// ================= MAIN =================
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
// ================= ANDROID ONLY =================
if (!kIsWeb) {
if (defaultTargetPlatform == TargetPlatform.android) {
await Permission.notification.request();
await Permission.scheduleExactAlarm.request();
}
const AndroidInitializationSettings androidSettings =
AndroidInitializationSettings('@mipmap/ic_launcher');
const InitializationSettings settings = InitializationSettings(
android: androidSettings,
);
await flutterLocalNotificationsPlugin.initialize(settings: settings);
}
runApp(const MyApp());
}
// ================= APP =================
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: StreamBuilder<User?>(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (context, snapshot) {
// ================= LOADING =================
if (snapshot.connectionState == ConnectionState.waiting) {
return const Scaffold(
body: Center(
child: CircularProgressIndicator(),
),
);
}
// ================= BELUM LOGIN =================
if (!snapshot.hasData) {
return const LoginPage();
}
final user = snapshot.data!;
// ================= CEK ROLE =================
return FutureBuilder<DocumentSnapshot>(
future: FirebaseFirestore.instance
.collection('users')
.doc(user.uid)
.get(),
builder: (context, userSnap) {
// Loading data user
if (userSnap.connectionState == ConnectionState.waiting) {
return const Scaffold(
body: Center(
child: CircularProgressIndicator(),
),
);
}
// Jika dokumen user tidak ada
if (!userSnap.hasData || !userSnap.data!.exists) {
return const Scaffold(
body: Center(
child: Text('Data pengguna tidak ditemukan'),
),
);
}
final data =
userSnap.data!.data() as Map<String, dynamic>? ?? {};
final role = data['role'] ?? 'ortu';
// ================= ADMIN =================
if (role == 'admin') {
return const DashboardAdmin();
}
// ================= GURU =================
if (role == 'guru') {
return const DashboardGuru();
}
// ================= ORTU =================
return const DashboardOrtu();
},
);
},
),
);
}
}

125
lib/register_guru.dart Normal file
View File

@ -0,0 +1,125 @@
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
class RegisterGuru extends StatefulWidget {
const RegisterGuru({super.key});
@override
State<RegisterGuru> createState() => _RegisterGuruState();
}
class _RegisterGuruState extends State<RegisterGuru> {
final nama = TextEditingController();
final email = TextEditingController();
final password = TextEditingController();
bool isLoading = false;
Future<void> register() async {
if (nama.text.isEmpty ||
email.text.isEmpty ||
password.text.isEmpty) return;
setState(() => isLoading = true);
try {
final userCred =
await FirebaseAuth.instance.createUserWithEmailAndPassword(
email: email.text,
password: password.text,
);
await FirebaseFirestore.instance
.collection('users')
.doc(userCred.user!.uid)
.set({
'role': 'guru',
'nama': nama.text,
});
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Register berhasil')),
);
Navigator.pop(context);
} catch (e) {
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(content: Text('Register gagal')));
}
setState(() => isLoading = false);
}
Widget input(controller, String hint, {bool pass = false}) {
return Container(
margin: const EdgeInsets.only(bottom: 15),
child: TextField(
controller: controller,
obscureText: pass,
decoration: InputDecoration(
hintText: hint,
filled: true,
fillColor: Colors.grey[100],
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
borderSide: BorderSide.none,
),
),
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.blue,
appBar: AppBar(
title: const Text('Register Guru'),
backgroundColor: Colors.transparent,
elevation: 0,
),
body: Center(
child: Padding(
padding: const EdgeInsets.all(20),
child: Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Colors.white,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.person_add, size: 60, color: Colors.blue),
const SizedBox(height: 10),
input(nama, 'Nama Guru'),
input(email, 'Email'),
input(password, 'Password', pass: true),
const SizedBox(height: 10),
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: isLoading ? null : register,
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.all(15),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: isLoading
? const CircularProgressIndicator(color: Colors.white)
: const Text('Register'),
),
)
],
),
),
),
),
);
}
}

638
lib/tambah_siswa.dart Normal file
View File

@ -0,0 +1,638 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_database/firebase_database.dart';
class TambahSiswa extends StatefulWidget {
const TambahSiswa({super.key});
@override
State<TambahSiswa> createState() => _TambahSiswaState();
}
class _TambahSiswaState extends State<TambahSiswa> {
final nama = TextEditingController();
final namaOrtu = TextEditingController();
final nomorAbsen = TextEditingController();
final emailOrtu = TextEditingController();
final passwordOrtu = TextEditingController();
String rfid = '';
String kelasPilihan = 'TK A';
bool isLoading = false;
bool isScanning = false;
bool showPassword = false;
final ref = FirebaseDatabase.instance.ref("rfid");
StreamSubscription? _rfidSubscription;
@override
void initState() {
super.initState();
_rfidSubscription = ref.child("latest").onValue.listen((event) {
final data = event.snapshot.value;
if (data != null && mounted) {
setState(() {
rfid = data.toString().toUpperCase();
isScanning = false;
});
}
});
}
@override
void dispose() {
_rfidSubscription?.cancel();
nama.dispose();
namaOrtu.dispose();
nomorAbsen.dispose();
emailOrtu.dispose();
passwordOrtu.dispose();
super.dispose();
}
Future<void> scanKartu() async {
if (nama.text.trim().isEmpty ||
namaOrtu.text.trim().isEmpty ||
nomorAbsen.text.trim().isEmpty ||
emailOrtu.text.trim().isEmpty ||
passwordOrtu.text.trim().isEmpty) {
showMsg("Lengkapi data terlebih dahulu");
return;
}
setState(() {
isScanning = true;
rfid = '';
});
await ref.child("mode").set("scan");
}
Future<void> simpan() async {
if (rfid.isEmpty || isScanning) {
showMsg("Scan kartu terlebih dahulu");
return;
}
setState(() => isLoading = true);
try {
final user = await FirebaseAuth.instance.createUserWithEmailAndPassword(
email: emailOrtu.text.trim(),
password: passwordOrtu.text.trim(),
);
final uid = user.user!.uid;
final namaSiswa = nama.text.trim();
final namaAyahIbu = namaOrtu.text.trim();
final noAbsen = nomorAbsen.text.trim();
await FirebaseFirestore.instance.collection('users').doc(uid).set({
'role': 'ortu',
'nama': namaAyahIbu,
'nama_siswa': namaSiswa,
'kelas': kelasPilihan,
'rfid': rfid,
});
await FirebaseFirestore.instance.collection('siswa').add({
'nama': namaSiswa,
'nama_orang_tua': namaAyahIbu,
'nomor_absen': noAbsen,
'kelas': kelasPilihan,
'rfid': rfid,
'ortu_uid': uid,
});
await FirebaseDatabase.instance.ref("siswa/$rfid").set(true);
showMsg("Berhasil ditambahkan");
if (mounted) Navigator.pop(context);
} catch (e) {
showMsg("Error : $e");
}
if (mounted) setState(() => isLoading = false);
}
void showMsg(String msg) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(msg),
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
),
);
}
// ================= WIDGET COMPONENT (MATCHED WITH DASHBOARD STYLE) =================
Widget header() {
final screenHeight = MediaQuery.of(context).size.height;
return Container(
width: double.infinity,
height: screenHeight * 0.24,
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [
Color(0xffE6DFFF),
Color(0xffCCBFFF),
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(40),
bottomRight: Radius.circular(40),
),
boxShadow: [
BoxShadow(
color: Color(0xff7F56D9),
blurRadius: 24,
offset: Offset(0, 8),
),
],
),
child: ClipRRect(
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(40),
bottomRight: Radius.circular(40),
),
child: Stack(
children: [
// Ornamen lingkaran besar sama seperti dashboard
Positioned(
top: -30,
left: -20,
child: Container(
width: 150,
height: 150,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white.withOpacity(0.15),
),
),
),
// Garis gelombang latar belakang
Positioned.fill(
child: CustomPaint(painter: HeaderWavePainter()),
),
// Pola titik grid
Positioned(top: 40, left: 24, child: _buildGridDots()),
Positioned(top: 60, right: 60, child: _buildGridDots()),
// Konten Header
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 20),
child: Row(
children: [
// Tombol kembali gaya modern
Container(
height: 44,
width: 44,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(14),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.06),
blurRadius: 12,
offset: const Offset(0, 4),
)
],
),
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(14),
onTap: () => Navigator.pop(context),
child: const Icon(Icons.arrow_back_ios_new, color: Color(0xff7F56D9), size: 18),
),
),
),
const SizedBox(width: 16),
Image.asset(
'lib/assets/sekolah.png',
width: 50,
height: 50,
fit: BoxFit.contain,
errorBuilder: (_, __, ___) => const Icon(Icons.school, size: 40, color: Color(0xff7F56D9)),
),
const SizedBox(width: 12),
const Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Tambah Siswa",
style: TextStyle(
color: Color(0xff12175E),
fontSize: 22,
fontWeight: FontWeight.bold,
letterSpacing: -0.5,
),
),
SizedBox(height: 4),
Text(
"Registrasi data & kartu RFID",
style: TextStyle(
color: Color(0xff12175E),
fontSize: 14,
fontWeight: FontWeight.w500,
height: 0.7,
),
),
],
),
),
Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.4),
borderRadius: BorderRadius.circular(14),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.04),
blurRadius: 8,
offset: const Offset(0, 2),
)
],
),
child: const Icon(
Icons.person_add_alt_1_rounded,
color: Color(0xff7F56D9),
size: 26,
),
),
],
),
),
],
),
),
);
}
Widget _buildGridDots() {
return Opacity(
opacity: 0.25,
child: Column(
children: List.generate(4, (index) => Row(
children: List.generate(4, (index) => Container(
width: 2.5,
height: 2.5,
margin: const EdgeInsets.all(2.5),
decoration: const BoxDecoration(color: Color(0xff12175E), shape: BoxShape.circle),
)),
)),
),
);
}
Widget sectionTitle(String title) {
return Padding(
padding: const EdgeInsets.only(left: 4, bottom: 12, top: 16),
child: Row(
children: [
Container(width: 24, height: 3, decoration: BoxDecoration(color: const Color(0xff7F56D9), borderRadius: BorderRadius.circular(1.5))),
const SizedBox(width: 3),
Container(width: 3, height: 3, decoration: const BoxDecoration(color: Color(0xff7F56D9), shape: BoxShape.circle)),
const SizedBox(width: 8),
Text(
title.toUpperCase(),
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: Color(0xff12175E),
letterSpacing: 0.5,
),
),
],
),
);
}
Widget customInput({
required TextEditingController controller,
required IconData icon,
required String hint,
bool password = false,
TextInputType keyboardType = TextInputType.text,
}) {
return Container(
margin: const EdgeInsets.only(bottom: 16),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
boxShadow: [
BoxShadow(
color: const Color(0xff7F56D9).withOpacity(0.08),
blurRadius: 16,
spreadRadius: 0,
offset: const Offset(0, 6),
),
],
),
child: TextField(
controller: controller,
keyboardType: keyboardType,
obscureText: password ? !showPassword : false,
textAlignVertical: TextAlignVertical.center,
style: const TextStyle(
fontSize: 15,
fontWeight: FontWeight.w500,
color: Color(0xff12175E),
),
decoration: InputDecoration(
border: InputBorder.none,
contentPadding: const EdgeInsets.symmetric(vertical: 18, horizontal: 18),
prefixIcon: Container(
margin: const EdgeInsets.all(8),
width: 40,
height: 40,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: const Color(0xff7F56D9).withOpacity(0.12),
),
child: Icon(
icon,
color: const Color(0xff7F56D9),
size: 22,
),
),
hintText: hint,
hintStyle: TextStyle(
color: const Color(0xff12175E).withOpacity(0.45),
fontSize: 15,
),
suffixIcon: password
? IconButton(
onPressed: () => setState(() => showPassword = !showPassword),
icon: Icon(
showPassword ? Icons.visibility : Icons.visibility_off,
color: const Color(0xff7F56D9).withOpacity(0.6),
size: 20,
),
)
: null,
),
),
);
}
Widget kelasDropdown() {
return Container(
margin: const EdgeInsets.only(bottom: 16),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
boxShadow: [
BoxShadow(
color: const Color(0xff7F56D9).withOpacity(0.08),
blurRadius: 16,
spreadRadius: 0,
offset: const Offset(0, 6),
),
],
),
child: DropdownButtonFormField<String>(
value: kelasPilihan,
isExpanded: true,
icon: const Icon(Icons.arrow_drop_down_circle_outlined, color: Color(0xff7F56D9), size: 22),
decoration: InputDecoration(
border: InputBorder.none,
contentPadding: const EdgeInsets.symmetric(horizontal: 18, vertical: 10),
prefixIcon: Container(
margin: const EdgeInsets.all(8),
width: 40,
height: 40,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: const Color(0xff7F56D9).withOpacity(0.12),
),
child: const Icon(
Icons.school_outlined,
color: Color(0xff7F56D9),
size: 22,
),
),
),
items: const [
DropdownMenuItem(value: 'TK A', child: Text('TK A', style: TextStyle(fontSize: 15, fontWeight: FontWeight.w500, color: Color(0xff12175E)))),
DropdownMenuItem(value: 'TK B', child: Text('TK B', style: TextStyle(fontSize: 15, fontWeight: FontWeight.w500, color: Color(0xff12175E)))),
],
onChanged: (value) {
if (value != null) setState(() => kelasPilihan = value);
},
),
);
}
Widget rfidCard() {
return Container(
width: double.infinity,
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(24),
boxShadow: [
BoxShadow(
color: const Color(0xff7F56D9).withOpacity(isScanning ? 0.15 : 0.08),
blurRadius: 24,
spreadRadius: 0,
offset: const Offset(0, 12),
),
],
border: Border.all(
color: isScanning ? const Color(0xff7F56D9).withOpacity(0.6) : Colors.transparent,
width: 1.5,
),
),
child: Column(
children: [
Container(
width: 70,
height: 70,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: rfid.isEmpty ? Colors.grey.shade100 : const Color(0xff7F56D9).withOpacity(0.12),
boxShadow: [
BoxShadow(
color: rfid.isEmpty ? Colors.grey.shade200 : const Color(0xff7F56D9).withOpacity(0.2),
blurRadius: 12,
spreadRadius: 2,
)
],
),
child: Icon(
Icons.vignette_rounded,
size: 32,
color: rfid.isEmpty ? Colors.grey.shade400 : const Color(0xff7F56D9),
),
),
const SizedBox(height: 16),
if (isScanning) ...[
const SizedBox(height: 24, width: 24, child: CircularProgressIndicator(strokeWidth: 2.5, color: Color(0xff7F56D9))),
const SizedBox(height: 12),
],
Text(
isScanning
? "Mendekatkan kartu ke Reader..."
: rfid.isEmpty
? "Belum Ada Kartu Terpindai"
: rfid,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: const Color(0xff12175E).withOpacity(rfid.isEmpty ? 0.5 : 1),
letterSpacing: rfid.isEmpty ? 0 : 2,
),
),
],
),
);
}
Widget scanButton() {
return SizedBox(
width: double.infinity,
height: 52,
child: DecoratedBox(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
gradient: LinearGradient(
colors: isScanning
? [Colors.grey.shade300, Colors.grey.shade400]
: [const Color(0xff7F56D9), const Color(0xff9181F4)],
),
boxShadow: [
BoxShadow(
color: isScanning ? Colors.transparent : const Color(0xff7F56D9).withOpacity(0.3),
blurRadius: 10,
offset: const Offset(0, 4),
),
],
),
child: ElevatedButton.icon(
onPressed: isScanning ? null : scanKartu,
icon: const Icon(Icons.sensors_rounded, size: 20, color: Colors.white),
label: const Text(
"Mulai Pindai RFID",
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Colors.white),
),
style: ElevatedButton.styleFrom(
elevation: 0,
backgroundColor: Colors.transparent,
shadowColor: Colors.transparent,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
),
),
),
);
}
Widget gradientButton({
required String title,
required VoidCallback onTap,
bool loading = false,
}) {
return SizedBox(
height: 56,
width: double.infinity,
child: DecoratedBox(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
gradient: const LinearGradient(
colors: [Color(0xff7F56D9), Color(0xff9181F4)],
),
boxShadow: [
BoxShadow(
color: const Color(0xff7F56D9).withOpacity(0.35),
blurRadius: 14,
offset: const Offset(0, 6),
),
],
),
child: ElevatedButton(
onPressed: loading ? null : onTap,
style: ElevatedButton.styleFrom(
elevation: 0,
backgroundColor: Colors.transparent,
shadowColor: Colors.transparent,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
),
child: loading
? const SizedBox(height: 24, width: 24, child: CircularProgressIndicator(color: Colors.white, strokeWidth: 2.5))
: Text(
title,
style: const TextStyle(fontSize: 17, fontWeight: FontWeight.bold, color: Colors.white),
),
),
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xffF6F5FB),
body: SafeArea(
child: Column(
children: [
header(),
Expanded(
child: SingleChildScrollView(
physics: const BouncingScrollPhysics(),
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
sectionTitle("Data Akademik Siswa"),
customInput(controller: nama, icon: Icons.person_outline_rounded, hint: "Nama Lengkap Siswa"),
customInput(controller: nomorAbsen, icon: Icons.tag_rounded, hint: "Nomor Absen", keyboardType: TextInputType.number),
kelasDropdown(),
sectionTitle("Data Akun Orang Tua"),
customInput(controller: namaOrtu, icon: Icons.supervisor_account_rounded, hint: "Nama Lengkap Orang Tua / Wali"),
customInput(controller: emailOrtu, icon: Icons.alternate_email_rounded, hint: "Email untuk Login", keyboardType: TextInputType.emailAddress),
customInput(controller: passwordOrtu, icon: Icons.lock_rounded, hint: "Password Akun", password: true),
sectionTitle("Integrasi Kartu RFID"),
scanButton(),
const SizedBox(height: 16),
rfidCard(),
const SizedBox(height: 36),
gradientButton(title: "Simpan & Daftarkan Siswa", onTap: simpan, loading: isLoading),
const SizedBox(height: 24),
],
),
),
),
],
),
),
);
}
}
// Reuse same wave painter from Dashboard
class HeaderWavePainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()
..color = Colors.white.withOpacity(0.3)
..style = PaintingStyle.stroke
..strokeWidth = 1.8;
final path = Path();
path.moveTo(0, size.height * 0.4);
path.quadraticBezierTo(size.width * 0.5, size.height * 0.1, size.width, size.height * 0.3);
canvas.drawPath(path, paint);
final path2 = Path();
path2.moveTo(0, size.height * 0.6);
path2.quadraticBezierTo(size.width * 0.6, size.height * 0.2, size.width, size.height * 0.5);
canvas.drawPath(path2, paint);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
}

371
lib/tambah_user.dart Normal file
View File

@ -0,0 +1,371 @@
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
class TambahUser extends StatefulWidget {
final String role;
const TambahUser({
super.key,
required this.role,
});
@override
State<TambahUser> createState() => _TambahUserState();
}
class _TambahUserState extends State<TambahUser> {
final nama = TextEditingController();
final email = TextEditingController();
final password = TextEditingController();
bool isLoading = false;
bool hidePassword = true;
Future<void> simpan() async {
setState(() => isLoading = true);
try {
final userCred =
await FirebaseAuth.instance.createUserWithEmailAndPassword(
email: email.text.trim(),
password: password.text.trim(),
);
await FirebaseFirestore.instance
.collection('users')
.doc(userCred.user!.uid)
.set({
'nama': nama.text.trim(),
'role': widget.role,
'dibuat_pada': FieldValue.serverTimestamp(),
});
await FirebaseAuth.instance.signOut();
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Pengguna berhasil dibuat'),
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(12))),
),
);
Navigator.pop(context);
}
} catch (e) {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Gagal membuat pengguna: ${e.toString()}'),
behavior: SnackBarBehavior.floating,
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(12))),
),
);
}
}
if (mounted) setState(() => isLoading = false);
}
Widget input(
TextEditingController controller,
String label,
IconData icon, {
bool pass = false,
}) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
label,
style: const TextStyle(
fontSize: 15,
color: Color(0xff2D2669),
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 10),
Row(
children: [
Container(
width: 52,
height: 52,
decoration: BoxDecoration(
color: const Color(0xffF0EBFF),
borderRadius: BorderRadius.circular(14),
),
child: Icon(
icon,
color: const Color(0xff7F56D9),
size: 24,
),
),
const SizedBox(width: 12),
Expanded(
child: SizedBox(
height: 52,
child: TextField(
controller: controller,
obscureText: pass ? hidePassword : false,
style: const TextStyle(fontSize: 14, color: Color(0xff2D2669)),
decoration: InputDecoration(
filled: true,
fillColor: Colors.white,
contentPadding: const EdgeInsets.symmetric(horizontal: 16),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(14),
borderSide: const BorderSide(color: Color(0xffD1D5DB)),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(14),
borderSide: const BorderSide(color: Color(0xffD1D5DB)),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(14),
borderSide: const BorderSide(color: Color(0xff7F56D9), width: 1.5),
),
suffixIcon: pass
? IconButton(
icon: Icon(
hidePassword
? Icons.visibility_outlined
: Icons.visibility_off_outlined,
color: const Color(0xff7F56D9),
size: 20,
),
onPressed: () {
setState(() {
hidePassword = !hidePassword;
});
},
)
: null,
),
),
),
),
],
),
],
);
}
@override
void dispose() {
nama.dispose();
email.dispose();
password.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final isGuru = widget.role == 'guru';
final judul = isGuru ? 'Tambah Guru' : 'Tambah Orang Tua';
return Scaffold(
backgroundColor: const Color(0xffF5F2FF),
body: SafeArea(
child: Stack(
children: [
// HEADER SESUAI GAYA UNGU
Positioned(
top: 0,
left: 0,
right: 0,
child: Container(
height: 200,
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xffEDE9FF),
Color(0xffDCD4FF),
Color(0xffCBBEFF),
],
),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(60),
bottomRight: Radius.circular(60),
),
),
),
),
// Pola titik hiasan
Positioned(
top: 40,
right: 30,
child: Column(
children: List.generate(3, (_) => Row(
children: List.generate(3, (_) => Container(
width: 3,
height: 3,
margin: const EdgeInsets.all(2),
decoration: BoxDecoration(
color: const Color(0xff7F56D9).withOpacity(0.25),
shape: BoxShape.circle,
),
)),
)),
),
),
SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 20),
child: Column(
children: [
// Tombol Kembali
Align(
alignment: Alignment.centerLeft,
child: Container(
width: 44,
height: 44,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
boxShadow: const [BoxShadow(color: Color(0x12000000), blurRadius: 8)],
),
child: IconButton(
padding: EdgeInsets.zero,
icon: const Icon(
Icons.arrow_back_ios_new,
color: Color(0xff7F56D9),
size: 20,
),
onPressed: () => Navigator.pop(context),
),
),
),
const SizedBox(height: 24),
// Judul Halaman
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
'lib/assets/sekolah.png',
height: 70,
fit: BoxFit.contain,
errorBuilder: (_, __, ___) => const Icon(
Icons.school,
size: 60,
color: Color(0xff7F56D9),
),
),
const SizedBox(width: 16),
Container(
width: 1.5,
height: 60,
color: const Color(0xff7F56D9).withOpacity(0.3),
),
const SizedBox(width: 16),
Text(
judul,
style: const TextStyle(
fontSize: 26,
fontWeight: FontWeight.bold,
color: Color(0xff2D2669),
),
),
],
),
const SizedBox(height: 40),
// FORM KARTU
Container(
width: double.infinity,
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(24),
boxShadow: const [
BoxShadow(
color: Color(0x10000000),
blurRadius: 16,
offset: Offset(0, 4),
)
],
),
child: Column(
children: [
input(
nama,
'Nama Lengkap',
Icons.person_outline_rounded,
),
const SizedBox(height: 24),
input(
email,
'Alamat Email',
Icons.email_outlined,
),
const SizedBox(height: 24),
input(
password,
'Kata Sandi',
Icons.lock_outline_rounded,
pass: true,
),
],
),
),
const SizedBox(height: 30),
// TOMBOL SIMPAN
SizedBox(
width: double.infinity,
height: 52,
child: ElevatedButton(
onPressed: isLoading ? null : simpan,
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xff7F56D9),
foregroundColor: Colors.white,
elevation: 3,
shadowColor: const Color(0xff7F56D9).withOpacity(0.3),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (isLoading)
const SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(
color: Colors.white,
strokeWidth: 2,
),
)
else
const Icon(Icons.save_rounded, size: 20),
const SizedBox(width: 10),
Text(
isLoading ? 'Menyimpan...' : 'Simpan Data',
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
],
),
),
),
const SizedBox(height: 40),
],
),
),
],
),
),
);
}
}

1
linux/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
flutter/ephemeral

128
linux/CMakeLists.txt Normal file
View File

@ -0,0 +1,128 @@
# Project-level configuration.
cmake_minimum_required(VERSION 3.13)
project(runner LANGUAGES CXX)
# The name of the executable created for the application. Change this to change
# the on-disk name of your application.
set(BINARY_NAME "absensi")
# The unique GTK application identifier for this application. See:
# https://wiki.gnome.org/HowDoI/ChooseApplicationID
set(APPLICATION_ID "com.example.absensi")
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
# versions of CMake.
cmake_policy(SET CMP0063 NEW)
# Load bundled libraries from the lib/ directory relative to the binary.
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
# Root filesystem for cross-building.
if(FLUTTER_TARGET_PLATFORM_SYSROOT)
set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT})
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
endif()
# Define build configuration options.
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Debug" CACHE
STRING "Flutter build mode" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Profile" "Release")
endif()
# Compilation settings that should be applied to most targets.
#
# Be cautious about adding new options here, as plugins use this function by
# default. In most cases, you should add new options to specific targets instead
# of modifying this function.
function(APPLY_STANDARD_SETTINGS TARGET)
target_compile_features(${TARGET} PUBLIC cxx_std_14)
target_compile_options(${TARGET} PRIVATE -Wall -Werror)
target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
endfunction()
# Flutter library and tool build rules.
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
add_subdirectory(${FLUTTER_MANAGED_DIR})
# System-level dependencies.
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
# Application build; see runner/CMakeLists.txt.
add_subdirectory("runner")
# Run the Flutter tool portions of the build. This must not be removed.
add_dependencies(${BINARY_NAME} flutter_assemble)
# Only the install-generated bundle's copy of the executable will launch
# correctly, since the resources must in the right relative locations. To avoid
# people trying to run the unbundled copy, put it in a subdirectory instead of
# the default top-level location.
set_target_properties(${BINARY_NAME}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
)
# Generated plugin build rules, which manage building the plugins and adding
# them to the application.
include(flutter/generated_plugins.cmake)
# === Installation ===
# By default, "installing" just makes a relocatable bundle in the build
# directory.
set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
endif()
# Start with a clean build bundle directory every time.
install(CODE "
file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
" COMPONENT Runtime)
set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
COMPONENT Runtime)
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
COMPONENT Runtime)
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
install(FILES "${bundled_library}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
endforeach(bundled_library)
# Copy the native assets provided by the build.dart from all packages.
set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/")
install(DIRECTORY "${NATIVE_ASSETS_DIR}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
# Fully re-copy the assets directory on each build to avoid having stale files
# from a previous install.
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
install(CODE "
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
" COMPONENT Runtime)
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
# Install the AOT library on non-Debug builds only.
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
endif()

View File

@ -0,0 +1,88 @@
# This file controls Flutter-level build steps. It should not be edited.
cmake_minimum_required(VERSION 3.10)
set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
# Configuration provided via flutter tool.
include(${EPHEMERAL_DIR}/generated_config.cmake)
# TODO: Move the rest of this into files in ephemeral. See
# https://github.com/flutter/flutter/issues/57146.
# Serves the same purpose as list(TRANSFORM ... PREPEND ...),
# which isn't available in 3.10.
function(list_prepend LIST_NAME PREFIX)
set(NEW_LIST "")
foreach(element ${${LIST_NAME}})
list(APPEND NEW_LIST "${PREFIX}${element}")
endforeach(element)
set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
endfunction()
# === Flutter Library ===
# System-level dependencies.
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
# Published to parent scope for install step.
set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
list(APPEND FLUTTER_LIBRARY_HEADERS
"fl_basic_message_channel.h"
"fl_binary_codec.h"
"fl_binary_messenger.h"
"fl_dart_project.h"
"fl_engine.h"
"fl_json_message_codec.h"
"fl_json_method_codec.h"
"fl_message_codec.h"
"fl_method_call.h"
"fl_method_channel.h"
"fl_method_codec.h"
"fl_method_response.h"
"fl_plugin_registrar.h"
"fl_plugin_registry.h"
"fl_standard_message_codec.h"
"fl_standard_method_codec.h"
"fl_string_codec.h"
"fl_value.h"
"fl_view.h"
"flutter_linux.h"
)
list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
add_library(flutter INTERFACE)
target_include_directories(flutter INTERFACE
"${EPHEMERAL_DIR}"
)
target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
target_link_libraries(flutter INTERFACE
PkgConfig::GTK
PkgConfig::GLIB
PkgConfig::GIO
)
add_dependencies(flutter flutter_assemble)
# === Flutter tool backend ===
# _phony_ is a non-existent file to force this command to run every time,
# since currently there's no way to get a full input/output list from the
# flutter tool.
add_custom_command(
OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
${CMAKE_CURRENT_BINARY_DIR}/_phony_
COMMAND ${CMAKE_COMMAND} -E env
${FLUTTER_TOOL_ENVIRONMENT}
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
VERBATIM
)
add_custom_target(flutter_assemble DEPENDS
"${FLUTTER_LIBRARY}"
${FLUTTER_LIBRARY_HEADERS}
)

View File

@ -0,0 +1,15 @@
//
// Generated file. Do not edit.
//
// clang-format off
#include "generated_plugin_registrant.h"
#include <file_selector_linux/file_selector_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
}

View File

@ -0,0 +1,15 @@
//
// Generated file. Do not edit.
//
// clang-format off
#ifndef GENERATED_PLUGIN_REGISTRANT_
#define GENERATED_PLUGIN_REGISTRANT_
#include <flutter_linux/flutter_linux.h>
// Registers Flutter plugins.
void fl_register_plugins(FlPluginRegistry* registry);
#endif // GENERATED_PLUGIN_REGISTRANT_

View File

@ -0,0 +1,25 @@
#
# Generated file, do not edit.
#
list(APPEND FLUTTER_PLUGIN_LIST
file_selector_linux
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST
jni
)
set(PLUGIN_BUNDLED_LIBRARIES)
foreach(plugin ${FLUTTER_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin)
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)

View File

@ -0,0 +1,26 @@
cmake_minimum_required(VERSION 3.13)
project(runner LANGUAGES CXX)
# Define the application target. To change its name, change BINARY_NAME in the
# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer
# work.
#
# Any new source files that you add to the application should be added here.
add_executable(${BINARY_NAME}
"main.cc"
"my_application.cc"
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
)
# Apply the standard set of build settings. This can be removed for applications
# that need different build settings.
apply_standard_settings(${BINARY_NAME})
# Add preprocessor definitions for the application ID.
add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
# Add dependency libraries. Add any application-specific dependencies here.
target_link_libraries(${BINARY_NAME} PRIVATE flutter)
target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")

6
linux/runner/main.cc Normal file
View File

@ -0,0 +1,6 @@
#include "my_application.h"
int main(int argc, char** argv) {
g_autoptr(MyApplication) app = my_application_new();
return g_application_run(G_APPLICATION(app), argc, argv);
}

View File

@ -0,0 +1,144 @@
#include "my_application.h"
#include <flutter_linux/flutter_linux.h>
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#endif
#include "flutter/generated_plugin_registrant.h"
struct _MyApplication {
GtkApplication parent_instance;
char** dart_entrypoint_arguments;
};
G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
// Called when first Flutter frame received.
static void first_frame_cb(MyApplication* self, FlView *view)
{
gtk_widget_show(gtk_widget_get_toplevel(GTK_WIDGET(view)));
}
// Implements GApplication::activate.
static void my_application_activate(GApplication* application) {
MyApplication* self = MY_APPLICATION(application);
GtkWindow* window =
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
// Use a header bar when running in GNOME as this is the common style used
// by applications and is the setup most users will be using (e.g. Ubuntu
// desktop).
// If running on X and not using GNOME then just use a traditional title bar
// in case the window manager does more exotic layout, e.g. tiling.
// If running on Wayland assume the header bar will work (may need changing
// if future cases occur).
gboolean use_header_bar = TRUE;
#ifdef GDK_WINDOWING_X11
GdkScreen* screen = gtk_window_get_screen(window);
if (GDK_IS_X11_SCREEN(screen)) {
const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
use_header_bar = FALSE;
}
}
#endif
if (use_header_bar) {
GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
gtk_widget_show(GTK_WIDGET(header_bar));
gtk_header_bar_set_title(header_bar, "absensi");
gtk_header_bar_set_show_close_button(header_bar, TRUE);
gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
} else {
gtk_window_set_title(window, "absensi");
}
gtk_window_set_default_size(window, 1280, 720);
g_autoptr(FlDartProject) project = fl_dart_project_new();
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
FlView* view = fl_view_new(project);
GdkRGBA background_color;
// Background defaults to black, override it here if necessary, e.g. #00000000 for transparent.
gdk_rgba_parse(&background_color, "#000000");
fl_view_set_background_color(view, &background_color);
gtk_widget_show(GTK_WIDGET(view));
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
// Show the window when Flutter renders.
// Requires the view to be realized so we can start rendering.
g_signal_connect_swapped(view, "first-frame", G_CALLBACK(first_frame_cb), self);
gtk_widget_realize(GTK_WIDGET(view));
fl_register_plugins(FL_PLUGIN_REGISTRY(view));
gtk_widget_grab_focus(GTK_WIDGET(view));
}
// Implements GApplication::local_command_line.
static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) {
MyApplication* self = MY_APPLICATION(application);
// Strip out the first argument as it is the binary name.
self->dart_entrypoint_arguments = g_strdupv(*arguments + 1);
g_autoptr(GError) error = nullptr;
if (!g_application_register(application, nullptr, &error)) {
g_warning("Failed to register: %s", error->message);
*exit_status = 1;
return TRUE;
}
g_application_activate(application);
*exit_status = 0;
return TRUE;
}
// Implements GApplication::startup.
static void my_application_startup(GApplication* application) {
//MyApplication* self = MY_APPLICATION(object);
// Perform any actions required at application startup.
G_APPLICATION_CLASS(my_application_parent_class)->startup(application);
}
// Implements GApplication::shutdown.
static void my_application_shutdown(GApplication* application) {
//MyApplication* self = MY_APPLICATION(object);
// Perform any actions required at application shutdown.
G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application);
}
// Implements GObject::dispose.
static void my_application_dispose(GObject* object) {
MyApplication* self = MY_APPLICATION(object);
g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev);
G_OBJECT_CLASS(my_application_parent_class)->dispose(object);
}
static void my_application_class_init(MyApplicationClass* klass) {
G_APPLICATION_CLASS(klass)->activate = my_application_activate;
G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line;
G_APPLICATION_CLASS(klass)->startup = my_application_startup;
G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown;
G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
}
static void my_application_init(MyApplication* self) {}
MyApplication* my_application_new() {
// Set the program name to the application ID, which helps various systems
// like GTK and desktop environments map this running application to its
// corresponding .desktop file. This ensures better integration by allowing
// the application to be recognized beyond its binary name.
g_set_prgname(APPLICATION_ID);
return MY_APPLICATION(g_object_new(my_application_get_type(),
"application-id", APPLICATION_ID,
"flags", G_APPLICATION_NON_UNIQUE,
nullptr));
}

View File

@ -0,0 +1,18 @@
#ifndef FLUTTER_MY_APPLICATION_H_
#define FLUTTER_MY_APPLICATION_H_
#include <gtk/gtk.h>
G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION,
GtkApplication)
/**
* my_application_new:
*
* Creates a new Flutter-based application.
*
* Returns: a new #MyApplication.
*/
MyApplication* my_application_new();
#endif // FLUTTER_MY_APPLICATION_H_

Some files were not shown because too many files have changed in this diff Show More