joss jiss
This commit is contained in:
parent
47fc79455b
commit
07d5cb369a
|
|
@ -115,7 +115,8 @@ class DeviceSetupBloc extends Bloc<DeviceSetupEvent, DeviceSetupState> {
|
||||||
// ESP restart setelah terima kredensial → koneksi putus → itu normal!
|
// ESP restart setelah terima kredensial → koneksi putus → itu normal!
|
||||||
// DioException di sini kemungkinan besar karena ESP sudah restart.
|
// DioException di sini kemungkinan besar karena ESP sudah restart.
|
||||||
if (e.type == DioExceptionType.receiveTimeout ||
|
if (e.type == DioExceptionType.receiveTimeout ||
|
||||||
e.type == DioExceptionType.connectionError) {
|
e.type == DioExceptionType.connectionError ||
|
||||||
|
e.type == DioExceptionType.sendTimeout) {
|
||||||
emit(state.copyWith(
|
emit(state.copyWith(
|
||||||
status: DeviceSetupStatus.success,
|
status: DeviceSetupStatus.success,
|
||||||
successMessage:
|
successMessage:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import '../blocs/device_setup_bloc.dart';
|
import '../blocs/device_setup_bloc.dart';
|
||||||
|
import 'package:app_settings/app_settings.dart';
|
||||||
|
|
||||||
class DeviceSetupScreen extends StatefulWidget {
|
class DeviceSetupScreen extends StatefulWidget {
|
||||||
const DeviceSetupScreen({super.key});
|
const DeviceSetupScreen({super.key});
|
||||||
|
|
@ -159,7 +160,7 @@ class _DeviceSetupScreenState extends State<DeviceSetupScreen> {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
builder: (_) => AlertDialog(
|
builder: (dialogContext) => AlertDialog(
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||||
title: Row(
|
title: Row(
|
||||||
children: [
|
children: [
|
||||||
|
|
@ -173,12 +174,21 @@ class _DeviceSetupScreenState extends State<DeviceSetupScreen> {
|
||||||
),
|
),
|
||||||
content: Text(message),
|
content: Text(message),
|
||||||
actions: [
|
actions: [
|
||||||
|
if (!success) // ← tambah tombol Coba Lagi jika gagal
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pop(); // tutup dialog
|
Navigator.of(dialogContext).pop(); // tutup dialog
|
||||||
Navigator.of(context).pop(); // kembali ke wind_speed_screen
|
context.read<DeviceSetupBloc>().add(
|
||||||
|
ResetDeviceSetupEvent()); // kembali ke wind_speed_screen
|
||||||
},
|
},
|
||||||
child: const Text('Selesai'),
|
child: const Text('Coba Lagi'),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(dialogContext).pop();
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
child: Text(success ? 'Selesai' : 'Tutup'),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
@ -353,13 +363,7 @@ class _OpenWifiSettingsButton extends StatelessWidget {
|
||||||
// Buka pengaturan WiFi sistem HP
|
// Buka pengaturan WiFi sistem HP
|
||||||
// Butuh package: app_settings (opsional)
|
// Butuh package: app_settings (opsional)
|
||||||
// AppSettings.openWIFISettings();
|
// AppSettings.openWIFISettings();
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
AppSettings.openAppSettings(type: AppSettingsType.wifi);
|
||||||
const SnackBar(
|
|
||||||
content: Text(
|
|
||||||
'Buka Pengaturan WiFi HP → sambungkan ke "Anemometer-Setup"'),
|
|
||||||
behavior: SnackBarBehavior.floating,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
icon: const Icon(Icons.settings_rounded, size: 16),
|
icon: const Icon(Icons.settings_rounded, size: 16),
|
||||||
label: const Text('Buka Setting'),
|
label: const Text('Buka Setting'),
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@ part 'wind_speed_state.dart';
|
||||||
|
|
||||||
/// Threshold kecepatan angin (satuan m/s)
|
/// Threshold kecepatan angin (satuan m/s)
|
||||||
/// Referensi: Beaufort scale & BMKG
|
/// Referensi: Beaufort scale & BMKG
|
||||||
const double _kWindWarning = 2.0; // Waspada: 8–12.5 m/s (~29–45 km/h)
|
const double _kWindWarning = 8.0; // Waspada: 8–12.5 m/s (~29–45 km/h)
|
||||||
const double _kWindDanger = 4.0; // Bahaya: > 12.5 m/s (> 45 km/h)
|
const double _kWindDanger = 12.5; // Bahaya: > 12.5 m/s (> 45 km/h)
|
||||||
|
|
||||||
class WindSpeedBloc extends Bloc<WindSpeedEvent, WindSpeedState> {
|
class WindSpeedBloc extends Bloc<WindSpeedEvent, WindSpeedState> {
|
||||||
final MonitoringRepository _repository;
|
final MonitoringRepository _repository;
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,3 @@ class WindSpeedPeriodChanged extends WindSpeedEvent {
|
||||||
final String period;
|
final String period;
|
||||||
const WindSpeedPeriodChanged(this.period);
|
const WindSpeedPeriodChanged(this.period);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event internal: saat data baru masuk dari Firebase
|
|
||||||
class _WindSpeedUpdated extends WindSpeedEvent {
|
|
||||||
final MyWindSpeed data;
|
|
||||||
const _WindSpeedUpdated(this.data);
|
|
||||||
@override
|
|
||||||
List<Object> get props => [data];
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ class WindSpeedState extends Equatable {
|
||||||
weeklySpeeds,
|
weeklySpeeds,
|
||||||
monthlySpeeds,
|
monthlySpeeds,
|
||||||
isLoading,
|
isLoading,
|
||||||
history
|
history,
|
||||||
|
alertLevel,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
import FlutterMacOS
|
import FlutterMacOS
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
import app_settings
|
||||||
import cloud_firestore
|
import cloud_firestore
|
||||||
import firebase_auth
|
import firebase_auth
|
||||||
import firebase_core
|
import firebase_core
|
||||||
|
|
@ -13,6 +14,7 @@ import google_sign_in_ios
|
||||||
import printing
|
import printing
|
||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
|
AppSettingsPlugin.register(with: registry.registrar(forPlugin: "AppSettingsPlugin"))
|
||||||
FLTFirebaseFirestorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseFirestorePlugin"))
|
FLTFirebaseFirestorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseFirestorePlugin"))
|
||||||
FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin"))
|
FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin"))
|
||||||
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
|
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.66"
|
version: "1.3.66"
|
||||||
|
app_settings:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: app_settings
|
||||||
|
sha256: "64d50e666fd96ae90301bf71205f05019286f940ad6f5fed3d1be19c6af7546a"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "7.0.0"
|
||||||
archive:
|
archive:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ version: 1.0.0+1
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.1.0
|
sdk: ^3.1.0
|
||||||
dependencies:
|
dependencies:
|
||||||
|
app_settings: ^7.0.0
|
||||||
bloc: ^8.1.0
|
bloc: ^8.1.0
|
||||||
bloc_concurrency: ^0.2.5
|
bloc_concurrency: ^0.2.5
|
||||||
cloud_firestore: ^6.1.1
|
cloud_firestore: ^6.1.1
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue