mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-08-25 17:29:42 +00:00
Compare commits
20 Commits
0f9cbd22a2
...
main
Author | SHA1 | Date | |
---|---|---|---|
534eed98e9 | |||
4fd46d820d | |||
8534cb3045 | |||
fcaed3e4e3 | |||
445d4facab | |||
b159c4f052 | |||
6afebdfef8 | |||
a24630b3eb | |||
4768b4a89e | |||
11cf992a1a | |||
774a1533f5 | |||
403b45c826 | |||
ed2b91d380 | |||
5bb3688a51 | |||
d6fcf051c6 | |||
5544430efa | |||
ae89a24a4b | |||
ecc01a1eb3 | |||
921da20d3f | |||
2fed2d9de3 |
@ -1,2 +1,3 @@
|
|||||||
ENV_NAME=development
|
ENV_NAME=development
|
||||||
BASE_URL=https://syncrow-dev.azurewebsites.net
|
BASE_URL=https://syncrow-dev.azurewebsites.net
|
||||||
|
RTDB_URL=https://syncrow-dev-79446.asia-southeast1.firebasedatabase.app/
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
ENV_NAME=production
|
ENV_NAME=production
|
||||||
BASE_URL=https://syncrow-staging.azurewebsites.net
|
BASE_URL=https://syncrow-staging.azurewebsites.net
|
||||||
|
RTDB_URL=https://syncrow-prod-79446.asia-southeast1.firebasedatabase.app/
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
ENV_NAME=staging
|
ENV_NAME=staging
|
||||||
BASE_URL=https://syncrow-staging.azurewebsites.net
|
BASE_URL=https://syncrow-staging.azurewebsites.net
|
||||||
|
RTDB_URL=https://syncrow-staging-79446.asia-southeast1.firebasedatabase.app/
|
||||||
|
112
.vscode/launch.json
vendored
112
.vscode/launch.json
vendored
@ -1,67 +1,49 @@
|
|||||||
{
|
{
|
||||||
"configurations": [
|
"configurations": [
|
||||||
|
{
|
||||||
{
|
"name": "DEVELOPMENT",
|
||||||
|
"request": "launch",
|
||||||
"name": "DEVELOPMENT",
|
"type": "dart",
|
||||||
|
"args": [
|
||||||
"request": "launch",
|
"-d",
|
||||||
|
"chrome",
|
||||||
"type": "dart",
|
"--web-port",
|
||||||
|
"3000",
|
||||||
"args": [
|
"-t",
|
||||||
"-d",
|
"lib/main_dev.dart",
|
||||||
"chrome",
|
"--web-experimental-hot-reload"
|
||||||
"--web-port",
|
],
|
||||||
"3000",
|
"flutterMode": "debug"
|
||||||
"-t",
|
},
|
||||||
"lib/main_dev.dart",
|
{
|
||||||
"--web-experimental-hot-reload",
|
"name": "STAGING",
|
||||||
],
|
"request": "launch",
|
||||||
|
"type": "dart",
|
||||||
"flutterMode": "debug"
|
"args": [
|
||||||
|
"-d",
|
||||||
},{
|
"chrome",
|
||||||
|
"--web-port",
|
||||||
"name": "STAGING",
|
"3000",
|
||||||
|
"-t",
|
||||||
"request": "launch",
|
"lib/main_staging.dart",
|
||||||
|
"--web-experimental-hot-reload"
|
||||||
"type": "dart",
|
],
|
||||||
|
"flutterMode": "debug"
|
||||||
"args": [
|
},
|
||||||
"-d",
|
{
|
||||||
"chrome",
|
"name": "PRODUCTION",
|
||||||
"--web-port",
|
"request": "launch",
|
||||||
"3000",
|
"type": "dart",
|
||||||
"-t",
|
"args": [
|
||||||
"lib/main_staging.dart",
|
"-d",
|
||||||
"--web-experimental-hot-reload",
|
"chrome",
|
||||||
],
|
"--web-port",
|
||||||
|
"3000",
|
||||||
"flutterMode": "debug"
|
"-t",
|
||||||
|
"lib/main.dart",
|
||||||
},{
|
"--web-experimental-hot-reload"
|
||||||
|
],
|
||||||
"name": "PRODUCTION",
|
"flutterMode": "debug"
|
||||||
|
}
|
||||||
"request": "launch",
|
]
|
||||||
|
|
||||||
"type": "dart",
|
|
||||||
|
|
||||||
"args": [
|
|
||||||
"-d",
|
|
||||||
"chrome",
|
|
||||||
"--web-port",
|
|
||||||
"3000",
|
|
||||||
"-t",
|
|
||||||
"lib/main.dart",
|
|
||||||
"--web-experimental-hot-reload",
|
|
||||||
],
|
|
||||||
|
|
||||||
"flutterMode": "debug"
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
]
|
|
||||||
}
|
}
|
@ -1 +1 @@
|
|||||||
{"flutter":{"platforms":{"android":{"default":{"projectId":"test2-8a3d2","appId":"1:427332280600:android:2bc36fbe82994a3e0c7e6d","fileOutput":"android/app/google-services.json"}},"ios":{"default":{"projectId":"test2-8a3d2","appId":"1:427332280600:ios:14346b200780dc760c7e6d","uploadDebugSymbols":true,"fileOutput":"ios/Runner/GoogleService-Info.plist"}},"macos":{"default":{"projectId":"test2-8a3d2","appId":"1:427332280600:ios:14346b200780dc760c7e6d","uploadDebugSymbols":true,"fileOutput":"macos/Runner/GoogleService-Info.plist"}},"dart":{"lib/firebase_options.dart":{"projectId":"test2-8a3d2","configurations":{"android":"1:427332280600:android:2bc36fbe82994a3e0c7e6d","ios":"1:427332280600:ios:14346b200780dc760c7e6d","macos":"1:427332280600:ios:14346b200780dc760c7e6d","web":"1:427332280600:web:ad50516a87a35a1a0c7e6d","windows":"1:427332280600:web:f7a25537ccd5a7bd0c7e6d"}}}}}}
|
{"flutter":{"platforms":{"android":{"default":{"projectId":"test2-8a3d2","appId":"1:427332280600:android:2bc36fbe82994a3e0c7e6d","fileOutput":"android/app/google-services.json"}},"ios":{"default":{"projectId":"test2-8a3d2","appId":"1:427332280600:ios:14346b200780dc760c7e6d","uploadDebugSymbols":true,"fileOutput":"ios/Runner/GoogleService-Info.plist"}},"macos":{"default":{"projectId":"test2-8a3d2","appId":"1:427332280600:ios:14346b200780dc760c7e6d","uploadDebugSymbols":true,"fileOutput":"macos/Runner/GoogleService-Info.plist"}},"dart":{"lib/firebase_options.dart":{"projectId":"syncrow-prod-79446","configurations":{"web":"1:255001682464:web:a03e2d6214c13101561245"}}}}}}
|
16
lib/firebase_options.dart
Normal file
16
lib/firebase_options.dart
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
|
||||||
|
|
||||||
|
final class DefaultFirebaseOptions extends FirebaseOptions {
|
||||||
|
const DefaultFirebaseOptions({
|
||||||
|
required String databaseUrl,
|
||||||
|
}) : super(
|
||||||
|
apiKey: 'AIzaSyDgq5ywsnFVbbQO-Xz1Z4sR5bBcuiDaS9g',
|
||||||
|
appId: '1:255001682464:web:a03e2d6214c13101561245',
|
||||||
|
messagingSenderId: '255001682464',
|
||||||
|
projectId: 'syncrow-prod-79446',
|
||||||
|
authDomain: 'syncrow-prod-79446.firebaseapp.com',
|
||||||
|
storageBucket: 'syncrow-prod-79446.firebasestorage.app',
|
||||||
|
databaseURL: databaseUrl,
|
||||||
|
measurementId: 'G-1850Q89RMK',
|
||||||
|
);
|
||||||
|
}
|
@ -1,93 +0,0 @@
|
|||||||
// 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 DefaultFirebaseOptionsDev {
|
|
||||||
static FirebaseOptions get currentPlatform {
|
|
||||||
if (kIsWeb) {
|
|
||||||
return web;
|
|
||||||
}
|
|
||||||
switch (defaultTargetPlatform) {
|
|
||||||
case TargetPlatform.android:
|
|
||||||
return android;
|
|
||||||
case TargetPlatform.iOS:
|
|
||||||
return ios;
|
|
||||||
case TargetPlatform.macOS:
|
|
||||||
return macos;
|
|
||||||
case TargetPlatform.windows:
|
|
||||||
return windows;
|
|
||||||
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: 'AIzaSyCVEvKsJYzhWDFM-9Od68FE0nPpP933st0',
|
|
||||||
appId: '1:427332280600:web:ad50516a87a35a1a0c7e6d',
|
|
||||||
messagingSenderId: '427332280600',
|
|
||||||
projectId: 'test2-8a3d2',
|
|
||||||
authDomain: 'test2-8a3d2.firebaseapp.com',
|
|
||||||
databaseURL: 'https://test2-8a3d2-default-rtdb.firebaseio.com',
|
|
||||||
storageBucket: 'test2-8a3d2.firebasestorage.app',
|
|
||||||
measurementId: 'G-Z1RTTTV5H9',
|
|
||||||
);
|
|
||||||
|
|
||||||
static const FirebaseOptions android = FirebaseOptions(
|
|
||||||
apiKey: 'AIzaSyA5qOErxdm0zJmoHIB0TixfebYEsNRpwV0',
|
|
||||||
appId: '1:427332280600:android:2bc36fbe82994a3e0c7e6d',
|
|
||||||
messagingSenderId: '427332280600',
|
|
||||||
projectId: 'test2-8a3d2',
|
|
||||||
databaseURL: 'https://test2-8a3d2-default-rtdb.firebaseio.com',
|
|
||||||
storageBucket: 'test2-8a3d2.firebasestorage.app',
|
|
||||||
);
|
|
||||||
|
|
||||||
static const FirebaseOptions ios = FirebaseOptions(
|
|
||||||
apiKey: 'AIzaSyABnpH6yo2RRjtkp4PlvtK84hKwRm2DhBw',
|
|
||||||
appId: '1:427332280600:ios:14346b200780dc760c7e6d',
|
|
||||||
messagingSenderId: '427332280600',
|
|
||||||
projectId: 'test2-8a3d2',
|
|
||||||
databaseURL: 'https://test2-8a3d2-default-rtdb.firebaseio.com',
|
|
||||||
storageBucket: 'test2-8a3d2.firebasestorage.app',
|
|
||||||
iosBundleId: 'com.example.syncrowWeb',
|
|
||||||
);
|
|
||||||
|
|
||||||
static const FirebaseOptions macos = FirebaseOptions(
|
|
||||||
apiKey: 'AIzaSyABnpH6yo2RRjtkp4PlvtK84hKwRm2DhBw',
|
|
||||||
appId: '1:427332280600:ios:14346b200780dc760c7e6d',
|
|
||||||
messagingSenderId: '427332280600',
|
|
||||||
projectId: 'test2-8a3d2',
|
|
||||||
databaseURL: 'https://test2-8a3d2-default-rtdb.firebaseio.com',
|
|
||||||
storageBucket: 'test2-8a3d2.firebasestorage.app',
|
|
||||||
iosBundleId: 'com.example.syncrowWeb',
|
|
||||||
);
|
|
||||||
|
|
||||||
static const FirebaseOptions windows = FirebaseOptions(
|
|
||||||
apiKey: 'AIzaSyDizKjPC5rdkEjDxwXjM-RU5unB0Ziq3iw',
|
|
||||||
appId: '1:427332280600:web:f7a25537ccd5a7bd0c7e6d',
|
|
||||||
messagingSenderId: '427332280600',
|
|
||||||
projectId: 'test2-8a3d2',
|
|
||||||
authDomain: 'test2-8a3d2.firebaseapp.com',
|
|
||||||
databaseURL: 'https://test2-8a3d2-default-rtdb.firebaseio.com',
|
|
||||||
storageBucket: 'test2-8a3d2.firebasestorage.app',
|
|
||||||
measurementId: 'G-4LFVXEXWKY',
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,77 +0,0 @@
|
|||||||
// 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 DefaultFirebaseOptionsStaging {
|
|
||||||
static FirebaseOptions get currentPlatform {
|
|
||||||
if (kIsWeb) {
|
|
||||||
return web;
|
|
||||||
}
|
|
||||||
switch (defaultTargetPlatform) {
|
|
||||||
case TargetPlatform.android:
|
|
||||||
return android;
|
|
||||||
case TargetPlatform.iOS:
|
|
||||||
return ios;
|
|
||||||
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 android = FirebaseOptions(
|
|
||||||
apiKey: 'AIzaSyDP9GpYfLE8gHTj3kZ1hW8fx_FkJqOqSQk',
|
|
||||||
appId: '1:786692570726:android:0ef7079c2b978d4417b7a7',
|
|
||||||
messagingSenderId: '786692570726',
|
|
||||||
projectId: 'syncrow-staging',
|
|
||||||
databaseURL: 'https://syncrow-staging-default-rtdb.firebaseio.com',
|
|
||||||
storageBucket: 'syncrow-staging.appspot.com',
|
|
||||||
);
|
|
||||||
|
|
||||||
static const FirebaseOptions ios = FirebaseOptions(
|
|
||||||
apiKey: 'AIzaSyAWlRiuJ75FMlf2_UDdri1voWKvkaSHtRg',
|
|
||||||
appId: '1:786692570726:ios:455a6fcff77e130f17b7a7',
|
|
||||||
messagingSenderId: '786692570726',
|
|
||||||
projectId: 'syncrow-staging',
|
|
||||||
databaseURL: 'https://syncrow-staging-default-rtdb.firebaseio.com',
|
|
||||||
storageBucket: 'syncrow-staging.appspot.com',
|
|
||||||
iosBundleId: 'com.example.syncrow.app',
|
|
||||||
);
|
|
||||||
|
|
||||||
static const FirebaseOptions web = FirebaseOptions(
|
|
||||||
apiKey: 'AIzaSyDyGaQ3sZhb4meaY6sGke-YglhdhJ2is8Q',
|
|
||||||
appId: '1:786692570726:web:93c931e6701797b317b7a7',
|
|
||||||
messagingSenderId: '786692570726',
|
|
||||||
projectId: 'syncrow-staging',
|
|
||||||
authDomain: 'syncrow-staging.firebaseapp.com',
|
|
||||||
databaseURL: 'https://syncrow-staging-default-rtdb.firebaseio.com',
|
|
||||||
storageBucket: 'syncrow-staging.appspot.com',
|
|
||||||
measurementId: 'G-CZ3J3G6LMQ',
|
|
||||||
);
|
|
||||||
}
|
|
@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:syncrow_web/firebase_options_prod.dart';
|
import 'package:syncrow_web/firebase_options.dart';
|
||||||
import 'package:syncrow_web/pages/auth/bloc/auth_bloc.dart';
|
import 'package:syncrow_web/pages/auth/bloc/auth_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/home/bloc/home_bloc.dart';
|
import 'package:syncrow_web/pages/home/bloc/home_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/home/bloc/home_event.dart';
|
import 'package:syncrow_web/pages/home/bloc/home_event.dart';
|
||||||
@ -27,7 +27,9 @@ Future<void> main() async {
|
|||||||
await dotenv.load(fileName: '.env.$environment');
|
await dotenv.load(fileName: '.env.$environment');
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
await Firebase.initializeApp(
|
await Firebase.initializeApp(
|
||||||
options: DefaultFirebaseOptionsStaging.currentPlatform,
|
options: DefaultFirebaseOptions(
|
||||||
|
databaseUrl: dotenv.env['RTDB_URL']!,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
initialSetup();
|
initialSetup();
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
@ -59,7 +61,7 @@ class MyApp extends StatelessWidget {
|
|||||||
BlocProvider<CreateRoutineBloc>(
|
BlocProvider<CreateRoutineBloc>(
|
||||||
create: (context) => CreateRoutineBloc(),
|
create: (context) => CreateRoutineBloc(),
|
||||||
),
|
),
|
||||||
BlocProvider(create: (context) => HomeBloc()..add(FetchUserInfo())),
|
BlocProvider(create: (context) => HomeBloc()..add(const FetchUserInfo())),
|
||||||
BlocProvider<VisitorPasswordBloc>(
|
BlocProvider<VisitorPasswordBloc>(
|
||||||
create: (context) => VisitorPasswordBloc(),
|
create: (context) => VisitorPasswordBloc(),
|
||||||
),
|
),
|
||||||
|
@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:syncrow_web/firebase_options_dev.dart';
|
import 'package:syncrow_web/firebase_options.dart';
|
||||||
import 'package:syncrow_web/pages/auth/bloc/auth_bloc.dart';
|
import 'package:syncrow_web/pages/auth/bloc/auth_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/home/bloc/home_bloc.dart';
|
import 'package:syncrow_web/pages/home/bloc/home_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/home/bloc/home_event.dart';
|
import 'package:syncrow_web/pages/home/bloc/home_event.dart';
|
||||||
@ -27,7 +27,9 @@ Future<void> main() async {
|
|||||||
await dotenv.load(fileName: '.env.$environment');
|
await dotenv.load(fileName: '.env.$environment');
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
await Firebase.initializeApp(
|
await Firebase.initializeApp(
|
||||||
options: DefaultFirebaseOptionsDev.currentPlatform,
|
options: DefaultFirebaseOptions(
|
||||||
|
databaseUrl: dotenv.env['RTDB_URL']!,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
initialSetup();
|
initialSetup();
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
@ -59,7 +61,7 @@ class MyApp extends StatelessWidget {
|
|||||||
BlocProvider<CreateRoutineBloc>(
|
BlocProvider<CreateRoutineBloc>(
|
||||||
create: (context) => CreateRoutineBloc(),
|
create: (context) => CreateRoutineBloc(),
|
||||||
),
|
),
|
||||||
BlocProvider(create: (context) => HomeBloc()..add(FetchUserInfo())),
|
BlocProvider(create: (context) => HomeBloc()..add(const FetchUserInfo())),
|
||||||
BlocProvider<VisitorPasswordBloc>(
|
BlocProvider<VisitorPasswordBloc>(
|
||||||
create: (context) => VisitorPasswordBloc(),
|
create: (context) => VisitorPasswordBloc(),
|
||||||
),
|
),
|
||||||
|
@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:syncrow_web/firebase_options_prod.dart';
|
import 'package:syncrow_web/firebase_options.dart';
|
||||||
import 'package:syncrow_web/pages/auth/bloc/auth_bloc.dart';
|
import 'package:syncrow_web/pages/auth/bloc/auth_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/home/bloc/home_bloc.dart';
|
import 'package:syncrow_web/pages/home/bloc/home_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/home/bloc/home_event.dart';
|
import 'package:syncrow_web/pages/home/bloc/home_event.dart';
|
||||||
@ -24,7 +24,9 @@ Future<void> main() async {
|
|||||||
await dotenv.load(fileName: '.env.$environment');
|
await dotenv.load(fileName: '.env.$environment');
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
await Firebase.initializeApp(
|
await Firebase.initializeApp(
|
||||||
options: DefaultFirebaseOptionsStaging.currentPlatform,
|
options: DefaultFirebaseOptions(
|
||||||
|
databaseUrl: dotenv.env['RTDB_URL']!,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
initialSetup();
|
initialSetup();
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
@ -56,7 +58,7 @@ class MyApp extends StatelessWidget {
|
|||||||
BlocProvider<CreateRoutineBloc>(
|
BlocProvider<CreateRoutineBloc>(
|
||||||
create: (context) => CreateRoutineBloc(),
|
create: (context) => CreateRoutineBloc(),
|
||||||
),
|
),
|
||||||
BlocProvider(create: (context) => HomeBloc()..add(FetchUserInfo())),
|
BlocProvider(create: (context) => HomeBloc()..add(const FetchUserInfo())),
|
||||||
BlocProvider<VisitorPasswordBloc>(
|
BlocProvider<VisitorPasswordBloc>(
|
||||||
create: (context) => VisitorPasswordBloc(),
|
create: (context) => VisitorPasswordBloc(),
|
||||||
),
|
),
|
||||||
|
@ -22,7 +22,9 @@ import 'package:syncrow_web/pages/analytics/services/analytics_devices/remote_en
|
|||||||
import 'package:syncrow_web/pages/analytics/services/analytics_devices/remote_occupancy_analytics_devices_service.dart';
|
import 'package:syncrow_web/pages/analytics/services/analytics_devices/remote_occupancy_analytics_devices_service.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/services/device_location/device_location_details_service_decorator.dart';
|
import 'package:syncrow_web/pages/analytics/services/device_location/device_location_details_service_decorator.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/services/device_location/remote_device_location_service.dart';
|
import 'package:syncrow_web/pages/analytics/services/device_location/remote_device_location_service.dart';
|
||||||
|
import 'package:syncrow_web/pages/analytics/services/energy_consumption_by_phases/energy_consumption_by_phases_value_divider_decorator.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/services/energy_consumption_by_phases/remote_energy_consumption_by_phases_service.dart';
|
import 'package:syncrow_web/pages/analytics/services/energy_consumption_by_phases/remote_energy_consumption_by_phases_service.dart';
|
||||||
|
import 'package:syncrow_web/pages/analytics/services/energy_consumption_per_device/energy_consumption_per_device_value_divider_decorator.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/services/energy_consumption_per_device/remote_energy_consumption_per_device_service.dart';
|
import 'package:syncrow_web/pages/analytics/services/energy_consumption_per_device/remote_energy_consumption_per_device_service.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/services/occupacy/remote_occupancy_service.dart';
|
import 'package:syncrow_web/pages/analytics/services/occupacy/remote_occupancy_service.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/services/occupancy_heat_map/remote_occupancy_heat_map_service.dart';
|
import 'package:syncrow_web/pages/analytics/services/occupancy_heat_map/remote_occupancy_heat_map_service.dart';
|
||||||
@ -62,17 +64,23 @@ class _AnalyticsPageState extends State<AnalyticsPage> {
|
|||||||
),
|
),
|
||||||
BlocProvider(
|
BlocProvider(
|
||||||
create: (context) => TotalEnergyConsumptionBloc(
|
create: (context) => TotalEnergyConsumptionBloc(
|
||||||
RemoteTotalEnergyConsumptionService(_httpService),
|
DividedTotalEnergyConsumptionDecorator(
|
||||||
|
RemoteTotalEnergyConsumptionService(_httpService),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
BlocProvider(
|
BlocProvider(
|
||||||
create: (context) => EnergyConsumptionByPhasesBloc(
|
create: (context) => EnergyConsumptionByPhasesBloc(
|
||||||
RemoteEnergyConsumptionByPhasesService(_httpService),
|
EnergyConsumptionByPhasesValueDividerDecorator(
|
||||||
|
RemoteEnergyConsumptionByPhasesService(_httpService),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
BlocProvider(
|
BlocProvider(
|
||||||
create: (context) => EnergyConsumptionPerDeviceBloc(
|
create: (context) => EnergyConsumptionPerDeviceBloc(
|
||||||
RemoteEnergyConsumptionPerDeviceService(_httpService),
|
EnergyConsumptionPerDeviceValueDividerDecorator(
|
||||||
|
RemoteEnergyConsumptionPerDeviceService(_httpService),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
BlocProvider(
|
BlocProvider(
|
||||||
@ -145,6 +153,7 @@ class _AnalyticsPageFormState extends State<AnalyticsPageForm> {
|
|||||||
context.read<SpaceTreeBloc>().add(InitialEvent());
|
context.read<SpaceTreeBloc>().add(InitialEvent());
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return WebScaffold(
|
return WebScaffold(
|
||||||
|
@ -13,15 +13,15 @@ class EnergyConsumptionByPhasesChart extends StatelessWidget {
|
|||||||
});
|
});
|
||||||
|
|
||||||
final List<PhasesEnergyConsumption> energyData;
|
final List<PhasesEnergyConsumption> energyData;
|
||||||
|
static const _kLeftTitlesInterval = 4.0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BarChart(
|
return BarChart(
|
||||||
BarChartData(
|
BarChartData(
|
||||||
|
|
||||||
gridData: EnergyManagementChartsHelper.gridData().copyWith(
|
gridData: EnergyManagementChartsHelper.gridData().copyWith(
|
||||||
checkToShowHorizontalLine: (value) => true,
|
checkToShowHorizontalLine: (value) => true,
|
||||||
horizontalInterval: 250,
|
horizontalInterval: _kLeftTitlesInterval,
|
||||||
),
|
),
|
||||||
borderData: EnergyManagementChartsHelper.borderData(),
|
borderData: EnergyManagementChartsHelper.borderData(),
|
||||||
barTouchData: _barTouchData(context),
|
barTouchData: _barTouchData(context),
|
||||||
@ -100,11 +100,11 @@ class EnergyConsumptionByPhasesChart extends StatelessWidget {
|
|||||||
}) {
|
}) {
|
||||||
final data = energyData;
|
final data = energyData;
|
||||||
|
|
||||||
final date = DateFormat('dd/MM/yyyy').format(data[group.x.toInt()].date);
|
final date = DateFormat('dd/MM/yyyy').format(data[group.x].date);
|
||||||
final phaseA = data[group.x.toInt()].energyConsumedA;
|
final phaseA = data[group.x].energyConsumedA;
|
||||||
final phaseB = data[group.x.toInt()].energyConsumedB;
|
final phaseB = data[group.x].energyConsumedB;
|
||||||
final phaseC = data[group.x.toInt()].energyConsumedC;
|
final phaseC = data[group.x].energyConsumedC;
|
||||||
final total = data[group.x.toInt()].energyConsumedKw;
|
final total = data[group.x].energyConsumedKw;
|
||||||
|
|
||||||
return BarTooltipItem(
|
return BarTooltipItem(
|
||||||
'$date\n',
|
'$date\n',
|
||||||
@ -149,7 +149,7 @@ class EnergyConsumptionByPhasesChart extends StatelessWidget {
|
|||||||
FlTitlesData _titlesData(BuildContext context) {
|
FlTitlesData _titlesData(BuildContext context) {
|
||||||
final titlesData = EnergyManagementChartsHelper.titlesData(
|
final titlesData = EnergyManagementChartsHelper.titlesData(
|
||||||
context,
|
context,
|
||||||
leftTitlesInterval: 250,
|
leftTitlesInterval: _kLeftTitlesInterval,
|
||||||
);
|
);
|
||||||
|
|
||||||
final leftTitles = titlesData.leftTitles.copyWith(
|
final leftTitles = titlesData.leftTitles.copyWith(
|
||||||
|
@ -7,6 +7,7 @@ class EnergyConsumptionPerDeviceChart extends StatelessWidget {
|
|||||||
const EnergyConsumptionPerDeviceChart({super.key, required this.chartData});
|
const EnergyConsumptionPerDeviceChart({super.key, required this.chartData});
|
||||||
|
|
||||||
final List<DeviceEnergyDataModel> chartData;
|
final List<DeviceEnergyDataModel> chartData;
|
||||||
|
static const _kLeftTitlesInterval = 2.5;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -15,12 +16,11 @@ class EnergyConsumptionPerDeviceChart extends StatelessWidget {
|
|||||||
clipData: const FlClipData.vertical(),
|
clipData: const FlClipData.vertical(),
|
||||||
titlesData: EnergyManagementChartsHelper.titlesData(
|
titlesData: EnergyManagementChartsHelper.titlesData(
|
||||||
context,
|
context,
|
||||||
leftTitlesInterval: 250,
|
leftTitlesInterval: _kLeftTitlesInterval,
|
||||||
),
|
),
|
||||||
|
|
||||||
gridData: EnergyManagementChartsHelper.gridData().copyWith(
|
gridData: EnergyManagementChartsHelper.gridData().copyWith(
|
||||||
checkToShowHorizontalLine: (value) => true,
|
checkToShowHorizontalLine: (value) => true,
|
||||||
horizontalInterval: 250,
|
horizontalInterval: _kLeftTitlesInterval,
|
||||||
),
|
),
|
||||||
borderData: EnergyManagementChartsHelper.borderData(),
|
borderData: EnergyManagementChartsHelper.borderData(),
|
||||||
lineTouchData: EnergyManagementChartsHelper.lineTouchData(),
|
lineTouchData: EnergyManagementChartsHelper.lineTouchData(),
|
||||||
|
@ -9,22 +9,24 @@ class TotalEnergyConsumptionChart extends StatelessWidget {
|
|||||||
|
|
||||||
final List<EnergyDataModel> chartData;
|
final List<EnergyDataModel> chartData;
|
||||||
|
|
||||||
|
static const _leftTitlesInterval = 5.0;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: LineChart(
|
child: LineChart(
|
||||||
LineChartData(
|
LineChartData(
|
||||||
maxY: chartData.isEmpty
|
maxY: chartData.isNotEmpty
|
||||||
? null
|
? chartData.map((e) => e.value).reduce((a, b) => a > b ? a : b) +
|
||||||
: chartData.map((e) => e.value).reduce((a, b) => a > b ? a : b) + 250,
|
_leftTitlesInterval
|
||||||
|
: null,
|
||||||
clipData: const FlClipData.vertical(),
|
clipData: const FlClipData.vertical(),
|
||||||
titlesData: EnergyManagementChartsHelper.titlesData(
|
titlesData: EnergyManagementChartsHelper.titlesData(
|
||||||
context,
|
context,
|
||||||
leftTitlesInterval: 500,
|
leftTitlesInterval: _leftTitlesInterval,
|
||||||
),
|
),
|
||||||
gridData: EnergyManagementChartsHelper.gridData().copyWith(
|
gridData: EnergyManagementChartsHelper.gridData().copyWith(
|
||||||
checkToShowHorizontalLine: (value) => true,
|
checkToShowHorizontalLine: (value) => true,
|
||||||
horizontalInterval: 500,
|
horizontalInterval: _leftTitlesInterval,
|
||||||
),
|
),
|
||||||
borderData: EnergyManagementChartsHelper.borderData(),
|
borderData: EnergyManagementChartsHelper.borderData(),
|
||||||
lineTouchData: EnergyManagementChartsHelper.lineTouchData(),
|
lineTouchData: EnergyManagementChartsHelper.lineTouchData(),
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
import 'package:syncrow_web/pages/analytics/models/phases_energy_consumption.dart';
|
||||||
|
import 'package:syncrow_web/pages/analytics/params/get_energy_consumption_by_phases_param.dart';
|
||||||
|
import 'package:syncrow_web/pages/analytics/services/energy_consumption_by_phases/energy_consumption_by_phases_service.dart';
|
||||||
|
import 'package:syncrow_web/utils/helpers/safe_division_helper.dart';
|
||||||
|
|
||||||
|
class EnergyConsumptionByPhasesValueDividerDecorator
|
||||||
|
implements EnergyConsumptionByPhasesService {
|
||||||
|
const EnergyConsumptionByPhasesValueDividerDecorator(
|
||||||
|
this._decoratee, {
|
||||||
|
this.divider = 100,
|
||||||
|
});
|
||||||
|
|
||||||
|
final EnergyConsumptionByPhasesService _decoratee;
|
||||||
|
final double divider;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<PhasesEnergyConsumption>> load(
|
||||||
|
GetEnergyConsumptionByPhasesParam param) async {
|
||||||
|
final result = await _decoratee.load(param);
|
||||||
|
return result.map((e) {
|
||||||
|
return PhasesEnergyConsumption(
|
||||||
|
date: e.date,
|
||||||
|
energyConsumedA: SafeDivisionHelper.divide(e.energyConsumedA, divider),
|
||||||
|
energyConsumedB: SafeDivisionHelper.divide(e.energyConsumedB, divider),
|
||||||
|
energyConsumedC: SafeDivisionHelper.divide(e.energyConsumedC, divider),
|
||||||
|
energyConsumedKw: SafeDivisionHelper.divide(e.energyConsumedKw, divider),
|
||||||
|
uuid: e.uuid,
|
||||||
|
createdAt: e.createdAt,
|
||||||
|
updatedAt: e.updatedAt,
|
||||||
|
deviceUuid: e.deviceUuid,
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
import 'package:syncrow_web/pages/analytics/models/device_energy_data_model.dart';
|
||||||
|
import 'package:syncrow_web/pages/analytics/models/energy_data_model.dart';
|
||||||
|
import 'package:syncrow_web/pages/analytics/params/get_energy_consumption_per_device_param.dart';
|
||||||
|
import 'package:syncrow_web/pages/analytics/services/energy_consumption_per_device/energy_consumption_per_device_service.dart';
|
||||||
|
import 'package:syncrow_web/utils/helpers/safe_division_helper.dart';
|
||||||
|
|
||||||
|
class EnergyConsumptionPerDeviceValueDividerDecorator
|
||||||
|
implements EnergyConsumptionPerDeviceService {
|
||||||
|
const EnergyConsumptionPerDeviceValueDividerDecorator(
|
||||||
|
this._decoratee, {
|
||||||
|
this.divider = 100,
|
||||||
|
});
|
||||||
|
|
||||||
|
final EnergyConsumptionPerDeviceService _decoratee;
|
||||||
|
final double divider;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<DeviceEnergyDataModel>> load(
|
||||||
|
GetEnergyConsumptionPerDeviceParam param,
|
||||||
|
) async {
|
||||||
|
final result = await _decoratee.load(param);
|
||||||
|
return result.map((device) {
|
||||||
|
return DeviceEnergyDataModel(
|
||||||
|
deviceId: device.deviceId,
|
||||||
|
deviceName: device.deviceName,
|
||||||
|
color: device.color,
|
||||||
|
energy: device.energy.map((e) {
|
||||||
|
return EnergyDataModel(
|
||||||
|
date: e.date,
|
||||||
|
value: SafeDivisionHelper.divide(e.value, divider),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
import 'package:syncrow_web/pages/analytics/models/energy_data_model.dart';
|
||||||
|
import 'package:syncrow_web/pages/analytics/params/get_total_energy_consumption_param.dart';
|
||||||
|
import 'package:syncrow_web/pages/analytics/services/total_energy_consumption/total_energy_consumption_service.dart';
|
||||||
|
import 'package:syncrow_web/utils/helpers/safe_division_helper.dart';
|
||||||
|
|
||||||
|
class DividedTotalEnergyConsumptionDecorator
|
||||||
|
implements TotalEnergyConsumptionService {
|
||||||
|
const DividedTotalEnergyConsumptionDecorator(
|
||||||
|
this._decoratee, {
|
||||||
|
this.divider = 100,
|
||||||
|
});
|
||||||
|
|
||||||
|
final TotalEnergyConsumptionService _decoratee;
|
||||||
|
final double divider;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<EnergyDataModel>> load(GetTotalEnergyConsumptionParam param) async {
|
||||||
|
final result = await _decoratee.load(param);
|
||||||
|
return result.map((e) {
|
||||||
|
return EnergyDataModel(
|
||||||
|
date: e.date,
|
||||||
|
value: SafeDivisionHelper.divide(e.value, divider),
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
}
|
@ -59,3 +59,23 @@ abstract final class _TotalEnergyConsumptionResponseMapper {
|
|||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class DividedTotalEnergyConsumptionDecorator
|
||||||
|
implements TotalEnergyConsumptionService {
|
||||||
|
const DividedTotalEnergyConsumptionDecorator(this._decoratee);
|
||||||
|
|
||||||
|
final TotalEnergyConsumptionService _decoratee;
|
||||||
|
@override
|
||||||
|
Future<List<EnergyDataModel>> load(
|
||||||
|
GetTotalEnergyConsumptionParam param,
|
||||||
|
) async {
|
||||||
|
final result = await _decoratee.load(param);
|
||||||
|
final dividedResult = result.map((e) {
|
||||||
|
return EnergyDataModel(
|
||||||
|
date: e.date,
|
||||||
|
value: e.value / 100,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
return dividedResult.toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -105,7 +105,7 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
|||||||
color: const Color(0xFF0026A2),
|
color: const Color(0xFF0026A2),
|
||||||
),
|
),
|
||||||
HomeItemModel(
|
HomeItemModel(
|
||||||
title: 'Devices Management',
|
title: 'Device Management',
|
||||||
icon: Assets.devicesIcon,
|
icon: Assets.devicesIcon,
|
||||||
active: true,
|
active: true,
|
||||||
onPress: (context) {
|
onPress: (context) {
|
||||||
|
8
lib/utils/helpers/safe_division_helper.dart
Normal file
8
lib/utils/helpers/safe_division_helper.dart
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
abstract final class SafeDivisionHelper {
|
||||||
|
const SafeDivisionHelper._();
|
||||||
|
|
||||||
|
static double divide(num value, num divider) {
|
||||||
|
if (divider == 0) return 0;
|
||||||
|
return value / divider;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user