Skip to content

About

An app for Ma'had Tahfizh Al-Qur'an Al-Imam Asy-Syathiby

Resources

Stars

0 stars

Watchers

0 watching

Forks

Β 
Β 

Latest commit

Β 

History

21 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Syathiby App

Attendance and staff management application for Ma'had Tahfizh al-Qur'an al-Imam as-Syathiby.

Enhanced and customized version of Syathiby Vendor App β€” https://github.com/creatorb/flutter-syathiby-vendor

πŸ“‹ Changelog: See CHANGELOG.md for full version history.


πŸ“‘ Table of Contents


πŸš€ Quick Start

# 1. Clone repository
git clone https://github.com/creatorb/flutter_syathiby.git
cd flutter_syathiby

# 2. Install dependencies
fvm flutter pub get

# 3. Generate code
fvm flutter pub run build_runner build --delete-conflicting-outputs

# 4. Run app (PROD flavor β€” automatically uses production URL)
fvm flutter run --flavor prod --dart-define=FLAVOR=prod

# 5. Run app (LOCAL flavor β€” automatically uses local URL)
fvm flutter run --flavor local --dart-define=FLAVOR=local

πŸ“‹ Prerequisites

  • Flutter SDK: Managed via FVM
  • Android Studio / Xcode (for Android/iOS builds)
  • ADB (Android Debug Bridge) for device deployment
  • Git

Install FVM (Flutter Version Manager)

# Windows (PowerShell)
choco install fvm

# macOS
brew tap leoafarias/fvm
brew install fvm

# Linux / Manual
dart pub global activate fvm

πŸ”§ Installation

1. Set Up FVM and Flutter SDK

# Install the Flutter version used by this project
fvm install

# Activate FVM version
fvm use

2. Install Dependencies

fvm flutter pub get

3. Generate Models & Code

fvm flutter pub run build_runner build --delete-conflicting-outputs

4. (Optional) Set Up Keystore for Release Build

See the Keystore section below.


🌐 URL Environment Setup (Flavor-Based)

The app uses automatic flavor-based URL configuration. The backend URL is selected automatically based on the active flavor:

Default Configuration (Built-in)

Flavor API URL Link Base App Name
prod https://aplikasi.syathiby.id/geten/ https://aplikasi.syathiby.id Syathiby
local http://192.168.50.100/aplikasi/geten/ http://192.168.50.100/aplikasi Syathiby LOCAL

⚑ Usage

Production:

fvm flutter run --flavor prod --dart-define=FLAVOR=prod

βœ… Automatically uses: https://aplikasi.syathiby.id

Local Development:

fvm flutter run --flavor local --dart-define=FLAVOR=local

βœ… Automatically uses: http://192.168.50.100/aplikasi

Note: --dart-define=FLAVOR=xxx tells the app which flavor is active so the correct URL is selected automatically.

πŸ”§ Changing the Default URL

If your local server IP is not 192.168.50.100, edit:

πŸ“„ lib/res/flavor_config.dart

static const Map<String, Map<String, String>> _configs = {
  'prod': {
    'API_URL': 'https://aplikasi.syathiby.id/geten/',
    'LINK_BASE': 'https://aplikasi.syathiby.id',
  },
  'local': {
    'API_URL': 'http://192.168.1.100/aplikasi/geten/',  // ← Change IP here
    'LINK_BASE': 'http://192.168.1.100/aplikasi',       // ← and here
  },
};

After editing, rebuild:

fvm flutter clean
fvm flutter pub get
fvm flutter run --flavor local --dart-define=FLAVOR=local

πŸŽ›οΈ Runtime URL Override (Without Rebuild)

You can also temporarily override the URL at runtime without rebuilding:

  1. Launch the app (any flavor)
  2. On the Login screen, long-press the Syathiby logo
  3. A dialog appears showing the active URL
  4. Enter your custom URL:
    API URL:   http://192.168.1.200/aplikasi/geten/
    Link Base: http://192.168.1.200/aplikasi
    
  5. Tap "Save & Restart"

The override is stored in SharedPreferences and persists until manually reset.

πŸ”„ Reset to Flavor Default

  1. Long-press the logo on the Login screen
  2. Clear all fields
  3. Tap "Save & Restart"

The app will revert to the default URL for the active flavor.

πŸ’‘ Development Tips

Find your server's local IP:

Windows:

ipconfig

macOS / Linux:

ifconfig
# or
ip addr show

Look for an IP starting with 192.168.x.x or 10.x.x.x.

Environment detection:

The app automatically detects the environment based on the active URL:

  • Local IP (192.168.x.x, 10.x.x.x, 172.16–31.x.x, localhost) β†’ LOCAL (red banner)
  • Other public domain β†’ PROD (green banner, hidden in release)

πŸ“ Relevant File Structure

flutter_syathiby/
└── lib/res/
    β”œβ”€β”€ flavor_config.dart          # URL configuration per flavor
    β”œβ”€β”€ environment_config.dart     # Runtime config + URL override logic
    └── env.dart                    # Legacy (optional, for MAPS_API_KEY)

πŸ› URL Environment Troubleshooting

Issue: URL still wrong after changing flavor

# Make sure to pass --dart-define=FLAVOR
fvm flutter run --flavor local --dart-define=FLAVOR=local
# ⚠️ NOT: fvm flutter run --flavor local  (missing --dart-define)

Issue: Cannot connect to local server

  1. βœ… Verify the backend server is running
  2. βœ… Device and server are on the same network (same Wi-Fi)
  3. βœ… Test the URL in a browser: http://192.168.x.x/aplikasi/geten/
  4. βœ… Check firewall is not blocking the connection
  5. βœ… Use the device's IP address, not localhost

Issue: Environment label shows PROD instead of LOCAL

  • Long-press the logo to verify the actual URL in use
  • Ensure the URL uses http:// (not https://) for local
  • Confirm the IP matches the local pattern: 192.168.x.x

πŸ’» Development

Run App (Development Mode)

# PROD flavor (automatically uses https://aplikasi.syathiby.id)
fvm flutter run --flavor prod --dart-define=FLAVOR=prod

# LOCAL flavor (automatically uses http://192.168.50.100/aplikasi)
fvm flutter run --flavor local --dart-define=FLAVOR=local

# Specify device
fvm flutter run -d <device-id> --flavor prod --dart-define=FLAVOR=prod
fvm flutter run -d 127.0.0.1:5555 --flavor local --dart-define=FLAVOR=local

Hot Reload & Restart

  • Hot Reload: r (in terminal while app is running)
  • Hot Restart: R
  • Quit: q

Code Generation

Run whenever you modify models or environment config:

fvm flutter pub run build_runner build --delete-conflicting-outputs

Watch mode (auto-generates on file changes):

fvm flutter pub run build_runner watch --delete-conflicting-outputs

Clean Build

If you encounter cache or dependency issues:

fvm flutter clean
fvm flutter pub get
fvm flutter pub run build_runner build --delete-conflicting-outputs

πŸ”¨ Building & Deployment

Android APK (Debug)

# PROD flavor
fvm flutter build apk --debug --flavor prod --dart-define=FLAVOR=prod

# LOCAL flavor
fvm flutter build apk --debug --flavor local --dart-define=FLAVOR=local

Output: build/app/outputs/flutter-apk/

Android APK (Release)

# PROD flavor
fvm flutter clean
fvm flutter pub get
fvm flutter pub run build_runner build --delete-conflicting-outputs
fvm flutter build apk --release --flavor prod --dart-define=FLAVOR=prod

# LOCAL flavor
fvm flutter clean
fvm flutter pub get
fvm flutter pub run build_runner build --delete-conflicting-outputs
fvm flutter build apk --release --flavor local --dart-define=FLAVOR=local

Android App Bundle (AAB) β€” Play Store

# PROD
fvm flutter clean
fvm flutter pub get
fvm flutter pub run build_runner build --delete-conflicting-outputs
fvm flutter build appbundle --release --flavor prod --dart-define=FLAVOR=prod

# LOCAL
fvm flutter clean
fvm flutter pub get
fvm flutter pub run build_runner build --delete-conflicting-outputs
fvm flutter build appbundle --release --flavor local --dart-define=FLAVOR=local

Output: build/app/outputs/bundle/

Install Both APKs Side-by-Side

Use the PowerShell script to install PROD and LOCAL simultaneously:

.\install-both-apks.ps1

Requirements:

  • Android device connected via USB or Wi-Fi
  • ADB installed and available in PATH
  • Both APKs already built (see above)

The script will:

  1. Validate ADB availability
  2. Check device connection
  3. Install app-local-debug.apk β†’ id.syathiby.app.local
  4. Install app-prod-debug.apk β†’ id.syathiby.app
  5. Display colored status output (green = success, red = failed)

Web Build

fvm flutter clean
fvm flutter pub get
fvm flutter pub run build_runner build --delete-conflicting-outputs
fvm flutter build web --release --tree-shake-icons

Output: build/web/

.htaccess for web deployment:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.html [L]

Run web locally:

fvm flutter run -d chrome --web-hostname 192.168.50.100 --web-port 8082

✨ Features

Attendance System

The app supports two attendance methods:

  1. Location (GPS): Validates attendance based on GPS coordinates and location radius
  2. Network (Wi-Fi / LAN): Validates attendance using the device's public IP address

How Wi-Fi attendance works:

  • User selects the attendance method when tapping the check-in/out button
  • Wi-Fi mode sends coordinates (0, 0) as a mode indicator to the backend
  • The app fetches the allowed public IP from the server endpoint (settings/wificonfig.php)
  • The app validates the device's current public IP against the allowed IP via an external IP API
  • If validation passes, the attendance request is submitted β€” backend skips GPS radius check for (0, 0) coordinates
  • Error code 03 is used for Wi-Fi validation failures

Update Checker

  • Automatically checks for a new version on app startup (Home screen)
  • Compares current app version with the latest version in CHANGELOG.md on GitHub
  • Displays a bottom sheet modal with the changelog content when an update is available
  • Provides a direct link to the Play Store for the update
  • Non-blocking: users can dismiss and continue using the current version

Profile Management

View and manage staff profile information.

Leave Request System

Submit and track leave/permit requests.

Timeline & Activity Tracking

View attendance history and activity timeline.


🎨 Environment Indicators

The app provides visual indicators to distinguish between environments:

Global Banner (Ribbon) β€” LOCAL Only

  • LOCAL: Red ribbon with "LOCAL" label (development indicator)
  • PROD: No banner β€” clean UI for end users

Production builds have a clean UI without any environment banner.

Dynamic App Name

  • Local environment: "Syathiby LOCAL"
  • Production environment: "Syathiby"

Login Screen Badge

  • Displays the active ENV label and API URL
  • Red for LOCAL, green for PROD
  • Long-press logo to override the API URL at runtime

Android Flavors

Flavor prod Flavor local
Application ID id.syathiby.app id.syathiby.app.local
App Label Syathiby Syathiby LOCAL
Banner ❌ None (clean UI) πŸ”΄ Red ribbon

Both flavors can be installed simultaneously on the same device.


πŸ§ͺ Testing

Wi-Fi Attendance Test Guide

A detailed test checklist for Wi-Fi attendance is available at:

πŸ“„ ATTENDANCE_WIFI_TEST_CHECKLIST.md

Flutter Analyzer

fvm flutter analyze

Unit Tests

fvm flutter test

πŸ› οΈ Troubleshooting

Build Runner β€” Conflicting Outputs

fvm flutter pub run build_runner build --delete-conflicting-outputs

Gradle Issues (Android)

Clear Gradle cache:

# Windows
Remove-Item -Recurse -Force $env:USERPROFILE\.gradle\caches

# macOS/Linux
rm -rf ~/.gradle/caches

Then rebuild:

fvm flutter clean
fvm flutter pub get

