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