ADB Device Not Found

# Check connected devices
adb devices

# Restart ADB server
adb kill-server
adb start-server

# Connect via Wi-Fi (after USB pairing)
adb tcpip 5555
adb connect <device-ip>:5555

FVM Not Found

Make sure FVM is added to PATH:

# Check FVM installation
fvm --version

# Install FVM if missing
dart pub global activate fvm

# Add to PATH (Windows example)
# Add: %USERPROFILE%\AppData\Local\Pub\Cache\bin

πŸ” Keystore

Debug Keystore

Generate a debug keystore for development:

keytool -genkeypair -v `
  -keystore debug.keystore `
  -alias androiddebugkey `
  -keyalg RSA -keysize 2048 `
  -validity 10000 `
  -storetype pkcs12 `
  -storepass android `
  -keypass android `
  -dname "CN=https://github.com/CreatorB, O=Freelance Fullstack Developer, C=ID"

Release Keystore

For production builds, use a secure keystore. Store it in a safe location and never commit it to git.


πŸ› οΈ Advanced Configuration

Rename App and Package Name

dart run flutter_application_id:main -f flutter_application_id.yaml

Change App Icon

# Generate configuration
dart run flutter_launcher_icons:generate --override

# Generate icons
dart run flutter_launcher_icons

Change Splash Screen

dart run flutter_native_splash:create

πŸ“¦ Project Structure

flutter_syathiby/
β”œβ”€β”€ android/                        # Android native code & flavor config
β”œβ”€β”€ ios/                            # iOS native code
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ app.dart                    # Root MaterialApp with environment banner
β”‚   β”œβ”€β”€ data/                       # Models, repositories, API services
β”‚   β”œβ”€β”€ presentation/
β”‚   β”‚   β”œβ”€β”€ home/                   # Home screen with update checker
β”‚   β”‚   β”œβ”€β”€ login/                  # Login screen with environment badge
β”‚   β”‚   └── presence/               # Attendance screen with Wi-Fi option
β”‚   β”œβ”€β”€ res/
β”‚   β”‚   β”œβ”€β”€ flavor_config.dart      # Built-in URL configuration per flavor
β”‚   β”‚   β”œβ”€β”€ environment_config.dart # Runtime config + URL override
β”‚   β”‚   └── strings.dart            # App constants, dynamic app name
β”‚   └── utils/
β”‚       └── update_checker.dart     # GitHub CHANGELOG version check
β”œβ”€β”€ test/                           # Unit & widget tests
β”œβ”€β”€ build/                          # Build outputs (gitignored)
β”œβ”€β”€ CHANGELOG.md                    # Version history
β”œβ”€β”€ ATTENDANCE_WIFI_TEST_CHECKLIST.md  # Wi-Fi attendance test guide
β”œβ”€β”€ install-both-apks.ps1           # Dual APK installer script
β”œβ”€β”€ pubspec.yaml                    # Flutter dependencies
└── README.md                       # This file

🀝 Contributing

  1. Create a new branch from test
  2. Implement features or fixes with clear commit messages
  3. Update CHANGELOG.md with a new entry
  4. Test all changes thoroughly
  5. Open a Pull Request to the test branch

Commit Message Convention

feat: add feature X
fix: resolve bug Y
docs: update documentation for Z
chore: update dependencies
refactor: restructure code for A

🌿 Branches

Active development branch β€” continuously updated with the latest features and requirements.

Stable branch. Maintained to support the latest production requirements with original features intact.


πŸ‘₯ Team & Contact

Ma'had Tahfizh al-Qur'an al-Imam as-Syathiby
Cileungsi, Bogor, Indonesia

  • Website: syathiby.com
  • Tags: pondok jabodetabek ma'had tahfizh al-Qur'an sunnah manhaj salaf cileungsi bogor indonesia syathiby

πŸ“„ License

Copyright IT Syathiby 2024

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

About

An app for Ma'had Tahfizh Al-Qur'an Al-Imam Asy-Syathiby

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages