diff --git a/README.md b/README.md index 2c06bfc34..af3cef1dc 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@
-[![Playstore: install](https://img.shields.io/badge/Playstore-install-brightgreen?logo=googleplay)](https://play.google.com/store/apps/details?id=com.cybear_jinni.smart_home) [![Snapcraft](https://img.shields.io/badge/snap-install-82BEA0?style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAfVQTFRFAAAAg7+igr+igr+h/1Es+mNA+mND+mM/gr+gg7+hc7KPgcCi/wAA+GRBfruif7Sbgr6h+mVC+mJAgsChfMWpgb6hgrexg7+igr+hgr+hhL+jgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+heMao/0sn/Fw5gr+hgr+hgr+hgr+hgr+hgcCizYZl+2I//GE++mNA+mNA+mNA+mNA+mNAgcCfgr+hgr+hgr+hg76gl6+Q04Fg+GVC/GI/+mNA+mNAgr+hgr+hgr+hgr+hgMGjibqbvJJy8WpH+mNA+mNAgr+hgMCjhL6g1IFf+2I/+mNA+mNA+mNA+mNAgr+hgr+hgr+hdsmr+mNA+mNA+mNA+mNAgr+hgr+h+mNA+mNA+mNAgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+h+mNAgcCi////z300sQAAAKN0Uk5TAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABCAEBOnI3CQbiuHMrBQRv9OasZyRu8v3gpFscAmrv+9eZTxUBAQEDYOn30GAlZ5GZl5aYVQFW5aWippK99NUgUOSmyeOukqnneE70p0V+1P7ZJUznWgMcZL13R9sPLwZA001IhM7KEsCCqa1oi3AnHc+8GH3SPCg2jTM56DGhzEnHLgy2wSqzJRZ7GyXhzTUAAAABYktHRKa3sBuVAAAACXBIWXMAAOw4AADsOAFxK8o4AAABWklEQVQ4y2NgoBgwiktIMuFVICUtIyvHjEcFs7yMgqKSsgpuNcyqauqLNTS1tFWZcarQ0V28WE/fwNDImBmHChPTxUBgZm5haWVtY8vCiqHCzt5hMRg4Ojm7uLq5e3h6enp5s7HDVXD4+PpBVCz2DwgMCg5ZAgShYUgmcXKFR0AUREYtjY6JjYsHqkhgRVLBzJ0YAVUAJJKSU1LT0jMykR3DzJylAFeQnZPLk5dfUMiLooKvqBiqIMKSX4BBUKiktAzFP8IC5RVgBRGVzFjDQ4S5qrpmcWRtNg55Bua6+ogGp8amcBzyHMzNZosVWlrbcIQ3A3N7B9CNnV04o0y0Gyjf0yuMU0Ef0JMd/cy4khez5ITFi2smMuNMN8yTJi+umYJHXn7q4ml45BmYp+vOmMksjFt+1uw5c/HJM9vPm88sxoBbwYKF2viyBgPz/EV45RmYjZnxK6AEAACJjG4Guv8uAwAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMC0wMS0xMFQxNjozNDozOSswMDowMOoslwkAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjAtMDEtMTBUMTY6MzQ6MzkrMDA6MDCbcS+1AAAARnRFWHRzb2Z0d2FyZQBJbWFnZU1hZ2ljayA2LjcuOC05IDIwMTktMDItMDEgUTE2IGh0dHA6Ly93d3cuaW1hZ2VtYWdpY2sub3JnQXviyAAAABh0RVh0VGh1bWI6OkRvY3VtZW50OjpQYWdlcwAxp/+7LwAAABh0RVh0VGh1bWI6OkltYWdlOjpoZWlnaHQANTEywNBQUQAAABd0RVh0VGh1bWI6OkltYWdlOjpXaWR0aAA1MTIcfAPcAAAAGXRFWHRUaHVtYjo6TWltZXR5cGUAaW1hZ2UvcG5nP7JWTgAAABd0RVh0VGh1bWI6Ok1UaW1lADE1Nzg2NzQwNznfLoLhAAAAE3RFWHRUaHVtYjo6U2l6ZQAxNS44S0JCBxRz5QAAAE90RVh0VGh1bWI6OlVSSQBmaWxlOi8vLi91cGxvYWRzLzU2LzhidnMzYVYvMjEwNy9maWxlX3R5cGVfc25hcGNyYWZ0X2ljb25fMTMwMTYwLnBuZ0uIQNAAAAAASUVORK5CYII=)](https://snapcraft.io/cybear-jinni) [![dart CI](https://github.com/CyBear-Jinni/cbj_app/workflows/Dart%20CI/badge.svg)](https://github.com/CyBear-Jinni/cbj_app/actions?query=workflow%3A%22Dart+CI%22) [![style: lint](https://img.shields.io/badge/lint-1.3.0-blue)](https://pub.dev/packages/lint) [![License: AGPL v3](https://img.shields.io/badge/License-AGPL%20v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0) [](https://en.wikipedia.org/wiki/Open_source) +[![Playstore: install](https://img.shields.io/badge/Playstore-install-brightgreen?logo=googleplay)](https://play.google.com/store/apps/details?id=com.cybearjinni.app) [![Snapcraft](https://img.shields.io/badge/snap-install-82BEA0?style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAfVQTFRFAAAAg7+igr+igr+h/1Es+mNA+mND+mM/gr+gg7+hc7KPgcCi/wAA+GRBfruif7Sbgr6h+mVC+mJAgsChfMWpgb6hgrexg7+igr+hgr+hhL+jgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+heMao/0sn/Fw5gr+hgr+hgr+hgr+hgr+hgcCizYZl+2I//GE++mNA+mNA+mNA+mNA+mNAgcCfgr+hgr+hgr+hg76gl6+Q04Fg+GVC/GI/+mNA+mNAgr+hgr+hgr+hgr+hgMGjibqbvJJy8WpH+mNA+mNAgr+hgMCjhL6g1IFf+2I/+mNA+mNA+mNA+mNAgr+hgr+hgr+hdsmr+mNA+mNA+mNA+mNAgr+hgr+h+mNA+mNA+mNAgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+hgr+h+mNAgcCi////z300sQAAAKN0Uk5TAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABCAEBOnI3CQbiuHMrBQRv9OasZyRu8v3gpFscAmrv+9eZTxUBAQEDYOn30GAlZ5GZl5aYVQFW5aWippK99NUgUOSmyeOukqnneE70p0V+1P7ZJUznWgMcZL13R9sPLwZA001IhM7KEsCCqa1oi3AnHc+8GH3SPCg2jTM56DGhzEnHLgy2wSqzJRZ7GyXhzTUAAAABYktHRKa3sBuVAAAACXBIWXMAAOw4AADsOAFxK8o4AAABWklEQVQ4y2NgoBgwiktIMuFVICUtIyvHjEcFs7yMgqKSsgpuNcyqauqLNTS1tFWZcarQ0V28WE/fwNDImBmHChPTxUBgZm5haWVtY8vCiqHCzt5hMRg4Ojm7uLq5e3h6enp5s7HDVXD4+PpBVCz2DwgMCg5ZAgShYUgmcXKFR0AUREYtjY6JjYsHqkhgRVLBzJ0YAVUAJJKSU1LT0jMykR3DzJylAFeQnZPLk5dfUMiLooKvqBiqIMKSX4BBUKiktAzFP8IC5RVgBRGVzFjDQ4S5qrpmcWRtNg55Bua6+ogGp8amcBzyHMzNZosVWlrbcIQ3A3N7B9CNnV04o0y0Gyjf0yuMU0Ef0JMd/cy4khez5ITFi2smMuNMN8yTJi+umYJHXn7q4ml45BmYp+vOmMksjFt+1uw5c/HJM9vPm88sxoBbwYKF2viyBgPz/EV45RmYjZnxK6AEAACJjG4Guv8uAwAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMC0wMS0xMFQxNjozNDozOSswMDowMOoslwkAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjAtMDEtMTBUMTY6MzQ6MzkrMDA6MDCbcS+1AAAARnRFWHRzb2Z0d2FyZQBJbWFnZU1hZ2ljayA2LjcuOC05IDIwMTktMDItMDEgUTE2IGh0dHA6Ly93d3cuaW1hZ2VtYWdpY2sub3JnQXviyAAAABh0RVh0VGh1bWI6OkRvY3VtZW50OjpQYWdlcwAxp/+7LwAAABh0RVh0VGh1bWI6OkltYWdlOjpoZWlnaHQANTEywNBQUQAAABd0RVh0VGh1bWI6OkltYWdlOjpXaWR0aAA1MTIcfAPcAAAAGXRFWHRUaHVtYjo6TWltZXR5cGUAaW1hZ2UvcG5nP7JWTgAAABd0RVh0VGh1bWI6Ok1UaW1lADE1Nzg2NzQwNznfLoLhAAAAE3RFWHRUaHVtYjo6U2l6ZQAxNS44S0JCBxRz5QAAAE90RVh0VGh1bWI6OlVSSQBmaWxlOi8vLi91cGxvYWRzLzU2LzhidnMzYVYvMjEwNy9maWxlX3R5cGVfc25hcGNyYWZ0X2ljb25fMTMwMTYwLnBuZ0uIQNAAAAAASUVORK5CYII=)](https://snapcraft.io/cybear-jinni) [![dart CI](https://github.com/CyBear-Jinni/cbj_app/workflows/Dart%20CI/badge.svg)](https://github.com/CyBear-Jinni/cbj_app/actions?query=workflow%3A%22Dart+CI%22) [![style: lint](https://img.shields.io/badge/lint-1.3.0-blue)](https://pub.dev/packages/lint) [![License: AGPL v3](https://img.shields.io/badge/License-AGPL%20v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0) [](https://en.wikipedia.org/wiki/Open_source)
[
CyBear Jinni image](https://github.com/CyBear-Jinni/CBJ_Smart-Home) @@ -20,7 +20,7 @@ It is writen with [Flutter](https://flutter.dev) and let you control the CyBear

- + Android Badge Snap Store Badge diff --git a/android/.gitignore b/android/.gitignore index 7c334f363..e93791d9d 100644 --- a/android/.gitignore +++ b/android/.gitignore @@ -8,4 +8,6 @@ app/google-services.json GeneratedPluginRegistrant.java gradle-wrapper.jar -key.properties \ No newline at end of file +key.properties +**/*.keystore +**/*.jks \ No newline at end of file diff --git a/android/app/build.gradle b/android/app/build.gradle index 7159f3688..c51278211 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -21,30 +21,37 @@ if (flutterVersionName == null) { flutterVersionName = '1.0' } +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + def keystoreProperties = new Properties() def keystorePropertiesFile = rootProject.file('key.properties') if (keystorePropertiesFile.exists()) { keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) } -apply plugin: 'com.android.application' -apply plugin: 'com.google.gms.google-services' // For firestore -apply plugin: 'kotlin-android' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 34 + namespace "com.cybearjinni.app" + compileSdkVersion flutter.compileSdkVersion + ndkVersion flutter.ndkVersion - sourceSets { - main.java.srcDirs += 'src/main/kotlin' + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' } - lintOptions { - disable 'InvalidPackage' + sourceSets { + main.java.srcDirs += 'src/main/kotlin' } defaultConfig { - applicationId "com.cybear_jinni.smart_home" + applicationId "com.cybearjinni.app" minSdkVersion 22 targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() @@ -62,6 +69,8 @@ android { } buildTypes { + debug { + } release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. @@ -71,9 +80,9 @@ android { // Includes the default ProGuard rules files that are packaged with // the Android Gradle plugin. To learn more, go to the section about // R8 configuration files. - proguardFiles getDefaultProguardFile( - 'proguard-android-optimize.txt'), - 'proguard-rules.pro' + // proguardFiles getDefaultProguardFile( + // 'proguard-android-optimize.txt'), + // 'proguard-rules.pro' } } } @@ -82,9 +91,4 @@ flutter { source '../..' } -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - -// implementation 'com.android.support:multidex:2.0.1' -// implementation 'com.google.firebase:firebase-analytics:18.0.3' // For firestore -} +dependencies {} diff --git a/android/app/google-services.json b/android/app/google-services.json deleted file mode 100644 index 770c54f99..000000000 --- a/android/app/google-services.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "project_info": { - "project_number": "907181373877", - "firebase_url": "https://smarthometest-3295f.firebaseio.com", - "project_id": "smarthometest-3295f", - "storage_bucket": "smarthometest-3295f.appspot.com" - }, - "client": [ - { - "client_info": { - "mobilesdk_app_id": "1:907181373877:android:ebff60e28c4a08955d81fc", - "android_client_info": { - "package_name": "com.cybear_jinni.smart_home" - } - }, - "oauth_client": [ - { - "client_id": "907181373877-9lbj11i9iv8o1jr1ldejbeogu1o7bjh7.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyBytaZgR_Tjg1UZP63oO1e8y35f4MFPmlA" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "907181373877-9lbj11i9iv8o1jr1ldejbeogu1o7bjh7.apps.googleusercontent.com", - "client_type": 3 - } - ] - } - } - } - ], - "configuration_version": "1" -} \ No newline at end of file diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml index f7aaa4af7..0152a8609 100644 --- a/android/app/src/debug/AndroidManifest.xml +++ b/android/app/src/debug/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.cybearjinni.app"> @@ -21,4 +21,5 @@ + diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index b3f7dad22..198ade3f1 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,11 +1,7 @@ - - + xmlns:tools="http://schemas.android.com/tools" + package="com.cybearjinni.app"> + @@ -24,20 +20,19 @@ + + android:icon="@mipmap/ic_launcher"> - @@ -65,8 +52,5 @@ android:name="flutterEmbedding" android:value="2" /> - \ No newline at end of file diff --git a/android/app/src/main/kotlin/com/cybear_jinni/smart_home/MainActivity.kt b/android/app/src/main/kotlin/com/cybear_jinni/smart_home/MainActivity.kt deleted file mode 100644 index c2d2962b1..000000000 --- a/android/app/src/main/kotlin/com/cybear_jinni/smart_home/MainActivity.kt +++ /dev/null @@ -1,43 +0,0 @@ -package com.cybear_jinni.smart_home - -import android.content.ContentResolver -import android.content.Context -import android.media.RingtoneManager -import io.flutter.embedding.android.FlutterActivity -import io.flutter.embedding.engine.FlutterEngine -import io.flutter.plugin.common.MethodCall -import io.flutter.plugin.common.MethodChannel -import java.util.* - - -import java.util.TimeZone - - -class MainActivity : FlutterActivity() { - - private fun resourceToUriString(context: Context, resId: Int): String? { - return (ContentResolver.SCHEME_ANDROID_RESOURCE - + "://" - + context.resources.getResourcePackageName(resId) - + "/" - + context.resources.getResourceTypeName(resId) - + "/" - + context.resources.getResourceEntryName(resId)) - } - - override fun configureFlutterEngine(flutterEngine: FlutterEngine) { - super.configureFlutterEngine(flutterEngine) - MethodChannel(flutterEngine.dartExecutor, "cybear_jinni/smart_home").setMethodCallHandler { call: MethodCall, result: MethodChannel.Result -> - if ("drawableToUri" == call.method) { - val resourceId = this@MainActivity.resources.getIdentifier(call.arguments as String, "drawable", this@MainActivity.packageName) - result.success(resourceToUriString(this@MainActivity.applicationContext, resourceId)) - } - if ("getAlarmUri" == call.method) { - result.success(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM).toString()) - } - if ("getTimeZoneName" == call.method) { - result.success(TimeZone.getDefault().id) - } - } - } -} diff --git a/android/app/src/main/kotlin/com/cybearjinni/cbj_app/MainActivity.kt b/android/app/src/main/kotlin/com/cybearjinni/cbj_app/MainActivity.kt index 3c3bc916e..383cc74a0 100644 --- a/android/app/src/main/kotlin/com/cybearjinni/cbj_app/MainActivity.kt +++ b/android/app/src/main/kotlin/com/cybearjinni/cbj_app/MainActivity.kt @@ -1,4 +1,4 @@ -package com.cybearjinni.cbj_app +package com.cybearjinni.app import io.flutter.embedding.android.FlutterActivity diff --git a/android/app/src/main/res/drawable-hdpi/splash_icon.png b/android/app/src/main/res/drawable-hdpi/splash_icon.png deleted file mode 100644 index e4f974c5c..000000000 Binary files a/android/app/src/main/res/drawable-hdpi/splash_icon.png and /dev/null differ diff --git a/android/app/src/main/res/drawable-mdpi/splash_icon.png b/android/app/src/main/res/drawable-mdpi/splash_icon.png deleted file mode 100644 index 36fa11c8a..000000000 Binary files a/android/app/src/main/res/drawable-mdpi/splash_icon.png and /dev/null differ diff --git a/android/app/src/main/res/drawable-v21/launch_background.xml b/android/app/src/main/res/drawable-v21/launch_background.xml index b89ef85cd..767afb3ae 100644 --- a/android/app/src/main/res/drawable-v21/launch_background.xml +++ b/android/app/src/main/res/drawable-v21/launch_background.xml @@ -1,12 +1,5 @@ - - - - - - + diff --git a/android/app/src/main/res/drawable-xhdpi/splash_icon.png b/android/app/src/main/res/drawable-xhdpi/splash_icon.png deleted file mode 100644 index 36fa11c8a..000000000 Binary files a/android/app/src/main/res/drawable-xhdpi/splash_icon.png and /dev/null differ diff --git a/android/app/src/main/res/drawable-xxhdpi/splash_icon.png b/android/app/src/main/res/drawable-xxhdpi/splash_icon.png deleted file mode 100644 index 36fa11c8a..000000000 Binary files a/android/app/src/main/res/drawable-xxhdpi/splash_icon.png and /dev/null differ diff --git a/android/app/src/main/res/drawable-xxxhdpi/splash_icon.png b/android/app/src/main/res/drawable-xxxhdpi/splash_icon.png deleted file mode 100644 index 36fa11c8a..000000000 Binary files a/android/app/src/main/res/drawable-xxxhdpi/splash_icon.png and /dev/null differ diff --git a/android/app/src/main/res/drawable/launch_background.xml b/android/app/src/main/res/drawable/launch_background.xml deleted file mode 100644 index 07d24f907..000000000 --- a/android/app/src/main/res/drawable/launch_background.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index e32fc8a8b..000000000 Binary files a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index 3aab1065b..000000000 Binary files a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png deleted file mode 100644 index 5214c32eb..000000000 Binary files a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index 07f30deb3..000000000 Binary files a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png deleted file mode 100644 index 87a9d0e46..000000000 Binary files a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ diff --git a/android/app/src/main/res/values-night/styles.xml b/android/app/src/main/res/values-night/styles.xml index 8b1f24814..2b36a04ef 100644 --- a/android/app/src/main/res/values-night/styles.xml +++ b/android/app/src/main/res/values-night/styles.xml @@ -3,16 +3,16 @@ diff --git a/android/app/src/main/res/values/colors.xml b/android/app/src/main/res/values/colors.xml index 4af3a60f2..c5d5899fd 100644 --- a/android/app/src/main/res/values/colors.xml +++ b/android/app/src/main/res/values/colors.xml @@ -1,11 +1,4 @@ - #D2D2D2 - #ff838383 - #1A000000 - #FF673AB7 - #FF3F51B5 - - #ebe9e9 #FFFFFF \ No newline at end of file diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml index 98e5d049c..4baf4d6d8 100644 --- a/android/app/src/main/res/values/styles.xml +++ b/android/app/src/main/res/values/styles.xml @@ -1,18 +1,19 @@ - - - + diff --git a/android/app/src/profile/AndroidManifest.xml b/android/app/src/profile/AndroidManifest.xml index f7aaa4af7..0152a8609 100644 --- a/android/app/src/profile/AndroidManifest.xml +++ b/android/app/src/profile/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.cybearjinni.app"> @@ -21,4 +21,5 @@ + diff --git a/android/build.gradle b/android/build.gradle index f9f24f56e..fd1e7a58a 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,23 +2,20 @@ buildscript { ext.kotlin_version = '1.9.0' repositories { google() - jcenter() + mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:7.3.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - // Todo: as we are no longer using firestore we need to check if this line is needed, - // it may be needed for the ads. - classpath 'com.google.gms:google-services:4.3.15' // For firestore } } allprojects { repositories { google() - jcenter() + mavenCentral() } } diff --git a/android/gradle.properties b/android/gradle.properties index 38c8d4544..ef73a2e94 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,4 +1,4 @@ org.gradle.jvmargs=-Xmx1536M -android.enableR8=true +# android.enableR8=true android.useAndroidX=true android.enableJetifier=true diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 6b665338b..cfe88f690 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip diff --git a/android/settings.gradle b/android/settings.gradle index d3b6a4013..7cd712855 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,15 +1,29 @@ -// Copyright 2014 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + } + settings.ext.flutterSdkPath = flutterSdkPath() -include ':app' + includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") -def localPropertiesFile = new File(rootProject.projectDir, "local.properties") -def properties = new Properties() + repositories { + google() + mavenCentral() + gradlePluginPortal() + } -assert localPropertiesFile.exists() -localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + plugins { + id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false + } +} -def flutterSdkPath = properties.getProperty("flutter.sdk") -assert flutterSdkPath != null, "flutter.sdk not set in local.properties" -apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "7.3.0" apply false +} + +include ":app" diff --git a/assets/cbj_half_app_logo.png b/assets/cbj_half_app_logo.png index 15c40c6ea..791d16a36 100644 Binary files a/assets/cbj_half_app_logo.png and b/assets/cbj_half_app_logo.png differ diff --git a/assets/cbj_logo.png b/assets/cbj_logo.png index 36fa11c8a..d2578b2f8 100644 Binary files a/assets/cbj_logo.png and b/assets/cbj_logo.png differ diff --git a/assets/gif/sleep1.gif b/assets/gif/sleep1.gif deleted file mode 100644 index ed8b5f489..000000000 Binary files a/assets/gif/sleep1.gif and /dev/null differ diff --git a/assets/gif/sleep3.gif b/assets/gif/sleep3.gif deleted file mode 100644 index 494531cd0..000000000 Binary files a/assets/gif/sleep3.gif and /dev/null differ diff --git a/assets/symbols/air_conditioner.jpg b/assets/symbols/air_conditioner.jpg deleted file mode 100644 index 70fc97b6c..000000000 Binary files a/assets/symbols/air_conditioner.jpg and /dev/null differ diff --git a/assets/symbols/blinds.jpg b/assets/symbols/blinds.jpg deleted file mode 100644 index cf746c976..000000000 Binary files a/assets/symbols/blinds.jpg and /dev/null differ diff --git a/assets/symbols/doctor.jpg b/assets/symbols/doctor.jpg deleted file mode 100644 index 81255770e..000000000 Binary files a/assets/symbols/doctor.jpg and /dev/null differ diff --git a/assets/symbols/light_bulb_drawing.png b/assets/symbols/light_bulb_drawing.png deleted file mode 100644 index 3a362db73..000000000 Binary files a/assets/symbols/light_bulb_drawing.png and /dev/null differ diff --git a/assets/symbols/location.png b/assets/symbols/location.png deleted file mode 100644 index 256f15dc2..000000000 Binary files a/assets/symbols/location.png and /dev/null differ diff --git a/assets/symbols/phone1.jpg b/assets/symbols/phone1.jpg deleted file mode 100644 index e33fa0f5d..000000000 Binary files a/assets/symbols/phone1.jpg and /dev/null differ diff --git a/assets/symbols/smart_watch2.jpg b/assets/symbols/smart_watch2.jpg deleted file mode 100644 index 680a62525..000000000 Binary files a/assets/symbols/smart_watch2.jpg and /dev/null differ diff --git a/assets/symbols/speakers.jpg b/assets/symbols/speakers.jpg deleted file mode 100644 index 0ff6c2593..000000000 Binary files a/assets/symbols/speakers.jpg and /dev/null differ diff --git a/lib/domain/cbj_comp/cbj_comp_entity.dart b/lib/domain/cbj_comp/cbj_comp_entity.dart index 2b16d225c..35419a5f2 100644 --- a/lib/domain/cbj_comp/cbj_comp_entity.dart +++ b/lib/domain/cbj_comp/cbj_comp_entity.dart @@ -1,6 +1,6 @@ import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_light_entity/generic_light_entity.dart'; -import 'package:cybear_jinni/domain/cbj_comp/cbj_comp_failures.dart'; -import 'package:cybear_jinni/domain/cbj_comp/cbj_comp_value_objects.dart'; +import 'package:cybearjinni/domain/cbj_comp/cbj_comp_failures.dart'; +import 'package:cybearjinni/domain/cbj_comp/cbj_comp_value_objects.dart'; import 'package:dartz/dartz.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:kt_dart/kt.dart'; diff --git a/lib/domain/cbj_comp/cbj_comp_errors.dart b/lib/domain/cbj_comp/cbj_comp_errors.dart index 7b277f118..8a9b84e1e 100644 --- a/lib/domain/cbj_comp/cbj_comp_errors.dart +++ b/lib/domain/cbj_comp/cbj_comp_errors.dart @@ -1,4 +1,4 @@ -import 'package:cybear_jinni/domain/cbj_comp/cbj_comp_failures.dart'; +import 'package:cybearjinni/domain/cbj_comp/cbj_comp_failures.dart'; class CBJCompUnexpectedValueError extends Error { CBJCompUnexpectedValueError(this.cBJCompFailure); diff --git a/lib/domain/cbj_comp/cbj_comp_validators.dart b/lib/domain/cbj_comp/cbj_comp_validators.dart index adac15f2e..472d48502 100644 --- a/lib/domain/cbj_comp/cbj_comp_validators.dart +++ b/lib/domain/cbj_comp/cbj_comp_validators.dart @@ -1,5 +1,5 @@ import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_light_entity/generic_light_entity.dart'; -import 'package:cybear_jinni/domain/cbj_comp/cbj_comp_failures.dart'; +import 'package:cybearjinni/domain/cbj_comp/cbj_comp_failures.dart'; import 'package:dartz/dartz.dart'; import 'package:kt_dart/kt.dart'; diff --git a/lib/domain/cbj_comp/cbj_comp_value_objects.dart b/lib/domain/cbj_comp/cbj_comp_value_objects.dart index eb84cb324..a19e224fb 100644 --- a/lib/domain/cbj_comp/cbj_comp_value_objects.dart +++ b/lib/domain/cbj_comp/cbj_comp_value_objects.dart @@ -1,7 +1,7 @@ import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_light_entity/generic_light_entity.dart'; -import 'package:cybear_jinni/domain/cbj_comp/cbj_comp_errors.dart'; -import 'package:cybear_jinni/domain/cbj_comp/cbj_comp_failures.dart'; -import 'package:cybear_jinni/domain/cbj_comp/cbj_comp_validators.dart'; +import 'package:cybearjinni/domain/cbj_comp/cbj_comp_errors.dart'; +import 'package:cybearjinni/domain/cbj_comp/cbj_comp_failures.dart'; +import 'package:cybearjinni/domain/cbj_comp/cbj_comp_validators.dart'; import 'package:dartz/dartz.dart'; import 'package:flutter/foundation.dart'; import 'package:kt_dart/collection.dart'; diff --git a/lib/domain/cbj_comp/i_cbj_comp_repository.dart b/lib/domain/cbj_comp/i_cbj_comp_repository.dart index 34fbe76f0..3a058ecef 100644 --- a/lib/domain/cbj_comp/i_cbj_comp_repository.dart +++ b/lib/domain/cbj_comp/i_cbj_comp_repository.dart @@ -1,12 +1,12 @@ import 'dart:async'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_app_server/protoc_as_dart/cbj_app_connections.pbgrpc.dart'; -import 'package:cybear_jinni/domain/cbj_comp/cbj_comp_entity.dart'; -import 'package:cybear_jinni/domain/cbj_comp/cbj_comp_failures.dart'; -import 'package:cybear_jinni/infrastructure/cbj_app_server_d.dart'; +import 'package:cybearjinni/domain/cbj_comp/cbj_comp_entity.dart'; +import 'package:cybearjinni/domain/cbj_comp/cbj_comp_failures.dart'; +import 'package:cybearjinni/infrastructure/cbj_app_server_d.dart'; import 'package:dartz/dartz.dart'; -part 'package:cybear_jinni/infrastructure/cbj_comp_repository.dart'; +part 'package:cybearjinni/infrastructure/cbj_comp_repository.dart'; abstract interface class ICBJCompRepository { static ICBJCompRepository? _instance; diff --git a/lib/domain/connections_service.dart b/lib/domain/connections_service.dart index 00e3bb2c9..577dd79b3 100644 --- a/lib/domain/connections_service.dart +++ b/lib/domain/connections_service.dart @@ -8,9 +8,9 @@ import 'package:cbj_integrations_controller/infrastructure/generic_entities/abst import 'package:cbj_integrations_controller/infrastructure/generic_entities/entity_type_utils.dart'; import 'package:cbj_integrations_controller/infrastructure/search_devices.dart'; -part 'package:cybear_jinni/infrastructure/connection_service/app_connection_service.dart'; -part 'package:cybear_jinni/infrastructure/connection_service/demo_connection_service.dart'; -part 'package:cybear_jinni/infrastructure/connection_service/none_connection_service.dart'; +part 'package:cybearjinni/infrastructure/connection_service/app_connection_service.dart'; +part 'package:cybearjinni/infrastructure/connection_service/demo_connection_service.dart'; +part 'package:cybearjinni/infrastructure/connection_service/none_connection_service.dart'; enum ConnectionType { appAsHub, diff --git a/lib/domain/device/devices_errors.dart b/lib/domain/device/devices_errors.dart index f17d2128a..8a3a820df 100644 --- a/lib/domain/device/devices_errors.dart +++ b/lib/domain/device/devices_errors.dart @@ -1,4 +1,4 @@ -import 'package:cybear_jinni/domain/device/devices_failures.dart'; +import 'package:cybearjinni/domain/device/devices_failures.dart'; class DevicesUnexpectedValueError extends Error { DevicesUnexpectedValueError(this.deviceValueFailure); diff --git a/lib/domain/device/devices_validators.dart b/lib/domain/device/devices_validators.dart index deb32dc93..1efb4965d 100644 --- a/lib/domain/device/devices_validators.dart +++ b/lib/domain/device/devices_validators.dart @@ -1,5 +1,5 @@ import 'package:cbj_integrations_controller/infrastructure/generic_entities/entity_type_utils.dart'; -import 'package:cybear_jinni/domain/device/devices_failures.dart'; +import 'package:cybearjinni/domain/device/devices_failures.dart'; import 'package:dartz/dartz.dart'; Either, String> validateDeviceNotEmpty(String input) { diff --git a/lib/domain/device/i_device_repository.dart b/lib/domain/device/i_device_repository.dart index 7ec84589d..db1dfaf22 100644 --- a/lib/domain/device/i_device_repository.dart +++ b/lib/domain/device/i_device_repository.dart @@ -26,9 +26,9 @@ import 'package:cbj_integrations_controller/infrastructure/generic_entities/gene import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_switch_entity/generic_switch_entity.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_switch_entity/generic_switch_value_objects.dart'; import 'package:cbj_integrations_controller/infrastructure/hub_client/hub_client.dart'; -import 'package:cybear_jinni/domain/device/devices_failures.dart'; -import 'package:cybear_jinni/infrastructure/core/logger.dart'; -import 'package:cybear_jinni/infrastructure/hub_client/hub_requests_routing.dart'; +import 'package:cybearjinni/domain/device/devices_failures.dart'; +import 'package:cybearjinni/infrastructure/core/logger.dart'; +import 'package:cybearjinni/infrastructure/hub_client/hub_requests_routing.dart'; import 'package:dartz/dartz.dart'; import 'package:device_info_plus/device_info_plus.dart'; import 'package:flutter/material.dart'; @@ -40,7 +40,7 @@ import 'package:network_info_plus/network_info_plus.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:rxdart/rxdart.dart'; -part 'package:cybear_jinni/infrastructure/device_repository.dart'; +part 'package:cybearjinni/infrastructure/device_repository.dart'; abstract interface class IDeviceRepository { static IDeviceRepository? _instance; @@ -55,7 +55,7 @@ abstract interface class IDeviceRepository { Future initiateHubConnection(); - Future>> getAllDevices(); + Future>> getAllEntites(); Stream>> watchAll(); diff --git a/lib/domain/home_user/home_user_entity.dart b/lib/domain/home_user/home_user_entity.dart index 16dbca5d1..0fa308dc8 100644 --- a/lib/domain/home_user/home_user_entity.dart +++ b/lib/domain/home_user/home_user_entity.dart @@ -1,5 +1,5 @@ -import 'package:cybear_jinni/domain/home_user/home_user_failures.dart'; -import 'package:cybear_jinni/domain/home_user/home_user_value_objects.dart'; +import 'package:cybearjinni/domain/home_user/home_user_failures.dart'; +import 'package:cybearjinni/domain/home_user/home_user_value_objects.dart'; import 'package:dartz/dartz.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; diff --git a/lib/domain/home_user/home_user_errors.dart b/lib/domain/home_user/home_user_errors.dart index d2d31de77..a5800f534 100644 --- a/lib/domain/home_user/home_user_errors.dart +++ b/lib/domain/home_user/home_user_errors.dart @@ -1,4 +1,4 @@ -import 'package:cybear_jinni/domain/home_user/home_user_failures.dart'; +import 'package:cybearjinni/domain/home_user/home_user_failures.dart'; class HomeUserUnexpectedValueError extends Error { HomeUserUnexpectedValueError(this.homeUserValueFailure); diff --git a/lib/domain/home_user/home_user_validators.dart b/lib/domain/home_user/home_user_validators.dart index a98b3875a..3781af043 100644 --- a/lib/domain/home_user/home_user_validators.dart +++ b/lib/domain/home_user/home_user_validators.dart @@ -1,4 +1,4 @@ -import 'package:cybear_jinni/domain/home_user/home_user_failures.dart'; +import 'package:cybearjinni/domain/home_user/home_user_failures.dart'; import 'package:dartz/dartz.dart'; Either, String?> validateHomeUserEmailNotEmpty( diff --git a/lib/domain/home_user/home_user_value_objects.dart b/lib/domain/home_user/home_user_value_objects.dart index d761ff057..a4ca35da5 100644 --- a/lib/domain/home_user/home_user_value_objects.dart +++ b/lib/domain/home_user/home_user_value_objects.dart @@ -1,6 +1,6 @@ -import 'package:cybear_jinni/domain/home_user/home_user_errors.dart'; -import 'package:cybear_jinni/domain/home_user/home_user_failures.dart'; -import 'package:cybear_jinni/domain/home_user/home_user_validators.dart'; +import 'package:cybearjinni/domain/home_user/home_user_errors.dart'; +import 'package:cybearjinni/domain/home_user/home_user_failures.dart'; +import 'package:cybearjinni/domain/home_user/home_user_validators.dart'; import 'package:dartz/dartz.dart'; import 'package:flutter/foundation.dart'; import 'package:uuid/uuid.dart'; diff --git a/lib/domain/i_hub_connection_repository.dart b/lib/domain/i_hub_connection_repository.dart index d5234a3e1..437ad1db5 100644 --- a/lib/domain/i_hub_connection_repository.dart +++ b/lib/domain/i_hub_connection_repository.dart @@ -11,8 +11,8 @@ import 'package:cbj_integrations_controller/infrastructure/hub_client/hub_client import 'package:cbj_integrations_controller/infrastructure/hub_client/hub_client_demo.dart'; import 'package:cbj_integrations_controller/infrastructure/hub_client/hub_dtos.dart'; import 'package:connectivity_plus/connectivity_plus.dart'; -import 'package:cybear_jinni/domain/i_local_db_repository.dart'; -import 'package:cybear_jinni/infrastructure/core/injection.dart'; +import 'package:cybearjinni/domain/i_local_db_repository.dart'; +import 'package:cybearjinni/infrastructure/core/injection.dart'; import 'package:dartz/dartz.dart'; import 'package:flutter/foundation.dart' show kIsWeb; import 'package:location/location.dart'; @@ -22,7 +22,7 @@ import 'package:permission_handler/permission_handler.dart' as permission_handler; import 'package:wifi_iot/wifi_iot.dart'; -part 'package:cybear_jinni/infrastructure/hub_client/hub_connection_repository.dart'; +part 'package:cybearjinni/infrastructure/hub_client/hub_connection_repository.dart'; abstract class IHubConnectionRepository { static IHubConnectionRepository? _instance; diff --git a/lib/domain/i_local_db_repository.dart b/lib/domain/i_local_db_repository.dart index 4240d11df..6e60e5662 100644 --- a/lib/domain/i_local_db_repository.dart +++ b/lib/domain/i_local_db_repository.dart @@ -1,13 +1,13 @@ import 'package:cbj_integrations_controller/domain/local_db/local_db_failures.dart'; -import 'package:cybear_jinni/infrastructure/core/logger.dart'; -import 'package:cybear_jinni/infrastructure/isar_local_db/isar_objects/home_entity_isar_model.dart'; -import 'package:cybear_jinni/infrastructure/isar_local_db/isar_objects/hub_entity_isar_model.dart'; -import 'package:cybear_jinni/infrastructure/isar_local_db/isar_objects/remote_pipes_isar_model.dart'; +import 'package:cybearjinni/infrastructure/core/logger.dart'; +import 'package:cybearjinni/infrastructure/isar_local_db/isar_objects/home_entity_isar_model.dart'; +import 'package:cybearjinni/infrastructure/isar_local_db/isar_objects/hub_entity_isar_model.dart'; +import 'package:cybearjinni/infrastructure/isar_local_db/isar_objects/remote_pipes_isar_model.dart'; import 'package:dartz/dartz.dart'; import 'package:isar/isar.dart'; import 'package:path_provider/path_provider.dart'; -part 'package:cybear_jinni/infrastructure/isar_local_db/isar_repository.dart'; +part 'package:cybearjinni/infrastructure/isar_local_db/isar_repository.dart'; abstract interface class ILocalDbRepository { static ILocalDbRepository? _instance; diff --git a/lib/domain/i_notification_service.dart b/lib/domain/i_notification_service.dart deleted file mode 100644 index e92f040f6..000000000 --- a/lib/domain/i_notification_service.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:cybear_jinni/infrastructure/core/logger.dart'; -import 'package:flutter/foundation.dart' show kIsWeb; -import 'package:flutter_local_notifications/flutter_local_notifications.dart'; -import 'package:flutter_timezone/flutter_timezone.dart'; -import 'package:timezone/data/latest.dart' as tz; -import 'package:timezone/timezone.dart' as tz; - -part 'package:cybear_jinni/infrastructure/notifications.dart'; - -abstract interface class INotificationService { - static INotificationService? _instance; - - static INotificationService get instance { - return _instance ??= _AppNotificationService(); - } - - Future asyncConstructor(); -} diff --git a/lib/domain/manage_network/i_manage_network_repository.dart b/lib/domain/manage_network/i_manage_network_repository.dart index 12894d5bc..a5207c970 100644 --- a/lib/domain/manage_network/i_manage_network_repository.dart +++ b/lib/domain/manage_network/i_manage_network_repository.dart @@ -1,9 +1,9 @@ import 'dart:io'; -import 'package:cybear_jinni/domain/home_user/home_user_failures.dart'; -import 'package:cybear_jinni/domain/manage_network/manage_network_entity.dart'; -import 'package:cybear_jinni/domain/manage_network/manage_network_value_objects.dart'; -import 'package:cybear_jinni/infrastructure/core/logger.dart'; +import 'package:cybearjinni/domain/home_user/home_user_failures.dart'; +import 'package:cybearjinni/domain/manage_network/manage_network_entity.dart'; +import 'package:cybearjinni/domain/manage_network/manage_network_value_objects.dart'; +import 'package:cybearjinni/infrastructure/core/logger.dart'; import 'package:dartz/dartz.dart'; import 'package:flutter/services.dart'; import 'package:kt_dart/collection.dart'; @@ -11,7 +11,7 @@ import 'package:network_info_plus/network_info_plus.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:wifi_iot/wifi_iot.dart'; -part 'package:cybear_jinni/infrastructure/manage_wifi_repository.dart'; +part 'package:cybearjinni/infrastructure/manage_wifi_repository.dart'; abstract interface class IManageNetworkRepository { static IManageNetworkRepository? _instance; diff --git a/lib/domain/manage_network/manage_network_entity.dart b/lib/domain/manage_network/manage_network_entity.dart index ee7ac82d5..d40944870 100644 --- a/lib/domain/manage_network/manage_network_entity.dart +++ b/lib/domain/manage_network/manage_network_entity.dart @@ -1,5 +1,5 @@ -import 'package:cybear_jinni/domain/manage_network/manage_network_failures.dart'; -import 'package:cybear_jinni/domain/manage_network/manage_network_value_objects.dart'; +import 'package:cybearjinni/domain/manage_network/manage_network_failures.dart'; +import 'package:cybearjinni/domain/manage_network/manage_network_value_objects.dart'; import 'package:dartz/dartz.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; diff --git a/lib/domain/manage_network/manage_network_errors.dart b/lib/domain/manage_network/manage_network_errors.dart index a44387d45..f22c251d1 100644 --- a/lib/domain/manage_network/manage_network_errors.dart +++ b/lib/domain/manage_network/manage_network_errors.dart @@ -1,4 +1,4 @@ -import 'package:cybear_jinni/domain/manage_network/manage_network_failures.dart'; +import 'package:cybearjinni/domain/manage_network/manage_network_failures.dart'; class ManageNetworkUnexpectedValueError extends Error { ManageNetworkUnexpectedValueError(this.homeUserValueFailure); diff --git a/lib/domain/manage_network/manage_network_validators.dart b/lib/domain/manage_network/manage_network_validators.dart index 8d2b11875..5959a8a54 100644 --- a/lib/domain/manage_network/manage_network_validators.dart +++ b/lib/domain/manage_network/manage_network_validators.dart @@ -1,4 +1,4 @@ -import 'package:cybear_jinni/domain/manage_network/manage_network_failures.dart'; +import 'package:cybearjinni/domain/manage_network/manage_network_failures.dart'; import 'package:dartz/dartz.dart'; Either, String> validateMangageNetworkNameEmpty( diff --git a/lib/domain/manage_network/manage_network_value_objects.dart b/lib/domain/manage_network/manage_network_value_objects.dart index 056a3a472..7be82aa18 100644 --- a/lib/domain/manage_network/manage_network_value_objects.dart +++ b/lib/domain/manage_network/manage_network_value_objects.dart @@ -1,6 +1,6 @@ -import 'package:cybear_jinni/domain/manage_network/manage_network_errors.dart'; -import 'package:cybear_jinni/domain/manage_network/manage_network_failures.dart'; -import 'package:cybear_jinni/domain/manage_network/manage_network_validators.dart'; +import 'package:cybearjinni/domain/manage_network/manage_network_errors.dart'; +import 'package:cybearjinni/domain/manage_network/manage_network_failures.dart'; +import 'package:cybearjinni/domain/manage_network/manage_network_validators.dart'; import 'package:dartz/dartz.dart'; import 'package:flutter/foundation.dart'; diff --git a/lib/domain/security_bear/i_security_bear_connection_repository.dart b/lib/domain/security_bear/i_security_bear_connection_repository.dart index b9ed72696..7979e269f 100644 --- a/lib/domain/security_bear/i_security_bear_connection_repository.dart +++ b/lib/domain/security_bear/i_security_bear_connection_repository.dart @@ -2,16 +2,16 @@ import 'dart:io'; import 'package:cbj_integrations_controller/infrastructure/gen/security_bear_server_d/protoc_as_dart/security_bear_connections.pbgrpc.dart'; import 'package:connectivity_plus/connectivity_plus.dart'; -import 'package:cybear_jinni/domain/cbj_comp/cbj_comp_entity.dart'; -import 'package:cybear_jinni/domain/manage_network/i_manage_network_repository.dart'; -import 'package:cybear_jinni/domain/manage_network/manage_network_entity.dart'; -import 'package:cybear_jinni/domain/manage_network/manage_network_value_objects.dart'; -import 'package:cybear_jinni/domain/security_bear/security_bear_entity.dart'; -import 'package:cybear_jinni/domain/security_bear/security_bear_failures.dart'; -import 'package:cybear_jinni/domain/security_bear/security_bear_value_objects.dart'; -import 'package:cybear_jinni/infrastructure/core/injection.dart'; -import 'package:cybear_jinni/infrastructure/core/logger.dart'; -import 'package:cybear_jinni/infrastructure/security_bear_client/security_bear_server_client.dart'; +import 'package:cybearjinni/domain/cbj_comp/cbj_comp_entity.dart'; +import 'package:cybearjinni/domain/manage_network/i_manage_network_repository.dart'; +import 'package:cybearjinni/domain/manage_network/manage_network_entity.dart'; +import 'package:cybearjinni/domain/manage_network/manage_network_value_objects.dart'; +import 'package:cybearjinni/domain/security_bear/security_bear_entity.dart'; +import 'package:cybearjinni/domain/security_bear/security_bear_failures.dart'; +import 'package:cybearjinni/domain/security_bear/security_bear_value_objects.dart'; +import 'package:cybearjinni/infrastructure/core/injection.dart'; +import 'package:cybearjinni/infrastructure/core/logger.dart'; +import 'package:cybearjinni/infrastructure/security_bear_client/security_bear_server_client.dart'; import 'package:dartz/dartz.dart'; import 'package:flutter/foundation.dart'; import 'package:location/location.dart'; @@ -20,7 +20,7 @@ import 'package:network_tools/network_tools.dart'; import 'package:permission_handler/permission_handler.dart' as permission_handler; -part 'package:cybear_jinni/infrastructure/security_bear_client/security_bear_connection_repository.dart'; +part 'package:cybearjinni/infrastructure/security_bear_client/security_bear_connection_repository.dart'; abstract interface class ISecurityBearConnectionRepository { static ISecurityBearConnectionRepository? _instance; diff --git a/lib/domain/security_bear/security_bear_entity.dart b/lib/domain/security_bear/security_bear_entity.dart index 015e20ef0..dcfdaa75e 100644 --- a/lib/domain/security_bear/security_bear_entity.dart +++ b/lib/domain/security_bear/security_bear_entity.dart @@ -1,6 +1,6 @@ -import 'package:cybear_jinni/domain/security_bear/security_bear_failures.dart'; -import 'package:cybear_jinni/domain/security_bear/security_bear_value_objects.dart'; -import 'package:cybear_jinni/infrastructure/security_bear_client/security_bear_dtos.dart'; +import 'package:cybearjinni/domain/security_bear/security_bear_failures.dart'; +import 'package:cybearjinni/domain/security_bear/security_bear_value_objects.dart'; +import 'package:cybearjinni/infrastructure/security_bear_client/security_bear_dtos.dart'; import 'package:dartz/dartz.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; diff --git a/lib/domain/security_bear/security_bear_errors.dart b/lib/domain/security_bear/security_bear_errors.dart index 9c239cdf4..158bf50c1 100644 --- a/lib/domain/security_bear/security_bear_errors.dart +++ b/lib/domain/security_bear/security_bear_errors.dart @@ -1,4 +1,4 @@ -import 'package:cybear_jinni/domain/security_bear/security_bear_failures.dart'; +import 'package:cybearjinni/domain/security_bear/security_bear_failures.dart'; class SecurityBearUnexpectedValueError extends Error { SecurityBearUnexpectedValueError(this.homeUserValueFailure); diff --git a/lib/domain/security_bear/security_bear_validators.dart b/lib/domain/security_bear/security_bear_validators.dart index d73d7a42d..21b4b7ef9 100644 --- a/lib/domain/security_bear/security_bear_validators.dart +++ b/lib/domain/security_bear/security_bear_validators.dart @@ -1,4 +1,4 @@ -import 'package:cybear_jinni/domain/security_bear/security_bear_failures.dart'; +import 'package:cybearjinni/domain/security_bear/security_bear_failures.dart'; import 'package:dartz/dartz.dart'; Either, String> validateStringNotEmpty( diff --git a/lib/domain/security_bear/security_bear_value_objects.dart b/lib/domain/security_bear/security_bear_value_objects.dart index 205969e53..2e34cce48 100644 --- a/lib/domain/security_bear/security_bear_value_objects.dart +++ b/lib/domain/security_bear/security_bear_value_objects.dart @@ -1,6 +1,6 @@ -import 'package:cybear_jinni/domain/security_bear/security_bear_errors.dart'; -import 'package:cybear_jinni/domain/security_bear/security_bear_failures.dart'; -import 'package:cybear_jinni/domain/security_bear/security_bear_validators.dart'; +import 'package:cybearjinni/domain/security_bear/security_bear_errors.dart'; +import 'package:cybearjinni/domain/security_bear/security_bear_failures.dart'; +import 'package:cybearjinni/domain/security_bear/security_bear_validators.dart'; import 'package:dartz/dartz.dart'; import 'package:flutter/foundation.dart'; diff --git a/lib/domain/software_info/i_software_info_repository.dart b/lib/domain/software_info/i_software_info_repository.dart index 2db5635a4..b912ea439 100644 --- a/lib/domain/software_info/i_software_info_repository.dart +++ b/lib/domain/software_info/i_software_info_repository.dart @@ -7,17 +7,17 @@ import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/pr import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/security_bear_server_d/proto_gen_date.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/security_bear_server_d/protoc_as_dart/security_bear_connections.pbgrpc.dart'; -import 'package:cybear_jinni/domain/i_hub_connection_repository.dart'; -import 'package:cybear_jinni/domain/security_bear/i_security_bear_connection_repository.dart'; -import 'package:cybear_jinni/domain/security_bear/security_bear_failures.dart'; -import 'package:cybear_jinni/domain/software_info/software_info_entity.dart'; -import 'package:cybear_jinni/domain/software_info/software_info_failures.dart'; -import 'package:cybear_jinni/infrastructure/core/logger.dart'; +import 'package:cybearjinni/domain/i_hub_connection_repository.dart'; +import 'package:cybearjinni/domain/security_bear/i_security_bear_connection_repository.dart'; +import 'package:cybearjinni/domain/security_bear/security_bear_failures.dart'; +import 'package:cybearjinni/domain/software_info/software_info_entity.dart'; +import 'package:cybearjinni/domain/software_info/software_info_failures.dart'; +import 'package:cybearjinni/infrastructure/core/logger.dart'; import 'package:dartz/dartz.dart'; import 'package:network_info_plus/network_info_plus.dart'; import 'package:package_info_plus/package_info_plus.dart'; -part 'package:cybear_jinni/infrastructure/software_info/software_info_repository.dart'; +part 'package:cybearjinni/infrastructure/software_info/software_info_repository.dart'; abstract interface class ISoftwareInfoRepository { static ISoftwareInfoRepository? _instance; diff --git a/lib/domain/software_info/software_info_entity.dart b/lib/domain/software_info/software_info_entity.dart index 1404d3574..17f61a3de 100644 --- a/lib/domain/software_info/software_info_entity.dart +++ b/lib/domain/software_info/software_info_entity.dart @@ -1,9 +1,9 @@ import 'package:cbj_integrations_controller/infrastructure/gen/cbj_app_server/protoc_as_dart/cbj_app_connections.pbgrpc.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/security_bear_server_d/protoc_as_dart/security_bear_connections.pbgrpc.dart'; -import 'package:cybear_jinni/domain/software_info/software_info_failures.dart'; -import 'package:cybear_jinni/domain/software_info/software_info_value_objects.dart'; -import 'package:cybear_jinni/infrastructure/software_info/software_info_dtos.dart'; +import 'package:cybearjinni/domain/software_info/software_info_failures.dart'; +import 'package:cybearjinni/domain/software_info/software_info_value_objects.dart'; +import 'package:cybearjinni/infrastructure/software_info/software_info_dtos.dart'; import 'package:dartz/dartz.dart'; class SoftwareInfoEntity { diff --git a/lib/domain/software_info/software_info_errors.dart b/lib/domain/software_info/software_info_errors.dart index afae576c1..516ebad68 100644 --- a/lib/domain/software_info/software_info_errors.dart +++ b/lib/domain/software_info/software_info_errors.dart @@ -1,4 +1,4 @@ -import 'package:cybear_jinni/domain/software_info/software_info_failures.dart'; +import 'package:cybearjinni/domain/software_info/software_info_failures.dart'; class SoftwareInfoUnexpectedValueError extends Error { SoftwareInfoUnexpectedValueError(this.homeUserValueFailure); diff --git a/lib/domain/software_info/software_info_validators.dart b/lib/domain/software_info/software_info_validators.dart index 2b2c4fe5d..818eb5d93 100644 --- a/lib/domain/software_info/software_info_validators.dart +++ b/lib/domain/software_info/software_info_validators.dart @@ -1,4 +1,4 @@ -import 'package:cybear_jinni/domain/software_info/software_info_failures.dart'; +import 'package:cybearjinni/domain/software_info/software_info_failures.dart'; import 'package:dartz/dartz.dart'; Either, String> validateSoftwareInfoEmpty( diff --git a/lib/domain/software_info/software_info_value_objects.dart b/lib/domain/software_info/software_info_value_objects.dart index d2ff93ee8..2c47d5c0c 100644 --- a/lib/domain/software_info/software_info_value_objects.dart +++ b/lib/domain/software_info/software_info_value_objects.dart @@ -1,5 +1,5 @@ -import 'package:cybear_jinni/domain/software_info/software_info_errors.dart'; -import 'package:cybear_jinni/domain/software_info/software_info_failures.dart'; +import 'package:cybearjinni/domain/software_info/software_info_errors.dart'; +import 'package:cybearjinni/domain/software_info/software_info_failures.dart'; import 'package:dartz/dartz.dart'; import 'package:flutter/foundation.dart'; diff --git a/lib/infrastructure/cbj_app_server_d.dart b/lib/infrastructure/cbj_app_server_d.dart index 31770b4f1..3e46a5e0e 100644 --- a/lib/infrastructure/cbj_app_server_d.dart +++ b/lib/infrastructure/cbj_app_server_d.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_app_server/protoc_as_dart/cbj_app_connections.pbgrpc.dart'; -import 'package:cybear_jinni/infrastructure/core/logger.dart'; +import 'package:cybearjinni/infrastructure/core/logger.dart'; import 'package:grpc/grpc.dart'; /// The implantation of the CyBear Jinni App Server from grpc diff --git a/lib/infrastructure/cbj_comp_repository.dart b/lib/infrastructure/cbj_comp_repository.dart index 15c0b0cf2..03a804cd2 100644 --- a/lib/infrastructure/cbj_comp_repository.dart +++ b/lib/infrastructure/cbj_comp_repository.dart @@ -1,4 +1,4 @@ -part of 'package:cybear_jinni/domain/cbj_comp/i_cbj_comp_repository.dart'; +part of 'package:cybearjinni/domain/cbj_comp/i_cbj_comp_repository.dart'; class _CBJCompRepository implements ICBJCompRepository { @override diff --git a/lib/infrastructure/connection_service/app_connection_service.dart b/lib/infrastructure/connection_service/app_connection_service.dart index 1f9391dff..6717e9f06 100644 --- a/lib/infrastructure/connection_service/app_connection_service.dart +++ b/lib/infrastructure/connection_service/app_connection_service.dart @@ -1,4 +1,4 @@ -part of 'package:cybear_jinni/domain/connections_service.dart'; +part of 'package:cybearjinni/domain/connections_service.dart'; class _AppConnectionService implements ConnectionsService { _AppConnectionService() { diff --git a/lib/infrastructure/connection_service/demo_connection_service.dart b/lib/infrastructure/connection_service/demo_connection_service.dart index 227a12e58..739c348bc 100644 --- a/lib/infrastructure/connection_service/demo_connection_service.dart +++ b/lib/infrastructure/connection_service/demo_connection_service.dart @@ -1,4 +1,4 @@ -part of 'package:cybear_jinni/domain/connections_service.dart'; +part of 'package:cybearjinni/domain/connections_service.dart'; class _DemoConnectionService implements ConnectionsService { StreamController>? stream; diff --git a/lib/infrastructure/connection_service/none_connection_service.dart b/lib/infrastructure/connection_service/none_connection_service.dart index ede9510ca..e287de7c8 100644 --- a/lib/infrastructure/connection_service/none_connection_service.dart +++ b/lib/infrastructure/connection_service/none_connection_service.dart @@ -1,4 +1,4 @@ -part of 'package:cybear_jinni/domain/connections_service.dart'; +part of 'package:cybearjinni/domain/connections_service.dart'; class _NoneConnectionService implements ConnectionsService { StreamController>? stream; diff --git a/lib/infrastructure/core/injection.dart b/lib/infrastructure/core/injection.dart index e785a0822..f676fbd4d 100644 --- a/lib/infrastructure/core/injection.dart +++ b/lib/infrastructure/core/injection.dart @@ -1,5 +1,5 @@ import 'package:cbj_integrations_controller/infrastructure/core/injection.config.dart'; -import 'package:cybear_jinni/infrastructure/core/logger.dart'; +import 'package:cybearjinni/infrastructure/core/logger.dart'; import 'package:get_it/get_it.dart'; import 'package:injectable/injectable.dart'; diff --git a/lib/infrastructure/device_repository.dart b/lib/infrastructure/device_repository.dart index 55bb95eb6..a11f53e7b 100644 --- a/lib/infrastructure/device_repository.dart +++ b/lib/infrastructure/device_repository.dart @@ -1,4 +1,4 @@ -part of 'package:cybear_jinni/domain/device/i_device_repository.dart'; +part of 'package:cybearjinni/domain/device/i_device_repository.dart'; class _DeviceRepository implements IDeviceRepository { // final DeviceRemoteService _deviceRemoteService; @@ -44,7 +44,7 @@ class _DeviceRepository implements IDeviceRepository { @override Future>> - getAllDevices() async { + getAllEntites() async { try { return right(allDevices.values.toImmutableList()); } catch (e) { diff --git a/lib/infrastructure/hub_client/hub_connection_repository.dart b/lib/infrastructure/hub_client/hub_connection_repository.dart index 0098d0bfe..a2ceae49b 100644 --- a/lib/infrastructure/hub_client/hub_connection_repository.dart +++ b/lib/infrastructure/hub_client/hub_connection_repository.dart @@ -1,4 +1,4 @@ -part of 'package:cybear_jinni/domain/i_hub_connection_repository.dart'; +part of 'package:cybearjinni/domain/i_hub_connection_repository.dart'; class _HubConnectionRepository implements IHubConnectionRepository { _HubConnectionRepository() { diff --git a/lib/infrastructure/hub_client/hub_requests_routing.dart b/lib/infrastructure/hub_client/hub_requests_routing.dart index cf366ceb2..3e2cbc16d 100644 --- a/lib/infrastructure/hub_client/hub_requests_routing.dart +++ b/lib/infrastructure/hub_client/hub_requests_routing.dart @@ -24,10 +24,10 @@ import 'package:cbj_integrations_controller/infrastructure/hub_client/hub_client import 'package:cbj_integrations_controller/infrastructure/room/room_entity_dtos.dart'; import 'package:cbj_integrations_controller/infrastructure/scenes/scene_cbj_dtos.dart'; import 'package:connectivity_plus/connectivity_plus.dart'; -import 'package:cybear_jinni/domain/device/i_device_repository.dart'; -import 'package:cybear_jinni/domain/i_hub_connection_repository.dart'; -import 'package:cybear_jinni/infrastructure/core/injection.dart'; -import 'package:cybear_jinni/infrastructure/core/logger.dart'; +import 'package:cybearjinni/domain/device/i_device_repository.dart'; +import 'package:cybearjinni/domain/i_hub_connection_repository.dart'; +import 'package:cybearjinni/infrastructure/core/injection.dart'; +import 'package:cybearjinni/infrastructure/core/logger.dart'; import 'package:grpc/grpc.dart'; class HubRequestRouting { @@ -216,7 +216,7 @@ class HubRequestRouting { return; } else { logger.w( - 'Device type is $deviceType is not supported $entityStateGRPC ', + 'Entity type is $deviceType is not supported $entityStateGRPC ', ); deviceEntity = GenericUnsupportedDeviceDtos.fromJson(requestAsJson).toDomain(); diff --git a/lib/infrastructure/isar_local_db/isar_repository.dart b/lib/infrastructure/isar_local_db/isar_repository.dart index 138c72d6f..ad3e9678e 100644 --- a/lib/infrastructure/isar_local_db/isar_repository.dart +++ b/lib/infrastructure/isar_local_db/isar_repository.dart @@ -1,4 +1,4 @@ -part of 'package:cybear_jinni/domain/i_local_db_repository.dart'; +part of 'package:cybearjinni/domain/i_local_db_repository.dart'; class _IsarRepository implements ILocalDbRepository { late Isar isar; diff --git a/lib/infrastructure/manage_wifi_repository.dart b/lib/infrastructure/manage_wifi_repository.dart index 5396a3181..6dd1e6aea 100644 --- a/lib/infrastructure/manage_wifi_repository.dart +++ b/lib/infrastructure/manage_wifi_repository.dart @@ -1,4 +1,4 @@ -part of 'package:cybear_jinni/domain/manage_network/i_manage_network_repository.dart'; +part of 'package:cybearjinni/domain/manage_network/i_manage_network_repository.dart'; class _ManageWiFiRepository implements IManageNetworkRepository { final NetworkSecurity networkSecurity = NetworkSecurity.WPA; diff --git a/lib/infrastructure/mqtt.dart b/lib/infrastructure/mqtt.dart index a4e221506..bd6ce936b 100644 --- a/lib/infrastructure/mqtt.dart +++ b/lib/infrastructure/mqtt.dart @@ -10,7 +10,7 @@ import 'package:cbj_integrations_controller/infrastructure/generic_entities/abst import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/value_objects_core.dart'; import 'package:cbj_integrations_controller/infrastructure/hub_client/hub_client.dart'; import 'package:cbj_integrations_controller/infrastructure/room/room_entity_dtos.dart'; -import 'package:cybear_jinni/infrastructure/core/logger.dart'; +import 'package:cybearjinni/infrastructure/core/logger.dart'; import 'package:mqtt_client/mqtt_client.dart'; import 'package:mqtt_client/mqtt_server_client.dart'; // ignore: implementation_imports diff --git a/lib/infrastructure/notifications.dart b/lib/infrastructure/notifications.dart deleted file mode 100644 index 585623d9f..000000000 --- a/lib/infrastructure/notifications.dart +++ /dev/null @@ -1,155 +0,0 @@ -part of 'package:cybear_jinni/domain/i_notification_service.dart'; - -class _AppNotificationService extends INotificationService { - FlutterLocalNotificationsPlugin? flutterLocalNotificationsPlugin; - - @override - Future asyncConstructor() async { - if (isConstructed) { - return; - } - isConstructed = true; - await configureLocalTimeZone(); - await initialisationNotifications(); - } - - bool isConstructed = false; - - Future configureLocalTimeZone() async { - tz.initializeTimeZones(); - try { - final String timeZoneName = await FlutterTimezone.getLocalTimezone(); - tz.setLocalLocation(tz.getLocation(timeZoneName)); - } catch (e) { - tz.setLocalLocation(tz.getLocation('US/Central')); - } - } - - Future initialisationNotifications() async { - if (kIsWeb) { - return; - } - flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin(); - - // initialise the plugin. app_icon needs to be a added as a drawable resource - // to the Android head project - const AndroidInitializationSettings initializationSettingsAndroid = - AndroidInitializationSettings('ic_launcher_foreground'); - final DarwinInitializationSettings initializationSettingsIOS = - DarwinInitializationSettings( - onDidReceiveLocalNotification: selectNotificationIos, - ); - - const LinuxInitializationSettings initializationSettingsLinux = - LinuxInitializationSettings( - defaultActionName: 'Open notification', - // defaultIcon: AssetsLinuxIcon('icons/app_icon.png'), - ); - - const DarwinInitializationSettings initializationSettingsMacOS = - DarwinInitializationSettings(); - final InitializationSettings initializationSettings = - InitializationSettings( - android: initializationSettingsAndroid, - iOS: initializationSettingsIOS, - macOS: initializationSettingsMacOS, - linux: initializationSettingsLinux, - ); - await flutterLocalNotificationsPlugin!.initialize( - initializationSettings, - ); - } - - Future selectNotification(String? payload) async { - if (payload != null) { - logger.d('notification payload: $payload'); - } - } - - Future selectNotificationIos( - int? id, - String? title, - String? body, - String? payload, - ) async { - if (payload != null) { - logger.d('notification payload: $payload'); - } - } - - Future zonedScheduleNotification() async { - if (kIsWeb) { - return; - } - await flutterLocalNotificationsPlugin!.zonedSchedule( - 0, - 'scheduled title', - 'scheduled body', - tz.TZDateTime.now(tz.local).add(const Duration(seconds: 5)), - const NotificationDetails( - android: AndroidNotificationDetails( - 'your channel id', - 'your channel name', - sound: RawResourceAndroidNotificationSound( - 'alarm_clock_the_journey_of_waking_up_created_by_omer_luz', - ), - ), - ), - androidScheduleMode: AndroidScheduleMode.exactAllowWhileIdle, - uiLocalNotificationDateInterpretation: - UILocalNotificationDateInterpretation.absoluteTime, - ); - } - - Future showNotificationCustomSound() async { - if (kIsWeb) { - return; - } - const AndroidNotificationDetails androidPlatformChannelSpecifics = - AndroidNotificationDetails( - 'your other channel id', - 'your other channel name', - sound: - RawResourceAndroidNotificationSound('alert_sfx_created_by_omer_luz'), - ); - const DarwinNotificationDetails iOSPlatformChannelSpecifics = - DarwinNotificationDetails(sound: 'alert_sfx_created_by_omer_luz.wav'); - const DarwinNotificationDetails macOSPlatformChannelSpecifics = - DarwinNotificationDetails(sound: 'alert_sfx_created_by_omer_luz.wav'); - const NotificationDetails platformChannelSpecifics = NotificationDetails( - android: androidPlatformChannelSpecifics, - iOS: iOSPlatformChannelSpecifics, - macOS: macOSPlatformChannelSpecifics, - ); - await flutterLocalNotificationsPlugin!.show( - 0, - 'custom sound notification title', - 'custom sound notification body', - platformChannelSpecifics, - ); - } - - Future showSoundUriNotification() async { - if (kIsWeb) { - return; - } - - /// this calls a method over a platform channel implemented within the - /// example app to return the Uri for the default alarm sound and uses - /// as the notification sound - // final String? alarmUri = await platform.invokeMethod('getAlarmUri'); - // final UriAndroidNotificationSound uriSound = - // UriAndroidNotificationSound(alarmUri!); - // final AndroidNotificationDetails androidPlatformChannelSpecifics = - // AndroidNotificationDetails( - // 'uri channel id', - // 'uri channel name', - // sound: uriSound, - // styleInformation: const DefaultStyleInformation(true, true), - // ); - // final NotificationDetails platformChannelSpecifics = - // NotificationDetails(android: androidPlatformChannelSpecifics); - // await flutterLocalNotificationsPlugin! - // .show(0, 'uri sound title', 'uri sound body', platformChannelSpecifics); - } -} diff --git a/lib/infrastructure/security_bear_client/security_bear_connection_repository.dart b/lib/infrastructure/security_bear_client/security_bear_connection_repository.dart index 946397839..60b613bc3 100644 --- a/lib/infrastructure/security_bear_client/security_bear_connection_repository.dart +++ b/lib/infrastructure/security_bear_client/security_bear_connection_repository.dart @@ -1,4 +1,4 @@ -part of 'package:cybear_jinni/domain/security_bear/i_security_bear_connection_repository.dart'; +part of 'package:cybearjinni/domain/security_bear/i_security_bear_connection_repository.dart'; class _SecurityBearConnectionRepository implements ISecurityBearConnectionRepository { diff --git a/lib/infrastructure/security_bear_client/security_bear_dtos.dart b/lib/infrastructure/security_bear_client/security_bear_dtos.dart index e4e2a09e1..94eb7c3df 100644 --- a/lib/infrastructure/security_bear_client/security_bear_dtos.dart +++ b/lib/infrastructure/security_bear_client/security_bear_dtos.dart @@ -1,5 +1,5 @@ -import 'package:cybear_jinni/domain/security_bear/security_bear_entity.dart'; -import 'package:cybear_jinni/domain/security_bear/security_bear_value_objects.dart'; +import 'package:cybearjinni/domain/security_bear/security_bear_entity.dart'; +import 'package:cybearjinni/domain/security_bear/security_bear_value_objects.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; part 'security_bear_dtos.freezed.dart'; diff --git a/lib/infrastructure/security_bear_client/security_bear_server_client.dart b/lib/infrastructure/security_bear_client/security_bear_server_client.dart index 2e8ff2781..6c2a8cd16 100644 --- a/lib/infrastructure/security_bear_client/security_bear_server_client.dart +++ b/lib/infrastructure/security_bear_client/security_bear_server_client.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'package:cbj_integrations_controller/infrastructure/gen/security_bear_server_d/protoc_as_dart/security_bear_connections.pbgrpc.dart'; -import 'package:cybear_jinni/infrastructure/core/logger.dart'; +import 'package:cybearjinni/infrastructure/core/logger.dart'; import 'package:grpc/grpc.dart'; class SecurityBearServerClient { diff --git a/lib/infrastructure/software_info/software_info_dtos.dart b/lib/infrastructure/software_info/software_info_dtos.dart index 7c7805e2c..0db87952a 100644 --- a/lib/infrastructure/software_info/software_info_dtos.dart +++ b/lib/infrastructure/software_info/software_info_dtos.dart @@ -1,5 +1,5 @@ -import 'package:cybear_jinni/domain/software_info/software_info_entity.dart'; -import 'package:cybear_jinni/domain/software_info/software_info_value_objects.dart'; +import 'package:cybearjinni/domain/software_info/software_info_entity.dart'; +import 'package:cybearjinni/domain/software_info/software_info_value_objects.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; part 'software_info_dtos.freezed.dart'; diff --git a/lib/infrastructure/software_info/software_info_repository.dart b/lib/infrastructure/software_info/software_info_repository.dart index 611f78fa2..9f528ee2a 100644 --- a/lib/infrastructure/software_info/software_info_repository.dart +++ b/lib/infrastructure/software_info/software_info_repository.dart @@ -1,4 +1,4 @@ -part of 'package:cybear_jinni/domain/software_info/i_software_info_repository.dart'; +part of 'package:cybearjinni/domain/software_info/i_software_info_repository.dart'; class _SoftwareInfoRepository implements ISoftwareInfoRepository { @override diff --git a/lib/main.dart b/lib/main.dart index 5cf7c26b1..3315c4d0d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,47 +1,20 @@ -import 'package:cbj_integrations_controller/domain/i_saved_devices_repo.dart'; -import 'package:cbj_integrations_controller/domain/local_db/i_local_db_repository.dart'; import 'package:cbj_integrations_controller/infrastructure/core/injection.dart'; -import 'package:cbj_integrations_controller/infrastructure/node_red/node_red_repository.dart'; -import 'package:cbj_integrations_controller/infrastructure/system_commands/system_commands_manager_d.dart'; -import 'package:cbj_smart_device_flutter/commands/flutter_commands.dart'; -import 'package:cybear_jinni/domain/connections_service.dart'; -import 'package:cybear_jinni/domain/i_local_db_repository.dart'; -import 'package:cybear_jinni/domain/i_notification_service.dart'; -import 'package:cybear_jinni/infrastructure/app_commands.dart'; -import 'package:cybear_jinni/infrastructure/core/injection.dart'; -import 'package:cybear_jinni/infrastructure/mqtt.dart'; -import 'package:cybear_jinni/presentation/core/app_widget.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.dart'; +import 'package:cybearjinni/infrastructure/core/injection.dart'; +import 'package:cybearjinni/presentation/core/app_widget.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.dart'; import 'package:dartz/dartz.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:hive_flutter/hive_flutter.dart'; Future main() async { configureDependencies(EnvApp.dev); configureInjection(Env.devPc); WidgetsFlutterBinding.ensureInitialized(); - // final Directory appDocDirectory = await getApplicationDocumentsDirectory(); - // await configureNetworkTools(appDocDirectory.path); - await Hive.initFlutter(); - AppCommands(); - await Future.value([ - IDbRepository.instance.initializeDb(isFlutter: true), - ILocalDbRepository.instance.asyncConstructor(), - ISavedDevicesRepo.instance.setUpAllFromDb(), - ]); + await EasyLocalization.ensureInitialized(); getIt.registerSingleton(AppRouter()); - await INotificationService.instance.asyncConstructor(); - - MqttServerRepository(); - PhoneCommandsD(); - SystemCommandsManager(); - NodeRedRepository(); - ConnectionsService.instance; - runApp( /// Use https://lingohub.com/developers/supported-locales/language-designators-with-regions /// Or https://www.contentstack.com/docs/developers/multilingual-content/list-of-supported-languages/ diff --git a/lib/presentation/atoms/atoms.dart b/lib/presentation/atoms/atoms.dart index 77f552e68..16fffc912 100644 --- a/lib/presentation/atoms/atoms.dart +++ b/lib/presentation/atoms/atoms.dart @@ -1,6 +1,8 @@ export 'bottom_navigation_bar_item_atom.dart'; export 'button_atom.dart'; +export 'card_atom.dart'; export 'circular_progress_indicator_atom.dart'; +export 'icon_atom.dart'; export 'image_atom.dart'; export 'margined_expanded_atom.dart'; export 'separator_atom.dart'; diff --git a/lib/presentation/atoms/button_atom.dart b/lib/presentation/atoms/button_atom.dart index 3df34941c..5540d2f98 100644 --- a/lib/presentation/atoms/button_atom.dart +++ b/lib/presentation/atoms/button_atom.dart @@ -1,4 +1,4 @@ -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; import 'package:flutter/material.dart'; class ButtonWidgetAtom extends StatelessWidget { diff --git a/lib/presentation/atoms/card_atom.dart b/lib/presentation/atoms/card_atom.dart new file mode 100644 index 000000000..56a16d40a --- /dev/null +++ b/lib/presentation/atoms/card_atom.dart @@ -0,0 +1,14 @@ +import 'package:flutter/material.dart'; + +class CardAtom extends StatelessWidget { + const CardAtom(this.child); + + final Widget child; + + @override + Widget build(BuildContext context) { + return Card( + child: child, + ); + } +} diff --git a/lib/presentation/atoms/icon_atom.dart b/lib/presentation/atoms/icon_atom.dart new file mode 100644 index 000000000..4adeb02fa --- /dev/null +++ b/lib/presentation/atoms/icon_atom.dart @@ -0,0 +1,12 @@ +import 'package:flutter/material.dart'; + +class IconAtom extends StatelessWidget { + const IconAtom(this.icon); + + final IconData icon; + + @override + Widget build(BuildContext context) { + return Icon(icon); + } +} diff --git a/lib/presentation/atoms/image_atom.dart b/lib/presentation/atoms/image_atom.dart index 00466d77f..85ee6a6a1 100644 --- a/lib/presentation/atoms/image_atom.dart +++ b/lib/presentation/atoms/image_atom.dart @@ -1,15 +1,21 @@ import 'package:flutter/cupertino.dart'; class ImageAtom extends StatelessWidget { - const ImageAtom(this.name, {this.fit, this.width, this.height}); + const ImageAtom( + this.name, { + this.fit, + this.width, + this.height, + this.hero, + }); final String name; final BoxFit? fit; final double? width; final double? height; + final String? hero; - @override - Widget build(BuildContext context) { + Widget image() { return Image.asset( name, fit: fit, @@ -17,4 +23,15 @@ class ImageAtom extends StatelessWidget { height: height, ); } + + @override + Widget build(BuildContext context) { + if (hero != null) { + return Hero( + tag: hero!, + child: image(), + ); + } + return image(); + } } diff --git a/lib/presentation/atoms/margined_expanded_atom.dart b/lib/presentation/atoms/margined_expanded_atom.dart index b5cc69308..bc1cebab1 100644 --- a/lib/presentation/atoms/margined_expanded_atom.dart +++ b/lib/presentation/atoms/margined_expanded_atom.dart @@ -1,4 +1,4 @@ -import 'package:cybear_jinni/presentation/core/theme_data.dart'; +import 'package:cybearjinni/presentation/core/theme_data.dart'; import 'package:flutter/widgets.dart'; class MarginedExpandedAtom extends StatelessWidget { diff --git a/lib/presentation/atoms/separator_atom.dart b/lib/presentation/atoms/separator_atom.dart index f33067d2d..b98669258 100644 --- a/lib/presentation/atoms/separator_atom.dart +++ b/lib/presentation/atoms/separator_atom.dart @@ -1,16 +1,38 @@ -import 'package:cybear_jinni/presentation/core/theme_data.dart'; +import 'package:cybearjinni/presentation/core/theme_data.dart'; import 'package:flutter/cupertino.dart'; class SeparatorAtom extends StatelessWidget { - const SeparatorAtom({super.key, this.multiple = 1}); + const SeparatorAtom({this.variant = SeparatorVariant.generalSpacing}); - final double multiple; + final SeparatorVariant variant; @override Widget build(BuildContext context) { + double spacing; + switch (variant) { + case SeparatorVariant.extenstionOfElement: + spacing = 2; + case SeparatorVariant.reletedElements: + spacing = 5; + case SeparatorVariant.closeWidgets: + spacing = 10; + case SeparatorVariant.generalSpacing: + spacing = AppThemeData.generalSpacing; + case SeparatorVariant.farAppart: + spacing = 45; + } return SizedBox( - height: AppThemeData.generalSpacing * multiple, - width: AppThemeData.generalSpacing, + height: spacing, + width: spacing, ); } } + +enum SeparatorVariant { + extenstionOfElement, + reletedElements, + closeWidgets, + generalSpacing, + farAppart, + ; +} diff --git a/lib/presentation/atoms/switch_atom.dart b/lib/presentation/atoms/switch_atom.dart index ee1021b8c..6b1c72ee6 100644 --- a/lib/presentation/atoms/switch_atom.dart +++ b/lib/presentation/atoms/switch_atom.dart @@ -53,6 +53,9 @@ class _SwitchAtomState extends State { @override Widget build(BuildContext context) { + final ThemeData themeData = Theme.of(context); + final ColorScheme colorScheme = themeData.colorScheme; + final Size screenSize = MediaQuery.of(context).size; final double sizeBoxWidth = screenSize.width * 0.25; @@ -74,10 +77,7 @@ class _SwitchAtomState extends State { inactiveIcon = MdiIcons.lightSwitch; } - final Color toggleColor = getToggleColor(); - - return Container( - margin: const EdgeInsets.symmetric(vertical: 5), + return SizedBox( width: sizeBoxWidth + 15, child: FlutterSwitch( width: screenSize.width * 0.25, @@ -86,23 +86,23 @@ class _SwitchAtomState extends State { value: toggleValue, borderRadius: 25.0, padding: 0.0, - activeToggleColor: const Color(0xFF2F363D), - inactiveToggleColor: Colors.deepPurple, + activeToggleColor: colorScheme.onPrimary, + inactiveToggleColor: colorScheme.onBackground, activeSwitchBorder: Border.all( - color: Theme.of(context).textTheme.bodyLarge!.color!, + color: colorScheme.onBackground, ), inactiveSwitchBorder: Border.all( - color: Theme.of(context).textTheme.bodyLarge!.color!, + color: colorScheme.onBackground, ), - activeColor: toggleColor, - inactiveColor: toggleColor, + activeColor: colorScheme.primary, + inactiveColor: colorScheme.background, activeIcon: Icon( activeIcon, - color: const Color(0xFFF8E3A1), + color: colorScheme.primary, ), inactiveIcon: Icon( inactiveIcon, - color: Theme.of(context).textTheme.bodyLarge!.color, + color: colorScheme.background, ), onToggle: onToggle, ), diff --git a/lib/presentation/atoms/text_atom.dart b/lib/presentation/atoms/text_atom.dart index 33ed51aa9..540164919 100644 --- a/lib/presentation/atoms/text_atom.dart +++ b/lib/presentation/atoms/text_atom.dart @@ -11,6 +11,7 @@ class TextAtom extends StatelessWidget { this.maxLines, this.translationArgs, this.translate = true, + this.veriant = TextVeriant.regular, }); final String text; @@ -20,15 +21,38 @@ class TextAtom extends StatelessWidget { final int? maxLines; final List? translationArgs; final bool translate; + final TextVeriant veriant; @override Widget build(BuildContext context) { + final ThemeData themeData = Theme.of(context); + final TextTheme textTheme = themeData.textTheme; + TextStyle? tempStyle = style; + + switch (veriant) { + case TextVeriant.regular: + break; + case TextVeriant.smallTitle: + tempStyle = textTheme.titleLarge; + case TextVeriant.medium: + tempStyle = textTheme.bodyMedium; + } + return Text( translate && text.isNotEmpty ? text.tr(args: translationArgs) : text, - style: style, + style: tempStyle, maxLines: maxLines, overflow: overflow, textAlign: textAlign, ); } } + +enum TextVeriant { + smallTitle, + + /// define out side, trying to deprecate + regular, + medium, + ; +} diff --git a/lib/presentation/core/ad_state.dart b/lib/presentation/core/ad_state.dart index 8b46830b5..aaa7edf5e 100644 --- a/lib/presentation/core/ad_state.dart +++ b/lib/presentation/core/ad_state.dart @@ -1,29 +1,29 @@ -import 'dart:io'; +// import 'dart:io'; -import 'package:cybear_jinni/infrastructure/core/logger.dart'; -import 'package:google_mobile_ads/google_mobile_ads.dart'; +// import 'package:cybearjinni/infrastructure/core/logger.dart'; +// import 'package:google_mobile_ads/google_mobile_ads.dart'; -class AdState { - AdState(this.initialization); +// class AdState { +// AdState(this.initialization); - Future initialization; +// Future initialization; - String get bannerAdUnitId => Platform.isAndroid - ? 'ca-app-pub-3940256099942544/6300978111' - : 'ca-app-pub-3940256099942544/2934735716'; +// String get bannerAdUnitId => Platform.isAndroid +// ? 'ca-app-pub-3940256099942544/6300978111' +// : 'ca-app-pub-3940256099942544/2934735716'; - BannerAdListener get adListener => _adListener; +// BannerAdListener get adListener => _adListener; - final BannerAdListener _adListener = AdManagerBannerAdListener( - onAdLoaded: (ad) => logger.t('Ad loaded: ${ad.adUnitId}.'), - onAdClosed: (ad) => logger.t('Ad closed: ${ad.adUnitId}.'), - onAdFailedToLoad: (ad, error) => - logger.t('Ad failed to load: ${ad.adUnitId}, $error.'), - onAdOpened: (ad) => logger.t('Ad opened: ${ad.adUnitId}.'), - onAppEvent: (ad, name, data) => - logger.t('App event: ${ad.adUnitId}, $name, $data'), - onAdImpression: (ad) => logger.t('Ad impression: ${ad.adUnitId}.'), - onAdWillDismissScreen: (ad) => - logger.t('Ad dismiss screen: ${ad.adUnitId}.'), - ); -} +// final BannerAdListener _adListener = AdManagerBannerAdListener( +// onAdLoaded: (ad) => logger.t('Ad loaded: ${ad.adUnitId}.'), +// onAdClosed: (ad) => logger.t('Ad closed: ${ad.adUnitId}.'), +// onAdFailedToLoad: (ad, error) => +// logger.t('Ad failed to load: ${ad.adUnitId}, $error.'), +// onAdOpened: (ad) => logger.t('Ad opened: ${ad.adUnitId}.'), +// onAppEvent: (ad, name, data) => +// logger.t('App event: ${ad.adUnitId}, $name, $data'), +// onAdImpression: (ad) => logger.t('Ad impression: ${ad.adUnitId}.'), +// onAdWillDismissScreen: (ad) => +// logger.t('Ad dismiss screen: ${ad.adUnitId}.'), +// ); +// } diff --git a/lib/presentation/core/app_widget.dart b/lib/presentation/core/app_widget.dart index 927eff176..833900cc4 100644 --- a/lib/presentation/core/app_widget.dart +++ b/lib/presentation/core/app_widget.dart @@ -1,70 +1,50 @@ import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/infrastructure/core/injection.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.dart'; +import 'package:cybearjinni/infrastructure/core/injection.dart'; +import 'package:cybearjinni/presentation/core/color_schemes.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; class AppWidget extends StatelessWidget { - MaterialColor createMaterialColor(Color color) { - final List strengths = [.05]; - final Map swatch = {}; - final int r = color.red; - final int g = color.green; - final int b = color.blue; + PageTransitionsTheme pageTransitionsTheme() { + const PageTransitionsBuilder transition = ZoomPageTransitionsBuilder(); - for (int i = 1; i < 10; i++) { - strengths.add(0.1 * i); - } - for (final strength in strengths) { - final double ds = 0.5 - strength; - swatch[(strength * 1000).round()] = Color.fromRGBO( - r + ((ds < 0 ? r : (255 - r)) * ds).round(), - g + ((ds < 0 ? g : (255 - g)) * ds).round(), - b + ((ds < 0 ? b : (255 - b)) * ds).round(), - 1, - ); - } - return MaterialColor(color.value, swatch); + return const PageTransitionsTheme( + builders: { + TargetPlatform.android: transition, + TargetPlatform.iOS: transition, + TargetPlatform.fuchsia: transition, + TargetPlatform.linux: transition, + TargetPlatform.macOS: transition, + TargetPlatform.windows: transition, + }, + ); } @override Widget build(BuildContext context) { + precacheImage(const AssetImage('assets/cbj_logo.png'), context); final rootRouter = getIt(); return MaterialApp.router( routerConfig: rootRouter.config( navigatorObservers: () => [AutoRouteObserver()], ), + theme: ThemeData( + useMaterial3: true, + colorScheme: lightColorScheme, + pageTransitionsTheme: pageTransitionsTheme(), + ), + darkTheme: ThemeData( + useMaterial3: true, + colorScheme: darkColorScheme, + pageTransitionsTheme: pageTransitionsTheme(), + ), title: 'CyBear Jinni App', localizationsDelegates: context.localizationDelegates, supportedLocales: context.supportedLocales, locale: context.locale, - // darkTheme: ThemeData(brightness: Brightness.dark), debugShowCheckedModeBanner: false, - theme: ThemeData( - useMaterial3: true, - primaryColor: - createMaterialColor(const Color.fromRGBO(162, 129, 162, 1.0)), - primaryColorDark: const Color(0xFF271052), - inputDecorationTheme: InputDecorationTheme( - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(8), - ), - ), - textTheme: const TextTheme( - bodyLarge: TextStyle(color: Colors.white), - bodyMedium: TextStyle(color: Colors.white70), - ), - fontFamily: 'gidole_regular', - colorScheme: ColorScheme.fromSwatch( - primarySwatch: createMaterialColor( - const Color.fromRGBO(162, 129, 162, 1.0), - ), - accentColor: Colors.yellow, - ).copyWith( - secondary: Colors.indigo, - ), - ), ); } } diff --git a/lib/presentation/core/color_schemes.dart b/lib/presentation/core/color_schemes.dart new file mode 100644 index 000000000..6410da100 --- /dev/null +++ b/lib/presentation/core/color_schemes.dart @@ -0,0 +1,69 @@ +import 'package:flutter/material.dart'; + +const lightColorScheme = ColorScheme( + brightness: Brightness.light, + primary: Color(0xFF8F4280), + onPrimary: Color(0xFFFFFFFF), + primaryContainer: Color(0xFFFFD7F1), + onPrimaryContainer: Color(0xFF3A0033), + secondary: Color(0xFF894587), + onSecondary: Color(0xFFFFFFFF), + secondaryContainer: Color(0xFFFFD6F8), + onSecondaryContainer: Color(0xFF37003A), + tertiary: Color(0xFF8B4483), + onTertiary: Color(0xFFFFFFFF), + tertiaryContainer: Color(0xFFFFD7F4), + onTertiaryContainer: Color(0xFF390036), + error: Color(0xFFBA1A1A), + errorContainer: Color(0xFFFFDAD6), + onError: Color(0xFFFFFFFF), + onErrorContainer: Color(0xFF410002), + background: Color(0xFFF8FDFF), + onBackground: Color(0xFF001F25), + surface: Color(0xFFF8FDFF), + onSurface: Color(0xFF001F25), + surfaceVariant: Color(0xFFEFDEE6), + onSurfaceVariant: Color(0xFF4F444A), + outline: Color(0xFF80747B), + onInverseSurface: Color(0xFFD6F6FF), + inverseSurface: Color(0xFF00363F), + inversePrimary: Color(0xFFFFACE9), + shadow: Color(0xFF000000), + surfaceTint: Color(0xFF8F4280), + outlineVariant: Color(0xFFD2C2CA), + scrim: Color(0xFF000000), +); + +const darkColorScheme = ColorScheme( + brightness: Brightness.dark, + primary: Color(0xFFFFACE9), + onPrimary: Color(0xFF58104E), + primaryContainer: Color(0xFF732A66), + onPrimaryContainer: Color(0xFFFFD7F1), + secondary: Color(0xFFFCABF6), + onSecondary: Color(0xFF531355), + secondaryContainer: Color(0xFF6E2C6E), + onSecondaryContainer: Color(0xFFFFD6F8), + tertiary: Color(0xFFFFABF0), + onTertiary: Color(0xFF551251), + tertiaryContainer: Color(0xFF702C69), + onTertiaryContainer: Color(0xFFFFD7F4), + error: Color(0xFFFFB4AB), + errorContainer: Color(0xFF93000A), + onError: Color(0xFF690005), + onErrorContainer: Color(0xFFFFDAD6), + background: Color(0xFF001F25), + onBackground: Color(0xFFA6EEFF), + surface: Color(0xFF001F25), + onSurface: Color(0xFFA6EEFF), + surfaceVariant: Color(0xFF4F444A), + onSurfaceVariant: Color(0xFFD2C2CA), + outline: Color(0xFF9B8D94), + onInverseSurface: Color(0xFF001F25), + inverseSurface: Color(0xFFA6EEFF), + inversePrimary: Color(0xFF8F4280), + shadow: Color(0xFF000000), + surfaceTint: Color(0xFFFFACE9), + outlineVariant: Color(0xFF4F444A), + scrim: Color(0xFF000000), +); diff --git a/lib/presentation/core/entities_utils.dart b/lib/presentation/core/entities_utils.dart new file mode 100644 index 000000000..72cfa17f4 --- /dev/null +++ b/lib/presentation/core/entities_utils.dart @@ -0,0 +1,125 @@ +import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; + +class EntitiesUtils { + static IconData iconOfDeviceType(EntityTypes deviceType) { + switch (deviceType) { + case EntityTypes.AirConditioner: + // TODO: Handle this case. + break; + case EntityTypes.babyMonitor: + // TODO: Handle this case. + break; + case EntityTypes.bed: + return Icons.bed; + case EntityTypes.blinds: + return FontAwesomeIcons.alignJustify; + case EntityTypes.boiler: + return FontAwesomeIcons.temperatureThreeQuarters; + case EntityTypes.browserApp: + // TODO: Handle this case. + break; + case EntityTypes.button: + return Icons.smart_button; + case EntityTypes.buttonWithLight: + // TODO: Handle this case. + break; + case EntityTypes.coffeeMachine: + // TODO: Handle this case. + break; + case EntityTypes.computerApp: + return Icons.computer; + case EntityTypes.dishwasher: + // TODO: Handle this case. + break; + case EntityTypes.emptyEntity: + // TODO: Handle this case. + break; + case EntityTypes.hub: + // TODO: Handle this case. + break; + case EntityTypes.humiditySensor: + // TODO: Handle this case. + break; + case EntityTypes.kettle: + // TODO: Handle this case. + break; + case EntityTypes.lightSensor: + return Icons.sensors; + case EntityTypes.light: + case EntityTypes.dimmableLight: + case EntityTypes.rgbLights: + case EntityTypes.rgbcctLights: + case EntityTypes.rgbwLights: + case EntityTypes.cctLight: + return FontAwesomeIcons.lightbulb; + case EntityTypes.microphone: + return Icons.mic; + case EntityTypes.motionSensor: + // TODO: Handle this case. + break; + case EntityTypes.oven: + // TODO: Handle this case. + break; + case EntityTypes.oxygenSensor: + return Icons.sensors; + case EntityTypes.phoneApp: + return Icons.phone; + case EntityTypes.pingEntity: + // TODO: Handle this case. + break; + case EntityTypes.playerEntity: + // TODO: Handle this case. + break; + case EntityTypes.printer: + case EntityTypes.scanner: + case EntityTypes.printerWithScanner: + return Icons.print; + case EntityTypes.refrigerator: + // TODO: Handle this case. + break; + case EntityTypes.routerEntity: + return Icons.router; + case EntityTypes.securityCamera: + return Icons.camera; + case EntityTypes.smartComputer: + return Icons.computer; + case EntityTypes.smartPlug: + return MdiIcons.powerSocketAu; + case EntityTypes.smartSpeakers: + return Icons.speaker; + case EntityTypes.smartTV: + return Icons.tv; + case EntityTypes.smartTypeNotSupported: + // TODO: Handle this case. + break; + case EntityTypes.smartWatch: + return Icons.watch; + case EntityTypes.smartWaterBottle: + // TODO: Handle this case. + break; + case EntityTypes.smokeDetector: + case EntityTypes.smokeSensor: + case EntityTypes.soundSensor: + return Icons.sensors; + case EntityTypes.switch_: + return MdiIcons.lightSwitch; + case EntityTypes.teapot: + // TODO: Handle this case. + break; + case EntityTypes.temperatureSensor: + return MdiIcons.temperatureCelsius; + case EntityTypes.toaster: + return MdiIcons.toaster; + case EntityTypes.vacuumCleaner: + return MdiIcons.vacuum; + case EntityTypes.voiceAssistant: + return MdiIcons.voicemail; + case EntityTypes.washingMachine: + return MdiIcons.washingMachine; + } + return Icons.question_mark; + } +} diff --git a/lib/presentation/core/routes/app_router.dart b/lib/presentation/core/routes/app_router.dart index ce045d24d..64931b528 100644 --- a/lib/presentation/core/routes/app_router.dart +++ b/lib/presentation/core/routes/app_router.dart @@ -1,5 +1,5 @@ import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.gr.dart'; @AutoRouterConfig() class AppRouter extends $AppRouter { @@ -32,8 +32,8 @@ class AppRouter extends $AppRouter { AutoRoute(page: ScanForNewCBJCompsRoute.page), AutoRoute(page: ConfigureNewCbjCompRoute.page), AutoRoute(page: ComputerConnectionCheckRoute.page), - AutoRoute(page: DevicesInNetworkRoute.page), - AutoRoute(page: DevicesInRoomRoute.page), + AutoRoute(page: EntitiesInNetworkRoute.page), + AutoRoute(page: EntitiesInRoomRoute.page), // Pages from packages AutoRoute(page: SmartCameraContainerRoute.page), diff --git a/lib/presentation/core/snack_bar_service.dart b/lib/presentation/core/snack_bar_service.dart index c3d5bf598..310cd680c 100644 --- a/lib/presentation/core/snack_bar_service.dart +++ b/lib/presentation/core/snack_bar_service.dart @@ -1,4 +1,4 @@ -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; import 'package:flutter/material.dart'; class SnackBarService { diff --git a/lib/presentation/molecules/bottom_navigation_bar_molecule.dart b/lib/presentation/molecules/bottom_navigation_bar_molecule.dart index 00f6a6b0e..def37ed1f 100644 --- a/lib/presentation/molecules/bottom_navigation_bar_molecule.dart +++ b/lib/presentation/molecules/bottom_navigation_bar_molecule.dart @@ -1,4 +1,4 @@ -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; import 'package:flutter/material.dart'; class BottomNavigationBarMolecule extends StatelessWidget { diff --git a/lib/presentation/molecules/device_by_type_molecule.dart b/lib/presentation/molecules/device_by_type_molecule.dart index 5aa3a7399..7cc07e4f8 100644 --- a/lib/presentation/molecules/device_by_type_molecule.dart +++ b/lib/presentation/molecules/device_by_type_molecule.dart @@ -11,8 +11,8 @@ import 'package:cbj_integrations_controller/infrastructure/generic_entities/gene import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_smart_plug_entity/generic_smart_plug_entity.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_smart_tv_entity/generic_smart_tv_entity.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_switch_entity/generic_switch_entity.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/molecules/molecules.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; import 'package:flutter/material.dart'; class DeviceByTypeMolecule extends StatelessWidget { @@ -48,7 +48,7 @@ class DeviceByTypeMolecule extends StatelessWidget { return DimmableLightMolecule(entity as GenericDimmableLightDE); default: - return TextAtom('Device type not supported ${type?.name ?? 'null'}'); + return TextAtom('Entity type is unsupported ${type?.name ?? 'null'}'); } } } diff --git a/lib/presentation/molecules/device_name_row.dart b/lib/presentation/molecules/device_name_row.dart new file mode 100644 index 000000000..bf383ef47 --- /dev/null +++ b/lib/presentation/molecules/device_name_row.dart @@ -0,0 +1,25 @@ +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; + +class DeviceNameRow extends StatelessWidget { + const DeviceNameRow(this.name, this.second); + final String name; + final Widget second; + + @override + Widget build(BuildContext context) { + return Row( + children: [ + Expanded( + child: TextAtom( + name, + overflow: TextOverflow.ellipsis, + maxLines: 1, + ), + ), + second, + ], + ); + } +} diff --git a/lib/presentation/molecules/devices/blind_molecule.dart b/lib/presentation/molecules/devices/blind_molecule.dart index b8cdce64a..7ac630610 100644 --- a/lib/presentation/molecules/devices/blind_molecule.dart +++ b/lib/presentation/molecules/devices/blind_molecule.dart @@ -4,8 +4,9 @@ import 'package:another_flushbar/flushbar_helper.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/entity_type_utils.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_blinds_entity/generic_blinds_entity.dart'; -import 'package:cybear_jinni/domain/connections_service.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/domain/connections_service.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -88,6 +89,9 @@ class _BlindMoleculeState extends State { final deviceState = widget.entity.entityStateGRPC.getOrCrash(); final deviceAction = widget.entity.blindsSwitchState!.getOrCrash(); + final ThemeData themeData = Theme.of(context); + final ColorScheme colorScheme = themeData.colorScheme; + // bool toggleValue = false; // Color toggleColor = Colors.blueGrey; @@ -102,123 +106,112 @@ class _BlindMoleculeState extends State { } } - return Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const SizedBox( - width: 10, - ), - TextButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( - Colors.brown, - ), - side: MaterialStateProperty.all( - BorderSide.lerp( - const BorderSide(color: Colors.white60), - const BorderSide(color: Colors.white60), - 22, - ), + return DeviceNameRow( + widget.entity.cbjEntityName.getOrCrash()!, + Row( + children: [ + TextButton( + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all( + colorScheme.surface, + ), + side: MaterialStateProperty.all( + BorderSide.lerp( + const BorderSide(color: Colors.white60), + const BorderSide(color: Colors.white60), + 22, ), ), - onPressed: () { - _moveDownAllBlinds( - [widget.entity.cbjDeviceVendor.getOrCrash()], - ); - }, - child: Tab( - icon: FaIcon( - FontAwesomeIcons.arrowDown, + ), + onPressed: () { + _moveDownAllBlinds( + [widget.entity.cbjDeviceVendor.getOrCrash()], + ); + }, + child: Tab( + icon: FaIcon( + FontAwesomeIcons.arrowDown, + color: Theme.of(context).textTheme.bodyLarge!.color, + ), + child: TextAtom( + 'Down', + style: TextStyle( color: Theme.of(context).textTheme.bodyLarge!.color, - ), - child: TextAtom( - 'Down', - style: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - fontSize: 16, - ), + fontSize: 16, ), ), ), - const SizedBox( - width: 10, - ), - TextButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( - Colors.grey, - ), - side: MaterialStateProperty.all( - BorderSide.lerp( - const BorderSide(color: Colors.white60), - const BorderSide(color: Colors.white60), - 22, - ), + ), + const SizedBox( + width: 10, + ), + TextButton( + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all( + colorScheme.surface, + ), + side: MaterialStateProperty.all( + BorderSide.lerp( + const BorderSide(color: Colors.white60), + const BorderSide(color: Colors.white60), + 22, ), ), - onPressed: () { - _stopAllBlinds( - [widget.entity.cbjDeviceVendor.getOrCrash()], - ); - }, - child: Tab( - icon: FaIcon( - FontAwesomeIcons.solidHand, + ), + onPressed: () { + _stopAllBlinds( + [widget.entity.cbjDeviceVendor.getOrCrash()], + ); + }, + child: Tab( + icon: FaIcon( + FontAwesomeIcons.solidHand, + color: Theme.of(context).textTheme.bodyLarge!.color, + ), + child: TextAtom( + 'Stop', + style: TextStyle( color: Theme.of(context).textTheme.bodyLarge!.color, - ), - child: TextAtom( - 'Stop', - style: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - fontSize: 16, - ), + fontSize: 16, ), ), ), - const SizedBox( - width: 10, - ), - TextButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( - Colors.amber, - ), - side: MaterialStateProperty.all( - BorderSide.lerp( - const BorderSide(color: Colors.white60), - const BorderSide(color: Colors.white60), - 22, - ), + ), + const SizedBox( + width: 10, + ), + TextButton( + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all( + colorScheme.surface, + ), + side: MaterialStateProperty.all( + BorderSide.lerp( + const BorderSide(color: Colors.white60), + const BorderSide(color: Colors.white60), + 22, ), ), - onPressed: () { - _moveUpAllBlinds(); - }, - child: Tab( - icon: FaIcon( - FontAwesomeIcons.arrowUp, + ), + onPressed: () { + _moveUpAllBlinds(); + }, + child: Tab( + icon: FaIcon( + FontAwesomeIcons.arrowUp, + color: Theme.of(context).textTheme.bodyLarge!.color, + ), + child: TextAtom( + 'Up', + style: TextStyle( color: Theme.of(context).textTheme.bodyLarge!.color, - ), - child: TextAtom( - 'Up', - style: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - fontSize: 16, - ), + fontSize: 16, ), ), ), - const SizedBox( - width: 10, - ), - ], - ), - const SizedBox( - height: 20, - ), - ], + ), + ], + ), ); } } diff --git a/lib/presentation/molecules/devices/blinds_card_molecule.dart b/lib/presentation/molecules/devices/blinds_card_molecule.dart index aa24d62cc..21c26ab5a 100644 --- a/lib/presentation/molecules/devices/blinds_card_molecule.dart +++ b/lib/presentation/molecules/devices/blinds_card_molecule.dart @@ -1,6 +1,6 @@ import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_light_entity/generic_light_entity.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; import 'package:flutter/material.dart'; class BlindsCardMolecule extends StatelessWidget { diff --git a/lib/presentation/molecules/devices/boiler_molecule.dart b/lib/presentation/molecules/devices/boiler_molecule.dart index fd53998f3..f59c75aa4 100644 --- a/lib/presentation/molecules/devices/boiler_molecule.dart +++ b/lib/presentation/molecules/devices/boiler_molecule.dart @@ -4,8 +4,9 @@ import 'package:another_flushbar/flushbar_helper.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/entity_type_utils.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_boiler_entity/generic_boiler_entity.dart'; -import 'package:cybear_jinni/domain/connections_service.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/domain/connections_service.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; @@ -73,11 +74,14 @@ class _BoilerMoleculeState extends State { @override Widget build(BuildContext context) { - return SwitchAtom( - variant: SwitchVariant.boiler, - onToggle: _onChange, - action: widget.entity.boilerSwitchState.action, - state: widget.entity.entityStateGRPC.state, + return DeviceNameRow( + widget.entity.cbjEntityName.getOrCrash()!, + SwitchAtom( + variant: SwitchVariant.boiler, + onToggle: _onChange, + action: widget.entity.boilerSwitchState.action, + state: widget.entity.entityStateGRPC.state, + ), ); } } diff --git a/lib/presentation/molecules/devices/dimmable_light_molecule.dart b/lib/presentation/molecules/devices/dimmable_light_molecule.dart index 87012b12d..e023fd35e 100644 --- a/lib/presentation/molecules/devices/dimmable_light_molecule.dart +++ b/lib/presentation/molecules/devices/dimmable_light_molecule.dart @@ -1,6 +1,12 @@ +import 'dart:collection'; + +import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/entity_type_utils.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_dimmable_light_entity/generic_dimmable_light_entity.dart'; -import 'package:cybear_jinni/domain/device/i_device_repository.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/domain/connections_service.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -18,92 +24,110 @@ class DimmableLightMolecule extends StatefulWidget { class _DimmableLightMoleculeState extends State { double brightness = 100; - Future _onChange(bool value) async { - if (value) { - await IDeviceRepository.instance.turnOnDevices( - devicesId: [widget.entity.cbjDeviceVendor.getOrCrash()], - ); - } else { - await IDeviceRepository.instance.turnOffDevices( - devicesId: [widget.entity.cbjDeviceVendor.getOrCrash()], - ); - } + Future _changeBrightness(double value) async { + setState(() { + brightness = value; + }); + + final HashMap hashValue = + HashMap() + ..addEntries([ + MapEntry(ActionValues.brightness, value.round().toString()), + ]); + + setEntityState( + EntityProperties.lightBrightness, + EntityActions.actionNotSupported, + value: hashValue, + ); } - Future _changeBrightness(double value) async { - brightness = value; + void _onChange(bool value) { + setEntityState( + EntityProperties.lightSwitchState, + value ? EntityActions.on : EntityActions.off, + ); + } - IDeviceRepository.instance.changeBrightnessDevices( - devicesId: [widget.entity.cbjDeviceVendor.getOrCrash()], - brightnessToChange: value.round(), + void setEntityState( + EntityProperties property, + EntityActions action, { + HashMap? value, + }) { + final VendorsAndServices? vendor = + widget.entity.cbjDeviceVendor.vendorsAndServices; + if (vendor == null) { + return; + } + + final HashMap> uniqueIdByVendor = + HashMap(); + uniqueIdByVendor.addEntries( + [ + MapEntry( + vendor, + HashSet() + ..addAll([widget.entity.deviceCbjUniqueId.getOrCrash()]), + ), + ], + ); + ConnectionsService.instance.setEntityState( + uniqueIdByVendor: uniqueIdByVendor, + property: property, + actionType: action, + value: value, ); } @override Widget build(BuildContext context) { - return ColoredBox( - color: Colors.white, - child: Column( - children: [ - Container( - margin: const EdgeInsets.symmetric(horizontal: 10), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Flexible( - child: TextAtom( - widget.entity.cbjEntityName.getOrCrash()!, - style: const TextStyle( - overflow: TextOverflow.clip, - fontSize: 20.0, - color: Colors.black, - ), - ), - ), - SwitchAtom( - variant: SwitchVariant.light, - action: widget.entity.lightSwitchState.action, - state: widget.entity.entityStateGRPC.state, - onToggle: _onChange, - ), - ], - ), - ), - const SizedBox( - height: 3, + final ThemeData themeData = Theme.of(context); + final ColorScheme colorScheme = themeData.colorScheme; + + return Column( + children: [ + DeviceNameRow( + widget.entity.cbjEntityName.getOrCrash()!, + SwitchAtom( + variant: SwitchVariant.light, + action: widget.entity.lightSwitchState.action, + state: widget.entity.entityStateGRPC.state, + onToggle: _onChange, ), - Container( - padding: const EdgeInsets.symmetric(horizontal: 10), - child: Row( - children: [ - const FaIcon( - FontAwesomeIcons.solidSun, - color: Colors.blueGrey, - ), - Expanded( - child: Slider( - thumbColor: Colors.white, - activeColor: Colors.orangeAccent.shade100, - inactiveColor: Colors.grey, - value: brightness, - divisions: 100, - min: 1, - max: 100, - onChanged: _changeBrightness, - ), + ), + const SizedBox( + height: 3, + ), + Container( + padding: const EdgeInsets.symmetric(horizontal: 10), + child: Row( + children: [ + const FaIcon( + FontAwesomeIcons.solidSun, + ), + Expanded( + child: Slider( + thumbColor: colorScheme.onBackground, + activeColor: colorScheme.tertiary, + inactiveColor: colorScheme.outline, + value: brightness, + divisions: 100, + min: 1, + max: 100, + onChanged: _changeBrightness, ), - SizedBox( - width: 45, - child: TextAtom( - '${brightness.round()}%', - style: const TextStyle(color: Colors.black), - ), + ), + SizedBox( + width: 45, + child: TextAtom( + '${brightness.round()}%', + style: const TextStyle(color: Colors.black), ), - ], - ), + ), + ], ), - ], - ), + ), + ], ); } } diff --git a/lib/presentation/molecules/devices/light_card_molecule.dart b/lib/presentation/molecules/devices/light_card_molecule.dart index d9bd62e8f..abc6bfd72 100644 --- a/lib/presentation/molecules/devices/light_card_molecule.dart +++ b/lib/presentation/molecules/devices/light_card_molecule.dart @@ -2,8 +2,8 @@ import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/pr import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/value_objects_core.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_light_entity/generic_light_entity.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_light_entity/generic_light_value_objects.dart'; -import 'package:cybear_jinni/domain/device/i_device_repository.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/domain/device/i_device_repository.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; import 'package:flutter/material.dart'; class LightCardMolecule extends StatelessWidget { diff --git a/lib/presentation/molecules/devices/light_molecule.dart b/lib/presentation/molecules/devices/light_molecule.dart index 7c4d6975c..1ccc9e54b 100644 --- a/lib/presentation/molecules/devices/light_molecule.dart +++ b/lib/presentation/molecules/devices/light_molecule.dart @@ -3,8 +3,9 @@ import 'dart:collection'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/entity_type_utils.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_light_entity/generic_light_entity.dart'; -import 'package:cybear_jinni/domain/connections_service.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/domain/connections_service.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; import 'package:flutter/material.dart'; /// Show light toggles in a container with the background color from smart room @@ -44,11 +45,14 @@ class LightMolecule extends StatelessWidget { @override Widget build(BuildContext context) { - return SwitchAtom( - variant: SwitchVariant.light, - onToggle: _onChange, - action: entity.lightSwitchState.action, - state: entity.entityStateGRPC.state, + return DeviceNameRow( + entity.cbjEntityName.getOrCrash()!, + SwitchAtom( + variant: SwitchVariant.light, + onToggle: _onChange, + action: entity.lightSwitchState.action, + state: entity.entityStateGRPC.state, + ), ); } } diff --git a/lib/presentation/molecules/devices/printer_molecule.dart b/lib/presentation/molecules/devices/printer_molecule.dart index fce4a0114..e1eeb72b0 100644 --- a/lib/presentation/molecules/devices/printer_molecule.dart +++ b/lib/presentation/molecules/devices/printer_molecule.dart @@ -1,6 +1,7 @@ import 'package:another_flushbar/flushbar_helper.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_printer_entity/generic_printer_entity.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -32,48 +33,38 @@ class _PrinterMoleculeState extends State { @override Widget build(BuildContext context) { - return Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - TextButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( - Colors.grey, - ), - side: MaterialStateProperty.all( - BorderSide.lerp( - const BorderSide(color: Colors.white60), - const BorderSide(color: Colors.white60), - 22, - ), - ), - ), - onPressed: () { - _openPrintersWebPage(); - }, - child: Tab( - icon: FaIcon( - FontAwesomeIcons.link, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - child: TextAtom( - "Open Printer's Web Page", - style: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - fontSize: 16, - ), - ), - ), + return DeviceNameRow( + widget.entity.cbjEntityName.getOrCrash()!, + TextButton( + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all( + Colors.grey, + ), + side: MaterialStateProperty.all( + BorderSide.lerp( + const BorderSide(color: Colors.white60), + const BorderSide(color: Colors.white60), + 22, ), - ], + ), ), - const SizedBox( - height: 20, + onPressed: () { + _openPrintersWebPage(); + }, + child: Tab( + icon: FaIcon( + FontAwesomeIcons.link, + color: Theme.of(context).textTheme.bodyLarge!.color, + ), + child: TextAtom( + "Open Printer's Web Page", + style: TextStyle( + color: Theme.of(context).textTheme.bodyLarge!.color, + fontSize: 16, + ), + ), ), - ], + ), ); } } diff --git a/lib/presentation/molecules/devices/rgb_light_molecule.dart b/lib/presentation/molecules/devices/rgb_light_molecule.dart index 02e13bbe3..68bcc93e7 100644 --- a/lib/presentation/molecules/devices/rgb_light_molecule.dart +++ b/lib/presentation/molecules/devices/rgb_light_molecule.dart @@ -4,9 +4,10 @@ import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/pr import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/entity_type_utils.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_rgbw_light_entity/generic_rgbw_light_entity.dart'; -import 'package:cybear_jinni/domain/connections_service.dart'; -import 'package:cybear_jinni/domain/device/i_device_repository.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/domain/connections_service.dart'; +import 'package:cybearjinni/domain/device/i_device_repository.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; import 'package:flutter/material.dart'; import 'package:flutter_colorpicker/flutter_colorpicker.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -106,70 +107,48 @@ class _RgbwLightMoleculeState extends State { @override Widget build(BuildContext context) { - return ColoredBox( - color: Colors.white, - child: Column( - children: [ - Container( - margin: const EdgeInsets.symmetric(horizontal: 10), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Flexible( - child: TextAtom( - widget.entity.cbjEntityName.getOrCrash()!, - style: const TextStyle( - overflow: TextOverflow.clip, - fontSize: 20.0, - color: Colors.black, - ), - ), - ), - SwitchAtom( - variant: SwitchVariant.light, - onToggle: _onChange, - action: widget.entity.lightSwitchState.action, - state: widget.entity.entityStateGRPC.state, - ), - ], - ), - ), - const SizedBox( - height: 3, + final ThemeData themeData = Theme.of(context); + final ColorScheme colorScheme = themeData.colorScheme; + final TextTheme textTheme = themeData.textTheme; + + return Column( + children: [ + DeviceNameRow( + widget.entity.cbjEntityName.getOrCrash()!, + SwitchAtom( + variant: SwitchVariant.light, + onToggle: _onChange, + action: widget.entity.lightSwitchState.action, + state: widget.entity.entityStateGRPC.state, ), - LightColorMods(deviceEntity: widget.entity), - Container( - padding: const EdgeInsets.symmetric(horizontal: 10), - child: Row( - children: [ - const FaIcon( - FontAwesomeIcons.solidSun, - color: Colors.blueGrey, - ), - Expanded( - child: Slider( - thumbColor: Colors.white, - activeColor: Colors.orangeAccent.shade100, - inactiveColor: Colors.grey, - value: brightness, - divisions: 100, - min: 1, - max: 100, - onChanged: _changeBrightness, - ), - ), - SizedBox( - width: 45, - child: TextAtom( - '${brightness.round()}%', - style: const TextStyle(color: Colors.black), - ), - ), - ], + ), + const SeparatorAtom(variant: SeparatorVariant.reletedElements), + LightColorMods(deviceEntity: widget.entity), + Row( + children: [ + const FaIcon(FontAwesomeIcons.solidSun), + Expanded( + child: Slider( + thumbColor: colorScheme.onBackground, + activeColor: colorScheme.tertiary, + inactiveColor: colorScheme.outline, + value: brightness, + divisions: 100, + min: 1, + max: 100, + onChanged: _changeBrightness, + ), ), - ), - ], - ), + SizedBox( + width: 45, + child: TextAtom( + '${brightness.round()}%', + style: textTheme.bodyMedium, + ), + ), + ], + ), + ], ); } } @@ -305,41 +284,45 @@ class _LightColorMods extends State { } Widget lightModBarFocus() { + final ThemeData themeData = Theme.of(context); + final ColorScheme colorScheme = themeData.colorScheme; + return Column( children: [ colorModeWidget, - Container( - color: Colors.white, - margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 5), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - TextButton( - child: TextAtom( - 'White', - style: TextStyle( - color: (colorModFocus == 0) ? Colors.red : Colors.grey, - fontSize: 18, - ), + const SeparatorAtom(variant: SeparatorVariant.reletedElements), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + OutlinedButton( + child: TextAtom( + 'White', + style: TextStyle( + color: (colorModFocus == 0) + ? colorScheme.primary + : colorScheme.onBackground, + fontSize: 18, ), - onPressed: () { - _showWhiteMode(); - }, ), - TextButton( - child: TextAtom( - 'Color', - style: TextStyle( - color: (colorModFocus == 1) ? Colors.red : Colors.grey, - fontSize: 18, - ), + onPressed: () { + _showWhiteMode(); + }, + ), + OutlinedButton( + child: TextAtom( + 'Color', + style: TextStyle( + color: (colorModFocus == 1) + ? colorScheme.primary + : colorScheme.onBackground, + fontSize: 18, ), - onPressed: () { - _showColorMode(); - }, ), - ], - ), + onPressed: () { + _showColorMode(); + }, + ), + ], ), ], ); diff --git a/lib/presentation/molecules/devices/smart_computer_molecule.dart b/lib/presentation/molecules/devices/smart_computer_molecule.dart index 9f91fe702..20b9c3558 100644 --- a/lib/presentation/molecules/devices/smart_computer_molecule.dart +++ b/lib/presentation/molecules/devices/smart_computer_molecule.dart @@ -1,7 +1,8 @@ import 'package:another_flushbar/flushbar_helper.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_smart_computer_entity/generic_smart_computer_entity.dart'; -import 'package:cybear_jinni/domain/device/i_device_repository.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/domain/device/i_device_repository.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -10,7 +11,7 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart'; class SmartComputerMolecule extends StatefulWidget { const SmartComputerMolecule(this.entity); - final GenericSmartComputerDE? entity; + final GenericSmartComputerDE entity; @override State createState() => _SmartComputerMoleculeState(); @@ -36,92 +37,87 @@ class _SmartComputerMoleculeState extends State { } void suspendComputer(BuildContext context) { - final String deviceId = widget.entity!.getCbjDeviceId; + final String deviceId = widget.entity.getCbjDeviceId; _suspendAllSmartComputers([deviceId]); } void shutdownComputer(BuildContext context) { - final String deviceId = widget.entity!.getCbjDeviceId; + final String deviceId = widget.entity.getCbjDeviceId; _shutdownAllSmartComputers([deviceId]); } @override Widget build(BuildContext context) { - return Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - TextButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( - Colors.grey, - ), - side: MaterialStateProperty.all( - BorderSide.lerp( - const BorderSide(color: Colors.white60), - const BorderSide(color: Colors.white60), - 22, - ), + return DeviceNameRow( + widget.entity.cbjEntityName.getOrCrash()!, + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + TextButton( + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all( + Colors.grey, + ), + side: MaterialStateProperty.all( + BorderSide.lerp( + const BorderSide(color: Colors.white60), + const BorderSide(color: Colors.white60), + 22, ), ), - onPressed: () { - suspendComputer(context); - }, - child: Tab( - icon: FaIcon( - FontAwesomeIcons.moon, + ), + onPressed: () { + suspendComputer(context); + }, + child: Tab( + icon: FaIcon( + FontAwesomeIcons.moon, + color: Theme.of(context).textTheme.bodyLarge!.color, + ), + child: TextAtom( + 'Sleep', + style: TextStyle( color: Theme.of(context).textTheme.bodyLarge!.color, - ), - child: TextAtom( - 'Sleep', - style: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - fontSize: 16, - ), + fontSize: 16, ), ), ), - const SizedBox( - width: 10, - ), - TextButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( - Colors.grey, - ), - side: MaterialStateProperty.all( - BorderSide.lerp( - const BorderSide(color: Colors.white60), - const BorderSide(color: Colors.white60), - 22, - ), + ), + const SizedBox( + width: 10, + ), + TextButton( + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all( + Colors.grey, + ), + side: MaterialStateProperty.all( + BorderSide.lerp( + const BorderSide(color: Colors.white60), + const BorderSide(color: Colors.white60), + 22, ), ), - onPressed: () { - shutdownComputer(context); - }, - child: Tab( - icon: FaIcon( - FontAwesomeIcons.powerOff, + ), + onPressed: () { + shutdownComputer(context); + }, + child: Tab( + icon: FaIcon( + FontAwesomeIcons.powerOff, + color: Theme.of(context).textTheme.bodyLarge!.color, + ), + child: TextAtom( + 'Shutdown', + style: TextStyle( color: Theme.of(context).textTheme.bodyLarge!.color, - ), - child: TextAtom( - 'Shutdown', - style: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - fontSize: 16, - ), + fontSize: 16, ), ), ), - ], - ), - const SizedBox( - height: 20, - ), - ], + ), + ], + ), ); } } diff --git a/lib/presentation/molecules/devices/smart_light_molecule.dart b/lib/presentation/molecules/devices/smart_light_molecule.dart deleted file mode 100644 index 8be8719b0..000000000 --- a/lib/presentation/molecules/devices/smart_light_molecule.dart +++ /dev/null @@ -1,153 +0,0 @@ -import 'dart:async'; - -import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/entity_type_utils.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_light_entity/generic_light_entity.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_light_entity/generic_light_value_objects.dart'; -import 'package:cybear_jinni/infrastructure/core/logger.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_switch/flutter_switch.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; - -// TODO: Check if duplicate of LightMolecule -class SmartLightMolecule extends StatefulWidget { - const SmartLightMolecule(this.entity); - - final GenericLightDE entity; - - @override - State createState() { - return _SmartLightPage(); - } -} - -class _SmartLightPage extends State { - bool _switchState = false; - GenericLightDE? _light; - bool _isLoading = true; - - @override - void initState() { - super.initState(); - _light = widget.entity; - getAndUpdateState(); - - WidgetsBinding.instance - .addObserver(LifecycleEventHandler(resumeCallBack: getAndUpdateState)); - } - - Future getAndUpdateState() async { - try { - final bool stateValue = await getLightAction(); - if (mounted) { - _isLoading = false; - setState(() { - _switchState = stateValue; - }); - } - } catch (exception) { - logger.e('Error when updating state after resume\n$exception'); - } - } - - // Send request to light to retrieve his state on or off - Future getLightAction() async { - return _switchState = EntityUtils.stringToDeviceAction( - _light!.lightSwitchState.getOrCrash(), - ) == - EntityActions.on; - } - - Future _onChange(bool value) async { - logger.t('OnChange $value'); - _light?.lightSwitchState = GenericLightSwitchState( - EntityUtils.deviceActionToString( - value ? EntityActions.on : EntityActions.off, - ), - ); - if (mounted) { - setState(() { - _switchState = value; - }); - } - } - - @override - Widget build(BuildContext context) { - final Size screenSize = MediaQuery.of(context).size; - return Column( - children: [ - TextAtom( - _light!.cbjEntityName.getOrCrash()!, // Show light name - style: TextStyle( - fontSize: 19.0, - color: Theme.of(context).textTheme.bodyMedium!.color, - ), - ), - const SizedBox( - height: 3, - ), - if (_isLoading) - const Center(child: CircularProgressIndicatorAtom()) - else - FlutterSwitch( - width: screenSize.width * 0.25, - height: screenSize.height * 0.065, - toggleSize: screenSize.height * 0.065, - value: _switchState, - borderRadius: 25.0, - padding: 0.0, - activeToggleColor: const Color(0xFF2F363D), - inactiveToggleColor: Theme.of(context).primaryColor, - activeSwitchBorder: Border.all( - color: Theme.of(context).textTheme.bodyLarge!.color!, - ), - inactiveSwitchBorder: Border.all( - color: Theme.of(context).textTheme.bodyLarge!.color!, - ), - activeColor: const Color(0xFFFFDF5D), - inactiveColor: Theme.of(context).primaryColorDark, - activeIcon: const Icon( - FontAwesomeIcons.solidLightbulb, - color: Color(0xFFF8E3A1), - ), - inactiveIcon: Icon( - FontAwesomeIcons.lightbulb, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - onToggle: (bool value) => _onChange(value), - ), - ], - ); - } -} - -class LifecycleEventHandler extends WidgetsBindingObserver { - LifecycleEventHandler({ - this.resumeCallBack, - this.suspendingCallBack, - }); - - final AsyncCallback? resumeCallBack; - final AsyncCallback? suspendingCallBack; - - @override - Future didChangeAppLifecycleState(AppLifecycleState state) async { - switch (state) { - case AppLifecycleState.resumed: - if (resumeCallBack != null) { - await resumeCallBack!(); - } - case AppLifecycleState.inactive: - case AppLifecycleState.paused: - case AppLifecycleState.detached: - if (suspendingCallBack != null) { - await suspendingCallBack!(); - } - case AppLifecycleState.hidden: - break; - } - } -} diff --git a/lib/presentation/molecules/devices/smart_plug_molecule.dart b/lib/presentation/molecules/devices/smart_plug_molecule.dart index 597ee5cbf..d73b43df1 100644 --- a/lib/presentation/molecules/devices/smart_plug_molecule.dart +++ b/lib/presentation/molecules/devices/smart_plug_molecule.dart @@ -4,8 +4,9 @@ import 'dart:collection'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/entity_type_utils.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_smart_plug_entity/generic_smart_plug_entity.dart'; -import 'package:cybear_jinni/domain/connections_service.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/domain/connections_service.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; import 'package:flutter/material.dart'; /// Show smartPlug toggles in a container with the background color from smart room @@ -54,11 +55,14 @@ class _SmartPlugsMoleculeState extends State { @override Widget build(BuildContext context) { - return SwitchAtom( - variant: SwitchVariant.smartPlug, - onToggle: _changeAction, - action: widget.entity.smartPlugState.action, - state: widget.entity.entityStateGRPC.state, + return DeviceNameRow( + widget.entity.cbjEntityName.getOrCrash()!, + SwitchAtom( + variant: SwitchVariant.smartPlug, + onToggle: _changeAction, + action: widget.entity.smartPlugState.action, + state: widget.entity.entityStateGRPC.state, + ), ); } } diff --git a/lib/presentation/molecules/devices/smart_tv_molecule.dart b/lib/presentation/molecules/devices/smart_tv_molecule.dart index f84300f34..2849f7def 100644 --- a/lib/presentation/molecules/devices/smart_tv_molecule.dart +++ b/lib/presentation/molecules/devices/smart_tv_molecule.dart @@ -5,8 +5,9 @@ import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/pr import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/entity_type_utils.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_smart_tv_entity/generic_smart_tv_entity.dart'; -import 'package:cybear_jinni/domain/connections_service.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/domain/connections_service.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -189,193 +190,202 @@ class _SmartTvMoleculeState extends State { @override Widget build(BuildContext context) { - return SizedBox( - height: 100, - child: ListView( - scrollDirection: Axis.horizontal, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, + return Column( + children: [ + DeviceNameRow( + widget.entity.cbjEntityName.getOrCrash()!, + const SizedBox(), + ), + SizedBox( + height: 100, + width: double.infinity, + child: ListView( + scrollDirection: Axis.horizontal, children: [ - const SeparatorAtom(), - TextButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( - Colors.grey, - ), - side: MaterialStateProperty.all( - BorderSide.lerp( - const BorderSide(color: Colors.white60), - const BorderSide(color: Colors.white60), - 22, + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const SeparatorAtom(), + TextButton( + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all( + Colors.grey, + ), + side: MaterialStateProperty.all( + BorderSide.lerp( + const BorderSide(color: Colors.white60), + const BorderSide(color: Colors.white60), + 22, + ), + ), ), - ), - ), - onPressed: onPause, - child: Tab( - icon: FaIcon( - FontAwesomeIcons.pause, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - child: TextAtom( - 'Pause', - style: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - fontSize: 16, + onPressed: onPause, + child: Tab( + icon: FaIcon( + FontAwesomeIcons.pause, + color: Theme.of(context).textTheme.bodyLarge!.color, + ), + child: TextAtom( + 'Pause', + style: TextStyle( + color: Theme.of(context).textTheme.bodyLarge!.color, + fontSize: 16, + ), + ), ), ), - ), - ), - const SeparatorAtom(multiple: 0.5), - TextButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( - Colors.grey, - ), - side: MaterialStateProperty.all( - BorderSide.lerp( - const BorderSide(color: Colors.white60), - const BorderSide(color: Colors.white60), - 22, + const SeparatorAtom(variant: SeparatorVariant.closeWidgets), + TextButton( + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all( + Colors.grey, + ), + side: MaterialStateProperty.all( + BorderSide.lerp( + const BorderSide(color: Colors.white60), + const BorderSide(color: Colors.white60), + 22, + ), + ), ), - ), - ), - onPressed: onPlay, - child: Tab( - icon: FaIcon( - FontAwesomeIcons.play, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - child: TextAtom( - 'Play', - style: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - fontSize: 16, + onPressed: onPlay, + child: Tab( + icon: FaIcon( + FontAwesomeIcons.play, + color: Theme.of(context).textTheme.bodyLarge!.color, + ), + child: TextAtom( + 'Play', + style: TextStyle( + color: Theme.of(context).textTheme.bodyLarge!.color, + fontSize: 16, + ), + ), ), ), - ), - ), - const SeparatorAtom(), - TextButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( - Colors.grey, - ), - side: MaterialStateProperty.all( - BorderSide.lerp( - const BorderSide(color: Colors.white60), - const BorderSide(color: Colors.white60), - 22, + const SeparatorAtom(), + TextButton( + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all( + Colors.grey, + ), + side: MaterialStateProperty.all( + BorderSide.lerp( + const BorderSide(color: Colors.white60), + const BorderSide(color: Colors.white60), + 22, + ), + ), ), - ), - ), - onPressed: onVolumeDown, - child: Tab( - icon: FaIcon( - FontAwesomeIcons.volumeLow, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - child: TextAtom( - 'Down', - style: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - fontSize: 16, + onPressed: onVolumeDown, + child: Tab( + icon: FaIcon( + FontAwesomeIcons.volumeLow, + color: Theme.of(context).textTheme.bodyLarge!.color, + ), + child: TextAtom( + 'Down', + style: TextStyle( + color: Theme.of(context).textTheme.bodyLarge!.color, + fontSize: 16, + ), + ), ), ), - ), - ), - const SeparatorAtom(multiple: 0.5), - TextButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( - Colors.grey, - ), - side: MaterialStateProperty.all( - BorderSide.lerp( - const BorderSide(color: Colors.white60), - const BorderSide(color: Colors.white60), - 22, + const SeparatorAtom(variant: SeparatorVariant.closeWidgets), + TextButton( + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all( + Colors.grey, + ), + side: MaterialStateProperty.all( + BorderSide.lerp( + const BorderSide(color: Colors.white60), + const BorderSide(color: Colors.white60), + 22, + ), + ), ), - ), - ), - onPressed: onVolumeUp, - child: Tab( - icon: FaIcon( - FontAwesomeIcons.volumeHigh, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - child: TextAtom( - 'Up', - style: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - fontSize: 16, + onPressed: onVolumeUp, + child: Tab( + icon: FaIcon( + FontAwesomeIcons.volumeHigh, + color: Theme.of(context).textTheme.bodyLarge!.color, + ), + child: TextAtom( + 'Up', + style: TextStyle( + color: Theme.of(context).textTheme.bodyLarge!.color, + fontSize: 16, + ), + ), ), ), - ), - ), - const SeparatorAtom(), - TextButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( - Colors.grey, - ), - side: MaterialStateProperty.all( - BorderSide.lerp( - const BorderSide(color: Colors.white60), - const BorderSide(color: Colors.white60), - 22, + const SeparatorAtom(), + TextButton( + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all( + Colors.grey, + ), + side: MaterialStateProperty.all( + BorderSide.lerp( + const BorderSide(color: Colors.white60), + const BorderSide(color: Colors.white60), + 22, + ), + ), ), - ), - ), - onPressed: onNetflix, - child: Tab( - icon: FaIcon( - FontAwesomeIcons.video, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - child: TextAtom( - 'Netflix', - style: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - fontSize: 16, + onPressed: onNetflix, + child: Tab( + icon: FaIcon( + FontAwesomeIcons.video, + color: Theme.of(context).textTheme.bodyLarge!.color, + ), + child: TextAtom( + 'Netflix', + style: TextStyle( + color: Theme.of(context).textTheme.bodyLarge!.color, + fontSize: 16, + ), + ), ), ), - ), - ), - const SeparatorAtom(), - TextButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( - Colors.grey, - ), - side: MaterialStateProperty.all( - BorderSide.lerp( - const BorderSide(color: Colors.white60), - const BorderSide(color: Colors.white60), - 22, + const SeparatorAtom(), + TextButton( + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all( + Colors.grey, + ), + side: MaterialStateProperty.all( + BorderSide.lerp( + const BorderSide(color: Colors.white60), + const BorderSide(color: Colors.white60), + 22, + ), + ), ), - ), - ), - onPressed: openUrlPopUp, - child: Tab( - icon: FaIcon( - FontAwesomeIcons.video, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - child: TextAtom( - 'Video', - style: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - fontSize: 16, + onPressed: openUrlPopUp, + child: Tab( + icon: FaIcon( + FontAwesomeIcons.video, + color: Theme.of(context).textTheme.bodyLarge!.color, + ), + child: TextAtom( + 'Video', + style: TextStyle( + color: Theme.of(context).textTheme.bodyLarge!.color, + fontSize: 16, + ), + ), ), ), - ), + const SeparatorAtom(), + ], ), - const SeparatorAtom(), ], ), - ], - ), + ), + ], ); } } diff --git a/lib/presentation/molecules/devices/switch_molecule.dart b/lib/presentation/molecules/devices/switch_molecule.dart index 6ba97f9aa..e75135c96 100644 --- a/lib/presentation/molecules/devices/switch_molecule.dart +++ b/lib/presentation/molecules/devices/switch_molecule.dart @@ -4,8 +4,9 @@ import 'dart:collection'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/entity_type_utils.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_switch_entity/generic_switch_entity.dart'; -import 'package:cybear_jinni/domain/connections_service.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/domain/connections_service.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; import 'package:flutter/material.dart'; /// Show switch toggles in a container with the background color from smart room @@ -54,11 +55,14 @@ class _SwitchMoleculeState extends State { @override Widget build(BuildContext context) { - return SwitchAtom( - variant: SwitchVariant.switchVariant, - onToggle: _changeAction, - action: widget.entity.switchState.action, - state: widget.entity.entityStateGRPC.state, + return DeviceNameRow( + widget.entity.cbjEntityName.getOrCrash()!, + SwitchAtom( + variant: SwitchVariant.switchVariant, + onToggle: _changeAction, + action: widget.entity.switchState.action, + state: widget.entity.entityStateGRPC.state, + ), ); } } diff --git a/lib/presentation/molecules/list_tile_molecule.dart b/lib/presentation/molecules/list_tile_molecule.dart new file mode 100644 index 000000000..deac5878a --- /dev/null +++ b/lib/presentation/molecules/list_tile_molecule.dart @@ -0,0 +1,26 @@ +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:flutter/material.dart'; + +class ListTileAtom extends StatelessWidget { + const ListTileAtom({ + this.headline, + this.supportingText, + this.leadingIcon, + this.onTap, + }); + + final String? headline; + final String? supportingText; + final IconData? leadingIcon; + final VoidCallback? onTap; + + @override + Widget build(BuildContext context) { + return ListTile( + title: headline != null ? TextAtom(headline!) : null, + subtitle: supportingText != null ? TextAtom(supportingText!) : null, + leading: leadingIcon != null ? IconAtom(leadingIcon!) : null, + onTap: onTap, + ); + } +} diff --git a/lib/presentation/molecules/list_view_molecule.dart b/lib/presentation/molecules/list_view_molecule.dart new file mode 100644 index 000000000..f9c03a7ee --- /dev/null +++ b/lib/presentation/molecules/list_view_molecule.dart @@ -0,0 +1,57 @@ +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:flutter/cupertino.dart'; + +class ListViewMolecule extends StatelessWidget { + const ListViewMolecule( + this.veriant, { + required this.itemCount, + required this.itemBuilder, + super.key, + this.scrollDirection = Axis.vertical, + this.reverse = false, + this.physics, + this.shrinkWrap = false, + }); + + final int itemCount; + final Widget Function(BuildContext context, int index) itemBuilder; + final Axis scrollDirection; + final bool reverse; + final ScrollPhysics? physics; + final bool shrinkWrap; + final ListViewVeriant veriant; + + @override + Widget build(BuildContext context) { + switch (veriant) { + case ListViewVeriant.builder: + return ListView.builder( + shrinkWrap: shrinkWrap, + physics: physics, + itemCount: itemCount, + scrollDirection: scrollDirection, + reverse: reverse, + itemBuilder: (BuildContext context, int index) => + itemBuilder(context, index), + ); + case ListViewVeriant.separated: + return ListView.separated( + shrinkWrap: shrinkWrap, + physics: physics, + itemCount: itemCount, + scrollDirection: scrollDirection, + reverse: reverse, + itemBuilder: (BuildContext context, int index) => + itemBuilder(context, index), + separatorBuilder: (context, index) => + const SeparatorAtom(variant: SeparatorVariant.reletedElements), + ); + } + } +} + +enum ListViewVeriant { + builder, + separated, + ; +} diff --git a/lib/presentation/molecules/list_view_separated_molecule.dart b/lib/presentation/molecules/list_view_separated_molecule.dart deleted file mode 100644 index 770848f5e..000000000 --- a/lib/presentation/molecules/list_view_separated_molecule.dart +++ /dev/null @@ -1,35 +0,0 @@ -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:flutter/cupertino.dart'; - -class ListViewSeparatedMolecule extends StatelessWidget { - const ListViewSeparatedMolecule({ - required this.itemCount, - required this.itemBuilder, - super.key, - this.scrollDirection = Axis.vertical, - this.reverse = false, - this.physics, - this.shrinkWrap = false, - }); - - final int itemCount; - final Widget Function(BuildContext context, int index) itemBuilder; - final Axis scrollDirection; - final bool reverse; - final ScrollPhysics? physics; - final bool shrinkWrap; - - @override - Widget build(BuildContext context) { - return ListView.separated( - shrinkWrap: shrinkWrap, - physics: physics, - itemCount: itemCount, - scrollDirection: scrollDirection, - reverse: reverse, - itemBuilder: (BuildContext context, int index) => - itemBuilder(context, index), - separatorBuilder: (context, index) => const SeparatorAtom(), - ); - } -} diff --git a/lib/presentation/molecules/loading_page_molecule.dart b/lib/presentation/molecules/loading_page_molecule.dart index 93344bc89..1e58d68e4 100644 --- a/lib/presentation/molecules/loading_page_molecule.dart +++ b/lib/presentation/molecules/loading_page_molecule.dart @@ -1,4 +1,4 @@ -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; import 'package:flutter/material.dart'; class LoadingPageMolecule extends StatelessWidget { diff --git a/lib/presentation/molecules/molecules.dart b/lib/presentation/molecules/molecules.dart index f9c8ae1c1..65a9b2d5a 100644 --- a/lib/presentation/molecules/molecules.dart +++ b/lib/presentation/molecules/molecules.dart @@ -1,5 +1,6 @@ export 'bottom_navigation_bar_molecule.dart'; export 'device_by_type_molecule.dart'; +export 'device_name_row.dart'; export 'devices/blind_molecule.dart'; export 'devices/blinds_card_molecule.dart'; export 'devices/boiler_molecule.dart'; @@ -9,10 +10,10 @@ export 'devices/light_molecule.dart'; export 'devices/printer_molecule.dart'; export 'devices/rgb_light_molecule.dart'; export 'devices/smart_computer_molecule.dart'; -export 'devices/smart_light_molecule.dart'; export 'devices/smart_plug_molecule.dart'; export 'devices/smart_tv_molecule.dart'; export 'devices/switch_molecule.dart'; -export 'list_view_separated_molecule.dart'; +export 'list_tile_molecule.dart'; +export 'list_view_molecule.dart'; export 'loading_page_molecule.dart'; export 'top_bar_molecule.dart'; diff --git a/lib/presentation/molecules/top_bar_molecule.dart b/lib/presentation/molecules/top_bar_molecule.dart index 02385aca4..640fea8b0 100644 --- a/lib/presentation/molecules/top_bar_molecule.dart +++ b/lib/presentation/molecules/top_bar_molecule.dart @@ -1,4 +1,4 @@ -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -42,81 +42,86 @@ class TopBarMolecule extends StatelessWidget { @override Widget build(BuildContext context) { - return ColoredBox( - color: backgroundColor != null - ? backgroundColor!.withOpacity(0.72) - : Colors.black.withOpacity(0.3), - child: Container( - margin: const EdgeInsets.fromLTRB(9, 3, 9, 0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - if (leftIcon != null) - Container( - alignment: Alignment.centerLeft, - child: IconButton( - icon: FaIcon( - leftIcon, - size: 19, - color: Theme.of(context).textTheme.bodyLarge!.color, + final ThemeData themeData = Theme.of(context); + final ColorScheme colorScheme = themeData.colorScheme; + final TextTheme textTheme = themeData.textTheme; + + final TextStyle style = textTheme.bodyLarge!; + + return SafeArea( + child: ColoredBox( + color: backgroundColor != null + ? backgroundColor!.withOpacity(0.72) + : colorScheme.background, + child: Container( + margin: const EdgeInsets.fromLTRB(9, 3, 9, 0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + if (leftIcon != null) + Container( + alignment: Alignment.centerLeft, + child: IconButton( + icon: FaIcon( + leftIcon, + size: style.fontSize, + color: colorScheme.tertiary, + ), + onPressed: () => leftIconFunction!(context), ), - onPressed: () => leftIconFunction!(context), - ), - ) - else - const SizedBox(), - TextAtom( - pageName!, - style: TextStyle( - fontSize: 16.0, - color: Theme.of(context).textTheme.bodyLarge!.color, + ) + else + const SizedBox(), + TextAtom( + pageName!, + style: style.copyWith(color: colorScheme.tertiary), ), - ), - ], - ), - if (rightIcon != null) - Row( - children: [ - if (rightSecondIcon != null) + ], + ), + if (rightIcon != null) + Row( + children: [ + if (rightSecondIcon != null) + SizedBox( + width: 70, + child: TextButton( + style: ButtonStyle( + padding: MaterialStateProperty.all( + EdgeInsets.zero, + ), + ), + onPressed: () => rightSecondFunction!(context), + child: FaIcon( + rightSecondIcon, + size: style.fontSize, + color: style.color, + ), + ), + ), SizedBox( - width: 70, + width: 25, child: TextButton( style: ButtonStyle( padding: MaterialStateProperty.all( EdgeInsets.zero, ), ), - onPressed: () => rightSecondFunction!(context), - child: FaIcon( - rightSecondIcon, - size: 19, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ), - SizedBox( - width: 25, - child: TextButton( - style: ButtonStyle( - padding: MaterialStateProperty.all( - EdgeInsets.zero, + onPressed: () => rightIconFunction!(context), + child: Icon( + rightIcon, + size: style.fontSize! + 5, + color: style.color, ), ), - onPressed: () => rightIconFunction!(context), - child: Icon( - rightIcon, - size: 26, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), ), - ), - ], - ) - else - const SizedBox(), - ], + ], + ) + else + const SizedBox(), + ], + ), ), ), ); diff --git a/lib/presentation/organisms/devices_list_view.dart b/lib/presentation/organisms/devices_list_view.dart new file mode 100644 index 000000000..cfa7e92e4 --- /dev/null +++ b/lib/presentation/organisms/devices_list_view.dart @@ -0,0 +1,92 @@ +import 'dart:collection'; + +import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/entities_utils.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; +import 'package:flutter/material.dart'; + +class DevicesListView extends StatelessWidget { + const DevicesListView(this.entities, this.onTap); + + final HashSet entities; + final Function(HashSet) onTap; + + HashSet getReleatedTypes(EntityTypes type) { + if (type == EntityTypes.light || + type == EntityTypes.rgbLights || + type == EntityTypes.rgbwLights || + type == EntityTypes.cctLight || + type == EntityTypes.dimmableLight) { + return HashSet.from({ + EntityTypes.light, + EntityTypes.rgbLights, + EntityTypes.rgbwLights, + EntityTypes.cctLight, + EntityTypes.dimmableLight, + }); + } + + return HashSet.from({type}); + } + + HashMap> geEntitiesByType() { + final HashMap> entitiesByType = + HashMap(); + + for (final DeviceEntityBase entity in entities) { + final EntityTypes type = getReleatedTypes(entity.entityTypes.type).first; + HashSet? entitiesForType = entitiesByType[type]; + entitiesForType ??= HashSet(); + entitiesForType.add(entity); + entitiesByType[type] = entitiesForType; + } + + return entitiesByType; + } + + @override + Widget build(BuildContext context) { + final HashMap> entitiesByType = + geEntitiesByType(); + + return ListViewMolecule( + ListViewVeriant.builder, + shrinkWrap: true, + itemBuilder: (context, index) { + final EntityTypes type = entitiesByType.keys.elementAt(index); + final HashSet? entitiesForType = entitiesByType[type]; + + if (entitiesForType == null) { + return const SizedBox(); + } + final int numberOfType = entitiesForType.length; + final DeviceEntityBase firstEntityOfType = entitiesForType.first; + + String? headline; + String? supportingText; + + if (numberOfType == 1) { + headline = firstEntityOfType.cbjEntityName.getOrCrash(); + supportingText = firstEntityOfType.entityStateGRPC.getOrCrash(); + } else { + headline = '$numberOfType ${type}s'; + supportingText = ''; + } + + return CardAtom( + ListTileAtom( + headline: headline, + supportingText: supportingText, + leadingIcon: EntitiesUtils.iconOfDeviceType(type), + onTap: () { + onTap(getReleatedTypes(type)); + }, + ), + ); + }, + itemCount: entitiesByType.length, + ); + } +} diff --git a/lib/presentation/organisms/empty_open_room_organism.dart b/lib/presentation/organisms/empty_open_room_organism.dart index 9b927ad94..8b2c6f111 100644 --- a/lib/presentation/organisms/empty_open_room_organism.dart +++ b/lib/presentation/organisms/empty_open_room_organism.dart @@ -1,5 +1,5 @@ import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; import 'package:flutter/material.dart'; class EmptyOpenRoomOrganism extends StatelessWidget { diff --git a/lib/presentation/organisms/entity_type_and_toggle_bar_organism.dart b/lib/presentation/organisms/entity_type_and_toggle_bar_organism.dart deleted file mode 100644 index 95c263035..000000000 --- a/lib/presentation/organisms/entity_type_and_toggle_bar_organism.dart +++ /dev/null @@ -1,61 +0,0 @@ -import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/entity_type_utils.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_light_entity/generic_light_entity.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/molecules/molecules.dart'; -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; - -/// Show bar of device type with toggle switch for light -class EntityTypeAndToggleBar extends StatelessWidget { - const EntityTypeAndToggleBar(this.entity); - - final GenericLightDE entity; - - @override - Widget build(BuildContext context) { - final EntityTypes deviceType = - EntityUtils.stringToDt(entity.entityTypes.getOrCrash())!; - return Row( - children: [ - if (deviceType == EntityTypes.light) - Container( - margin: const EdgeInsets.only(right: 5), - child: const CircleAvatar( - radius: 16, - child: FaIcon(FontAwesomeIcons.solidLightbulb), - ), - ), - if (deviceType == EntityTypes.blinds) - Container( - margin: const EdgeInsets.only(right: 5), - child: const CircleAvatar( - radius: 16, - child: FaIcon(FontAwesomeIcons.satelliteDish), - ), - ), - TextAtom( - 'Device_type:_', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 20, - color: Theme.of(context).textTheme.bodyLarge!.color, - backgroundColor: Colors.blueGrey -// color: (Theme.of(context).textTheme.bodyLarge!.color)!, - , - ), - translationArgs: [EntityUtils.dTToString(deviceType)], - ), - if (deviceType == EntityTypes.light) - SizedBox( - width: 100, - child: SmartLightMolecule( - entity, - ), // The actual render of the device - ) - else - Container(), - ], - ); - } -} diff --git a/lib/presentation/organisms/open_room_organism.dart b/lib/presentation/organisms/open_room_organism.dart index e5aa05f31..87dde7195 100644 --- a/lib/presentation/organisms/open_room_organism.dart +++ b/lib/presentation/organisms/open_room_organism.dart @@ -1,94 +1,47 @@ import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; -import 'package:cybear_jinni/domain/connections_service.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/molecules/molecules.dart'; -import 'package:cybear_jinni/presentation/organisms/organisms.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; +import 'package:cybearjinni/presentation/organisms/organisms.dart'; import 'package:flutter/material.dart'; class OpenRoomOrganism extends StatefulWidget { const OpenRoomOrganism({ required this.roomEntity, - required this.roomColorGradiant, required this.entityTypes, + required this.devices, }); /// If it have value will only show Printers in this room final RoomEntity roomEntity; - final Set? roomColorGradiant; final Set entityTypes; + final Set devices; @override State createState() => _OpenRoomOrganismState(); } class _OpenRoomOrganismState extends State { - Set? devices; - - @override - void initState() { - super.initState(); - initialzeDevices(); - } - - Future initialzeDevices() async { - final Map devicesMap = - await ConnectionsService.instance.getAllEntities; - final Set deviceIdsInRoom = - widget.roomEntity.roomDevicesId.getOrCrash(); - final Set entityTypes = widget.entityTypes; - if (entityTypes.isEmpty) { - return; - } - final Set tempDevices = devicesMap.values - .where( - (element) => - deviceIdsInRoom.contains(element.getCbjDeviceId) && - entityTypes.contains(element.entityTypes.type), - ) - .toSet(); - - setState(() { - devices = tempDevices; - }); - } - @override Widget build(BuildContext context) { - if (devices == null) { - return const CircularProgressIndicatorAtom(); - } - - if (devices!.isEmpty) { + if (widget.devices.isEmpty) { return EmptyOpenRoomOrganism(); } - final ThemeData themeData = Theme.of(context); - final TextTheme textTheme = themeData.textTheme; - return Container( margin: const EdgeInsets.symmetric(horizontal: 5, vertical: 15), child: ListView.separated( reverse: true, padding: EdgeInsets.zero, itemBuilder: (context, index) { - final DeviceEntityBase device = devices!.elementAt(index); + final DeviceEntityBase device = widget.devices.elementAt(index); - return Column( - children: [ - TextAtom( - device.cbjEntityName.getOrCrash() ?? '', - style: textTheme.titleMedium, - ), - const SeparatorAtom(multiple: 0.5), - DeviceByTypeMolecule(device), - ], - ); + return DeviceByTypeMolecule(device); }, - itemCount: devices!.length, + itemCount: widget.devices.length, separatorBuilder: (BuildContext context, int index) => - const SeparatorAtom(), + const SeparatorAtom(variant: SeparatorVariant.farAppart), ), ); } diff --git a/lib/presentation/organisms/organisms.dart b/lib/presentation/organisms/organisms.dart index b1905ebc0..f479d3eed 100644 --- a/lib/presentation/organisms/organisms.dart +++ b/lib/presentation/organisms/organisms.dart @@ -1,4 +1,4 @@ +export 'devices_list_view.dart'; export 'empty_open_room_organism.dart'; -export 'entity_type_and_toggle_bar_organism.dart'; export 'open_room_organism.dart'; export 'page_organism.dart'; diff --git a/lib/presentation/organisms/page_organism.dart b/lib/presentation/organisms/page_organism.dart index b541ca94c..500a13409 100644 --- a/lib/presentation/organisms/page_organism.dart +++ b/lib/presentation/organisms/page_organism.dart @@ -1,5 +1,5 @@ import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/presentation/molecules/top_bar_molecule.dart'; +import 'package:cybearjinni/presentation/molecules/top_bar_molecule.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -7,12 +7,12 @@ class PageOrganism extends StatelessWidget { const PageOrganism({ required this.child, required this.pageName, - required this.topBarColor, + this.topBarColor, }); final Widget child; final String pageName; - final Color topBarColor; + final Color? topBarColor; @override Widget build(BuildContext context) { diff --git a/lib/presentation/pages/add_new_automation_process/add_action/add_action_page.dart b/lib/presentation/pages/add_new_automation_process/add_action/add_action_page.dart index bca48b4c3..328f57f67 100644 --- a/lib/presentation/pages/add_new_automation_process/add_action/add_action_page.dart +++ b/lib/presentation/pages/add_new_automation_process/add_action/add_action_page.dart @@ -1,11 +1,9 @@ import 'package:auto_route/auto_route.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; -import 'package:cybear_jinni/presentation/molecules/molecules.dart'; -import 'package:cybear_jinni/presentation/pages/add_new_automation_process/add_action/widgets/action_choose_information.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; +import 'package:cybearjinni/presentation/pages/add_new_automation_process/add_action/widgets/action_choose_information.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:hexcolor/hexcolor.dart'; @RoutePage>>>() class AddActionPage extends StatelessWidget { @@ -14,12 +12,6 @@ class AddActionPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - toolbarHeight: 0, - backgroundColor: HexColor('#303030'), - systemOverlayStyle: SystemUiOverlayStyle.light, - ), - backgroundColor: HexColor('#303030'), body: Column( children: [ TopBarMolecule( diff --git a/lib/presentation/pages/add_new_automation_process/add_action/widgets/action_choose_information.dart b/lib/presentation/pages/add_new_automation_process/add_action/widgets/action_choose_information.dart index 168d65ae5..0768f3c60 100644 --- a/lib/presentation/pages/add_new_automation_process/add_action/widgets/action_choose_information.dart +++ b/lib/presentation/pages/add_new_automation_process/add_action/widgets/action_choose_information.dart @@ -2,9 +2,9 @@ import 'package:auto_route/auto_route.dart'; import 'package:cbj_integrations_controller/domain/room/i_room_repository.dart'; import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; -import 'package:cybear_jinni/domain/device/i_device_repository.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/snack_bar_service.dart'; +import 'package:cybearjinni/domain/device/i_device_repository.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/snack_bar_service.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; @@ -16,14 +16,14 @@ class ActionChooseInformation extends StatefulWidget { class _ActionChooseInformationState extends State { List _allRooms = []; - List _allDevices = []; + List _allEntities = []; String actionsName = ''; String propertyName = ''; /// Will contain (in that order) device to change his property to change and the new value of this property List>> - allDevicesWithNewAction = []; + allEntitiesWithNewAction = []; List> allEntityActions = []; bool isSubmitting = false; @@ -40,22 +40,22 @@ class _ActionChooseInformationState extends State { }); allRoomsTemp.removeWhere((element) => element == null); - List allDevicesTemp = []; - (await IDeviceRepository.instance.getAllDevices()).fold((l) => null, (r) { - allDevicesTemp = List.from(r.iter); + List allEntitiesTemp = []; + (await IDeviceRepository.instance.getAllEntites()).fold((l) => null, (r) { + allEntitiesTemp = List.from(r.iter); }); - allDevicesTemp.removeWhere((element) => element == null); + allEntitiesTemp.removeWhere((element) => element == null); setState(() { _allRooms = allRoomsTemp.map((e) => e!).toList(); - _allDevices = allDevicesTemp.map((e) => e!).toList(); + _allEntities = allEntitiesTemp.map((e) => e!).toList(); }); } - Future _changeActionDevices(String actionForProperty) async { - for (final DeviceEntityBase? device in _allDevices) { + Future _changeActionEntities(String actionForProperty) async { + for (final DeviceEntityBase? device in _allEntities) { if (device != null && actionForProperty == device.uniqueId.getOrCrash()) { setState(() { - allDevicesWithNewAction = [ + allEntitiesWithNewAction = [ MapEntry(device, const MapEntry(null, null)), ]; actionsName = ''; @@ -65,48 +65,50 @@ class _ActionChooseInformationState extends State { } Future _actionsNameChange(String value) async { - if (allDevicesWithNewAction.isNotEmpty) { + if (allEntitiesWithNewAction.isNotEmpty) { final List>> - tempAllDevicesWithNewActionList = List.from(allDevicesWithNewAction); + tempAllEntitiesWithNewActionList = + List.from(allEntitiesWithNewAction); final MapEntry propertyWithAction = MapEntry( - tempAllDevicesWithNewActionList[0].value.key, + tempAllEntitiesWithNewActionList[0].value.key, actionsName, ); - tempAllDevicesWithNewActionList[0] = - MapEntry(tempAllDevicesWithNewActionList[0].key, propertyWithAction); + tempAllEntitiesWithNewActionList[0] = + MapEntry(tempAllEntitiesWithNewActionList[0].key, propertyWithAction); setState(() { actionsName = value; - allDevicesWithNewAction = tempAllDevicesWithNewActionList; + allEntitiesWithNewAction = tempAllEntitiesWithNewActionList; }); } } - Future _changePropertyForDevices(String propertyOfDevice) async { - if (allDevicesWithNewAction.isNotEmpty) { + Future _changePropertyForEntities(String propertyOfDevice) async { + if (allEntitiesWithNewAction.isNotEmpty) { final List>> - tempAllDevicesWithNewActionList = List.from(allDevicesWithNewAction); + tempAllEntitiesWithNewActionList = + List.from(allEntitiesWithNewAction); final MapEntry propertyWithAction = MapEntry( propertyOfDevice, null, ); - tempAllDevicesWithNewActionList[0] = - MapEntry(tempAllDevicesWithNewActionList[0].key, propertyWithAction); + tempAllEntitiesWithNewActionList[0] = + MapEntry(tempAllEntitiesWithNewActionList[0].key, propertyWithAction); setState(() { propertyName = propertyOfDevice; - allDevicesWithNewAction = tempAllDevicesWithNewActionList; + allEntitiesWithNewAction = tempAllEntitiesWithNewActionList; }); } } @override Widget build(BuildContext context) { - if (_allDevices.isEmpty || _allRooms.isEmpty) { + if (_allEntities.isEmpty || _allRooms.isEmpty) { return const Expanded( child: Center( child: TextAtom( @@ -141,8 +143,11 @@ class _ActionChooseInformationState extends State { style: const TextStyle(color: Colors.white), icon: const Icon(Icons.arrow_drop_down), hint: TextAtom( - allDevicesWithNewAction.isNotEmpty - ? allDevicesWithNewAction[0].key.cbjEntityName.getOrCrash()! + allEntitiesWithNewAction.isNotEmpty + ? allEntitiesWithNewAction[0] + .key + .cbjEntityName + .getOrCrash()! : 'Choose Device', style: const TextStyle(color: Colors.white), ), @@ -150,8 +155,8 @@ class _ActionChooseInformationState extends State { underline: Container( height: 2, ), - onChanged: (value) => _changeActionDevices(value!), - items: _allDevices.map>((e) { + onChanged: (value) => _changeActionEntities(value!), + items: _allEntities.map>((e) { return DropdownMenuItem( value: e.uniqueId.getOrCrash(), child: TextAtom(e.cbjEntityName.getOrCrash()!), @@ -173,9 +178,9 @@ class _ActionChooseInformationState extends State { underline: Container( height: 2, ), - onChanged: (value) => _changePropertyForDevices(value!), - items: allDevicesWithNewAction.isNotEmpty - ? allDevicesWithNewAction[0] + onChanged: (value) => _changePropertyForEntities(value!), + items: allEntitiesWithNewAction.isNotEmpty + ? allEntitiesWithNewAction[0] .key .getListOfPropertiesToChange() .map>((e) { @@ -186,8 +191,8 @@ class _ActionChooseInformationState extends State { }).toList() : >[ const DropdownMenuItem( - value: 'Choose device first', - child: TextAtom('Choose device first'), + value: 'Choose entity first', + child: TextAtom('Choose entity first'), ), ], ), @@ -207,10 +212,10 @@ class _ActionChooseInformationState extends State { height: 2, ), onChanged: (value) => _actionsNameChange(value!), - items: (allDevicesWithNewAction.isNotEmpty && - allDevicesWithNewAction[0].value.key != null && - allDevicesWithNewAction[0].value.key!.isNotEmpty) - ? allDevicesWithNewAction[0] + items: (allEntitiesWithNewAction.isNotEmpty && + allEntitiesWithNewAction[0].value.key != null && + allEntitiesWithNewAction[0].value.key!.isNotEmpty) + ? allEntitiesWithNewAction[0] .key .getAllValidActions() .map>((e) { @@ -240,7 +245,7 @@ class _ActionChooseInformationState extends State { List< MapEntry>>>( - allDevicesWithNewAction, + allEntitiesWithNewAction, ); }, child: const TextAtom( diff --git a/lib/presentation/pages/add_new_automation_process/add_bindings/add_binding_page.dart b/lib/presentation/pages/add_new_automation_process/add_bindings/add_binding_page.dart index c08d49e25..5663fb0e9 100644 --- a/lib/presentation/pages/add_new_automation_process/add_bindings/add_binding_page.dart +++ b/lib/presentation/pages/add_new_automation_process/add_bindings/add_binding_page.dart @@ -1,8 +1,7 @@ import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/presentation/molecules/molecules.dart'; -import 'package:cybear_jinni/presentation/pages/add_new_automation_process/add_bindings/widgets/add_binding_widget.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; +import 'package:cybearjinni/presentation/pages/add_new_automation_process/add_bindings/widgets/add_binding_widget.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:hexcolor/hexcolor.dart'; @@ -16,11 +15,6 @@ class AddBindingPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - toolbarHeight: 0, - backgroundColor: Colors.black, - systemOverlayStyle: SystemUiOverlayStyle.dark, - ), body: ColoredBox( color: HexColor('#FBF5F9'), child: Column( diff --git a/lib/presentation/pages/add_new_automation_process/add_bindings/widgets/add_binding_widget.dart b/lib/presentation/pages/add_new_automation_process/add_bindings/widgets/add_binding_widget.dart index 42e163b9f..879733d2d 100644 --- a/lib/presentation/pages/add_new_automation_process/add_bindings/widgets/add_binding_widget.dart +++ b/lib/presentation/pages/add_new_automation_process/add_bindings/widgets/add_binding_widget.dart @@ -4,11 +4,11 @@ import 'package:cbj_integrations_controller/domain/binding/i_binding_cbj_reposit import 'package:cbj_integrations_controller/domain/vendors/login_abstract/core_login_failures.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; -import 'package:cybear_jinni/domain/device/i_device_repository.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; -import 'package:cybear_jinni/presentation/core/snack_bar_service.dart'; -import 'package:cybear_jinni/presentation/pages/add_new_automation_process/add_bindings/widgets/binding_action_widget.dart'; +import 'package:cybearjinni/domain/device/i_device_repository.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.gr.dart'; +import 'package:cybearjinni/presentation/core/snack_bar_service.dart'; +import 'package:cybearjinni/presentation/pages/add_new_automation_process/add_bindings/widgets/binding_action_widget.dart'; import 'package:dartz/dartz.dart' as dartz; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -40,7 +40,7 @@ class _AddBindingWidgetState extends State { Future _initialized() async { Set value = {}; - (await IDeviceRepository.instance.getAllDevices()).fold((l) => null, (r) { + (await IDeviceRepository.instance.getAllEntites()).fold((l) => null, (r) { value = Set.from(r.iter); }); value.removeWhere((element) => element == null); diff --git a/lib/presentation/pages/add_new_automation_process/add_routine/add_routine_page.dart b/lib/presentation/pages/add_new_automation_process/add_routine/add_routine_page.dart index 5b04ad2dc..fa8c0b869 100644 --- a/lib/presentation/pages/add_new_automation_process/add_routine/add_routine_page.dart +++ b/lib/presentation/pages/add_new_automation_process/add_routine/add_routine_page.dart @@ -1,9 +1,8 @@ import 'package:auto_route/auto_route.dart'; import 'package:cbj_integrations_controller/domain/routine/value_objects_routine_cbj.dart'; -import 'package:cybear_jinni/presentation/molecules/molecules.dart'; -import 'package:cybear_jinni/presentation/pages/add_new_automation_process/add_routine/widgets/add_routine_widget.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; +import 'package:cybearjinni/presentation/pages/add_new_automation_process/add_routine/widgets/add_routine_widget.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:hexcolor/hexcolor.dart'; @@ -27,11 +26,6 @@ class AddRoutinePage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - toolbarHeight: 0, - backgroundColor: Colors.black, - systemOverlayStyle: SystemUiOverlayStyle.dark, - ), body: ColoredBox( color: HexColor('#FBF5F9'), child: Column( diff --git a/lib/presentation/pages/add_new_automation_process/add_routine/pick_repeat_time/pick_repeat_time_page.dart b/lib/presentation/pages/add_new_automation_process/add_routine/pick_repeat_time/pick_repeat_time_page.dart index 4dbef652b..2b2f285c3 100644 --- a/lib/presentation/pages/add_new_automation_process/add_routine/pick_repeat_time/pick_repeat_time_page.dart +++ b/lib/presentation/pages/add_new_automation_process/add_routine/pick_repeat_time/pick_repeat_time_page.dart @@ -1,12 +1,11 @@ import 'package:auto_route/auto_route.dart'; import 'package:cbj_integrations_controller/domain/routine/value_objects_routine_cbj.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; -import 'package:cybear_jinni/presentation/molecules/molecules.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.gr.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; import 'package:day_night_time_picker/day_night_time_picker.dart'; import 'package:day_picker/day_picker.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:hexcolor/hexcolor.dart'; @@ -34,11 +33,6 @@ class PickRepeatTimePage extends StatelessWidget { RoutineCbjRepeatDateMinute? minutesToRepeat; return Scaffold( - appBar: AppBar( - toolbarHeight: 0, - backgroundColor: Colors.black, - systemOverlayStyle: SystemUiOverlayStyle.dark, - ), body: ColoredBox( color: HexColor('#FBF5F9'), child: Column( diff --git a/lib/presentation/pages/add_new_automation_process/add_routine/widgets/add_routine_widget.dart b/lib/presentation/pages/add_new_automation_process/add_routine/widgets/add_routine_widget.dart index 37022b076..a599d488d 100644 --- a/lib/presentation/pages/add_new_automation_process/add_routine/widgets/add_routine_widget.dart +++ b/lib/presentation/pages/add_new_automation_process/add_routine/widgets/add_routine_widget.dart @@ -5,11 +5,11 @@ import 'package:cbj_integrations_controller/domain/routine/value_objects_routine import 'package:cbj_integrations_controller/domain/vendors/login_abstract/core_login_failures.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; -import 'package:cybear_jinni/domain/device/i_device_repository.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; -import 'package:cybear_jinni/presentation/core/snack_bar_service.dart'; -import 'package:cybear_jinni/presentation/pages/add_new_automation_process/add_routine/widgets/routine_action_widget.dart'; +import 'package:cybearjinni/domain/device/i_device_repository.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.gr.dart'; +import 'package:cybearjinni/presentation/core/snack_bar_service.dart'; +import 'package:cybearjinni/presentation/pages/add_new_automation_process/add_routine/widgets/routine_action_widget.dart'; import 'package:dartz/dartz.dart' as dartz; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -46,7 +46,7 @@ class _AddRoutineWidgetState extends State { Future _initialized() async { Set temp = {}; - (await IDeviceRepository.instance.getAllDevices()).fold((l) => null, (r) { + (await IDeviceRepository.instance.getAllEntites()).fold((l) => null, (r) { temp = Set.from(r.iter); }); temp.removeWhere((element) => element == null); diff --git a/lib/presentation/pages/add_new_automation_process/add_scene/add_scene_page.dart b/lib/presentation/pages/add_new_automation_process/add_scene/add_scene_page.dart index 65b9995fb..c3f22a76a 100644 --- a/lib/presentation/pages/add_new_automation_process/add_scene/add_scene_page.dart +++ b/lib/presentation/pages/add_new_automation_process/add_scene/add_scene_page.dart @@ -1,8 +1,7 @@ import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/presentation/molecules/molecules.dart'; -import 'package:cybear_jinni/presentation/pages/add_new_automation_process/add_scene/widgets/add_scene_widget.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; +import 'package:cybearjinni/presentation/pages/add_new_automation_process/add_scene/widgets/add_scene_widget.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:hexcolor/hexcolor.dart'; @@ -16,11 +15,6 @@ class AddScenePage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - toolbarHeight: 0, - backgroundColor: Colors.black, - systemOverlayStyle: SystemUiOverlayStyle.dark, - ), body: ColoredBox( color: HexColor('#FBF5F9'), child: Column( diff --git a/lib/presentation/pages/add_new_automation_process/add_scene/widgets/add_scene_widget.dart b/lib/presentation/pages/add_new_automation_process/add_scene/widgets/add_scene_widget.dart index 0604c7a04..8caba3d2b 100644 --- a/lib/presentation/pages/add_new_automation_process/add_scene/widgets/add_scene_widget.dart +++ b/lib/presentation/pages/add_new_automation_process/add_scene/widgets/add_scene_widget.dart @@ -4,11 +4,11 @@ import 'package:cbj_integrations_controller/domain/scene/i_scene_cbj_repository. import 'package:cbj_integrations_controller/domain/vendors/login_abstract/core_login_failures.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; -import 'package:cybear_jinni/domain/device/i_device_repository.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; -import 'package:cybear_jinni/presentation/core/snack_bar_service.dart'; -import 'package:cybear_jinni/presentation/pages/add_new_automation_process/add_scene/widgets/scene_action_widget.dart'; +import 'package:cybearjinni/domain/device/i_device_repository.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.gr.dart'; +import 'package:cybearjinni/presentation/core/snack_bar_service.dart'; +import 'package:cybearjinni/presentation/pages/add_new_automation_process/add_scene/widgets/scene_action_widget.dart'; import 'package:dartz/dartz.dart' as dartz; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -39,7 +39,7 @@ class _AddSceneWidgetState extends State { Future _initialized() async { Set allDevicesTemp = {}; - (await IDeviceRepository.instance.getAllDevices()).fold((l) => null, (r) { + (await IDeviceRepository.instance.getAllEntites()).fold((l) => null, (r) { allDevicesTemp = Set.from(r.iter); }); diff --git a/lib/presentation/pages/add_new_automation_process/choose_automation_type_to_add/choose_automation_type_to_add_page.dart b/lib/presentation/pages/add_new_automation_process/choose_automation_type_to_add/choose_automation_type_to_add_page.dart index b94dde15b..8390a294b 100644 --- a/lib/presentation/pages/add_new_automation_process/choose_automation_type_to_add/choose_automation_type_to_add_page.dart +++ b/lib/presentation/pages/add_new_automation_process/choose_automation_type_to_add/choose_automation_type_to_add_page.dart @@ -1,12 +1,10 @@ import 'package:auto_route/auto_route.dart'; import 'package:auto_size_text/auto_size_text.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; -import 'package:cybear_jinni/presentation/molecules/molecules.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.gr.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:hexcolor/hexcolor.dart'; /// Page for the user to decide what kind of Scene he wants to add @RoutePage() @@ -18,233 +16,225 @@ class ChooseAutomationTypeToAddPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - toolbarHeight: 0, - backgroundColor: Colors.black, - systemOverlayStyle: SystemUiOverlayStyle.dark, - ), - body: ColoredBox( - color: HexColor('#FBF5F9'), - child: Column( - children: [ - TopBarMolecule( - pageName: 'Add Automations', + body: Column( + children: [ + TopBarMolecule( + pageName: 'Add Automations', - // FontAwesomeIcons.magnifyingGlass, - rightIconFunction: backButtonFunction, - leftIcon: FontAwesomeIcons.arrowLeft, - leftIconFunction: backButtonFunction, - ), - Container( - margin: const EdgeInsets.symmetric(horizontal: 10), - child: Column( - children: [ - const SizedBox( - height: 20, - ), - const TextAtom( - 'Do several things at once or start actions' - ' automatically by adding a trigger.', - style: TextStyle( - color: Colors.black, - ), - ), - const SizedBox( - height: 13, - ), - const TextAtom( - 'Please choose your automation trigger', - style: TextStyle( - color: Colors.black, - fontSize: 18, - ), + // FontAwesomeIcons.magnifyingGlass, + rightIconFunction: backButtonFunction, + leftIcon: FontAwesomeIcons.arrowLeft, + leftIconFunction: backButtonFunction, + ), + Container( + margin: const EdgeInsets.symmetric(horizontal: 10), + child: Column( + children: [ + const SizedBox( + height: 20, + ), + const TextAtom( + 'Do several things at once or start actions' + ' automatically by adding a trigger.', + style: TextStyle( + color: Colors.black, ), - const SizedBox( - height: 30, + ), + const SizedBox( + height: 13, + ), + const TextAtom( + 'Please choose your automation trigger', + style: TextStyle( + color: Colors.black, + fontSize: 18, ), - SingleChildScrollView( - child: Column( - children: [ - Container( - decoration: BoxDecoration( - color: Colors.lightBlueAccent.withOpacity(0.5), - // Red border with the width is equal to 5 - border: Border.all(), - ), - padding: const EdgeInsets.all(10), - child: TextButton( - onPressed: () { - context.router.push(const AddSceneRoute()); - }, - child: const Column( - children: [ - Row( - children: [ - TextAtom( - 'Scenes - ', - style: TextStyle( - color: Colors.black, - fontSize: 25, - ), + ), + const SizedBox( + height: 30, + ), + SingleChildScrollView( + child: Column( + children: [ + Container( + decoration: BoxDecoration( + color: Colors.lightBlueAccent.withOpacity(0.5), + // Red border with the width is equal to 5 + border: Border.all(), + ), + padding: const EdgeInsets.all(10), + child: TextButton( + onPressed: () { + context.router.push(const AddSceneRoute()); + }, + child: const Column( + children: [ + Row( + children: [ + TextAtom( + 'Scenes - ', + style: TextStyle( + color: Colors.black, + fontSize: 25, ), - AutoSizeText( - 'Triggered by user click', - maxFontSize: 18, - style: TextStyle( - color: Colors.black, - ), + ), + AutoSizeText( + 'Triggered by user click', + maxFontSize: 18, + style: TextStyle( + color: Colors.black, ), - ], - ), - TextAtom( - 'Combining a number of actions in a big button.', - style: TextStyle( - color: Colors.black, - fontSize: 13, ), + ], + ), + TextAtom( + 'Combining a number of actions in a big button.', + style: TextStyle( + color: Colors.black, + fontSize: 13, ), - TextAtom( - 'Example:\n"Arriving Home" button that will turn on some lights and turn up all the blinds when you click on it.', - style: TextStyle( - color: Colors.black, - fontSize: 15, - ), + ), + TextAtom( + 'Example:\n"Arriving Home" button that will turn on some lights and turn up all the blinds when you click on it.', + style: TextStyle( + color: Colors.black, + fontSize: 15, ), - ], - ), + ), + ], ), ), - const SizedBox( - height: 20, + ), + const SizedBox( + height: 20, + ), + Container( + decoration: BoxDecoration( + color: Colors.yellow.withOpacity(0.5), + // Red border with the width is equal to 5 + border: Border.all(), ), - Container( - decoration: BoxDecoration( - color: Colors.yellow.withOpacity(0.5), - // Red border with the width is equal to 5 - border: Border.all(), - ), - padding: const EdgeInsets.all(10), - child: TextButton( - onPressed: () { - // showDialog( - // context: context, - // builder: (_) => const AlertDialog( - // title: TextAtom( - // 'Not supported yet', - // ), - // ), - // ); - context.router.push(const PickRepeatTimeRoute()); - }, - child: const Column( - children: [ - Row( - children: [ - TextAtom( - 'Routines - ', - style: TextStyle( - color: Colors.black, - fontSize: 25, - ), + padding: const EdgeInsets.all(10), + child: TextButton( + onPressed: () { + // showDialog( + // context: context, + // builder: (_) => const AlertDialog( + // title: TextAtom( + // 'Not supported yet', + // ), + // ), + // ); + context.router.push(const PickRepeatTimeRoute()); + }, + child: const Column( + children: [ + Row( + children: [ + TextAtom( + 'Routines - ', + style: TextStyle( + color: Colors.black, + fontSize: 25, ), - AutoSizeText( - 'Triggered by time', - maxFontSize: 18, - style: TextStyle( - color: Colors.black, - ), + ), + AutoSizeText( + 'Triggered by time', + maxFontSize: 18, + style: TextStyle( + color: Colors.black, ), - ], - ), - TextAtom( - 'Like alarm clock but for triggering actions.', - style: TextStyle( - color: Colors.black, - fontSize: 13, ), + ], + ), + TextAtom( + 'Like alarm clock but for triggering actions.', + style: TextStyle( + color: Colors.black, + fontSize: 13, ), - TextAtom( - 'Example:\nTurn on the thermostat for an hour and open all blinds each day at 7:00am.', - style: TextStyle( - color: Colors.black, - fontSize: 15, - ), + ), + TextAtom( + 'Example:\nTurn on the thermostat for an hour and open all blinds each day at 7:00am.', + style: TextStyle( + color: Colors.black, + fontSize: 15, ), - ], - ), + ), + ], ), ), - const SizedBox( - height: 20, + ), + const SizedBox( + height: 20, + ), + Container( + decoration: BoxDecoration( + color: Colors.greenAccent.withOpacity(0.5), + // Red border with the width is equal to 5 + border: Border.all(), ), - Container( - decoration: BoxDecoration( - color: Colors.greenAccent.withOpacity(0.5), - // Red border with the width is equal to 5 - border: Border.all(), - ), - padding: const EdgeInsets.all(10), - child: TextButton( - onPressed: () { - showDialog( - context: context, - builder: (_) => const AlertDialog( - title: TextAtom( - 'Not supported yet', - ), + padding: const EdgeInsets.all(10), + child: TextButton( + onPressed: () { + showDialog( + context: context, + builder: (_) => const AlertDialog( + title: TextAtom( + 'Not supported yet', ), - ); - // context.router - // .push(const AddRoutineDeleteRoute()); - // context.router - // .push(const AddBindingRoute()); - }, - child: const Column( - children: [ - Row( - children: [ - TextAtom( - 'Bindings - ', - style: TextStyle( - color: Colors.black, - fontSize: 25, - ), + ), + ); + // context.router + // .push(const AddRoutineDeleteRoute()); + // context.router + // .push(const AddBindingRoute()); + }, + child: const Column( + children: [ + Row( + children: [ + TextAtom( + 'Bindings - ', + style: TextStyle( + color: Colors.black, + fontSize: 25, ), - AutoSizeText( - 'Triggered by external action', - maxFontSize: 18, - style: TextStyle( - color: Colors.black, - ), + ), + AutoSizeText( + 'Triggered by external action', + maxFontSize: 18, + style: TextStyle( + color: Colors.black, ), - ], - ), - TextAtom( - 'Trigger actions whenever an external action occurs.', - style: TextStyle( - color: Colors.black, - fontSize: 13, ), + ], + ), + TextAtom( + 'Trigger actions whenever an external action occurs.', + style: TextStyle( + color: Colors.black, + fontSize: 13, ), - TextAtom( - 'Example:\nIf the home door got opened from 3:00am - 6:00am trigger anti-thief alarm system.', - style: TextStyle( - color: Colors.black, - fontSize: 15, - ), + ), + TextAtom( + 'Example:\nIf the home door got opened from 3:00am - 6:00am trigger anti-thief alarm system.', + style: TextStyle( + color: Colors.black, + fontSize: 15, ), - ], - ), + ), + ], ), ), - ], - ), + ), + ], ), - ], - ), + ), + ], ), - ], - ), + ), + ], ), ); } diff --git a/lib/presentation/pages/add_new_devices/add_new_cbj_devices.dart b/lib/presentation/pages/add_new_devices/add_new_cbj_devices.dart index 737df5c5d..0e828e9e8 100644 --- a/lib/presentation/pages/add_new_devices/add_new_cbj_devices.dart +++ b/lib/presentation/pages/add_new_devices/add_new_cbj_devices.dart @@ -2,10 +2,9 @@ import 'dart:async'; import 'package:auto_route/auto_route.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_light_entity/generic_light_entity.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/molecules/molecules.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; /// This page will show all the CyBear Jinni devices that have connected to the @@ -51,11 +50,6 @@ class _AddNewCBJDevices extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - toolbarHeight: 0, - backgroundColor: Colors.black, - systemOverlayStyle: SystemUiOverlayStyle.dark, - ), body: Container( width: MediaQuery.of(context).size.width, decoration: BoxDecoration( diff --git a/lib/presentation/pages/add_new_devices/smart_device_to_configure.dart b/lib/presentation/pages/add_new_devices/smart_device_to_configure.dart deleted file mode 100644 index 3a7311205..000000000 --- a/lib/presentation/pages/add_new_devices/smart_device_to_configure.dart +++ /dev/null @@ -1,44 +0,0 @@ -import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_light_entity/generic_light_entity.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/organisms/organisms.dart'; -import 'package:flutter/material.dart'; - -class SmartDeviceToConfigure extends StatelessWidget { - const SmartDeviceToConfigure(this.smartDeviceObject); - - final GenericLightDE smartDeviceObject; - - @override - Widget build(BuildContext context) { - return Container( - margin: const EdgeInsets.all(10), - color: Colors.black54, - child: Column( - children: [ - EntityTypeAndToggleBar(smartDeviceObject), - TextAtom( - 'Device Name: ${smartDeviceObject.cbjEntityName.getOrCrash()}', - style: const TextStyle(fontSize: 21), - ), - const SizedBox( - height: 20, - ), - TextButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( - Colors.lightGreen, - ), - ), - onPressed: () {}, - child: TextAtom( - 'Edit device', - style: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ), - ], - ), - ); - } -} diff --git a/lib/presentation/pages/add_new_devices_process/choose_device_vendor_to_add/choose_device_vendor_to_add_page.dart b/lib/presentation/pages/add_new_devices_process/choose_device_vendor_to_add/choose_device_vendor_to_add_page.dart index 4c9d161ff..689a701c3 100644 --- a/lib/presentation/pages/add_new_devices_process/choose_device_vendor_to_add/choose_device_vendor_to_add_page.dart +++ b/lib/presentation/pages/add_new_devices_process/choose_device_vendor_to_add/choose_device_vendor_to_add_page.dart @@ -1,9 +1,8 @@ import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/molecules/molecules.dart'; -import 'package:cybear_jinni/presentation/pages/add_new_devices_process/choose_device_vendor_to_add/widgets/vendors_list.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; +import 'package:cybearjinni/presentation/pages/add_new_devices_process/choose_device_vendor_to_add/widgets/vendors_list.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:hexcolor/hexcolor.dart'; @@ -16,40 +15,30 @@ class ChooseDeviceVendorToAddPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - toolbarHeight: 0, - backgroundColor: Colors.black, - systemOverlayStyle: SystemUiOverlayStyle.light, - ), - body: ColoredBox( - color: HexColor('#FBF5F9'), - child: Column( - children: [ - TopBarMolecule( - pageName: 'Add Service', - - // FontAwesomeIcons.magnifyingGlass, - rightIconFunction: backButtonFunction, - leftIcon: FontAwesomeIcons.arrowLeft, - leftIconFunction: backButtonFunction, - ), - Container( - margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 40), - alignment: Alignment.centerLeft, - child: TextAtom( - 'Vendors:', - style: TextStyle(color: HexColor('#6599CA'), fontSize: 20), - ), - ), - Expanded( - child: VendorsList(), - ), - const SizedBox( - height: 50, - child: TextAtom(''), + body: Column( + children: [ + TopBarMolecule( + pageName: 'Add Service', + rightIconFunction: backButtonFunction, + leftIcon: FontAwesomeIcons.arrowLeft, + leftIconFunction: backButtonFunction, + ), + Container( + margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 40), + alignment: Alignment.centerLeft, + child: TextAtom( + 'Vendors:', + style: TextStyle(color: HexColor('#6599CA'), fontSize: 20), ), - ], - ), + ), + Expanded( + child: VendorsList(), + ), + const SizedBox( + height: 50, + child: TextAtom(''), + ), + ], ), ); } diff --git a/lib/presentation/pages/add_new_devices_process/choose_device_vendor_to_add/widgets/vendor_widget.dart b/lib/presentation/pages/add_new_devices_process/choose_device_vendor_to_add/widgets/vendor_widget.dart index 1458625ed..9cebb45c8 100644 --- a/lib/presentation/pages/add_new_devices_process/choose_device_vendor_to_add/widgets/vendor_widget.dart +++ b/lib/presentation/pages/add_new_devices_process/choose_device_vendor_to_add/widgets/vendor_widget.dart @@ -1,9 +1,9 @@ import 'package:auto_route/auto_route.dart'; import 'package:cbj_integrations_controller/domain/vendors/vendor_data.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; -import 'package:cybear_jinni/presentation/core/snack_bar_service.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.gr.dart'; +import 'package:cybearjinni/presentation/core/snack_bar_service.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; diff --git a/lib/presentation/pages/add_new_devices_process/choose_device_vendor_to_add/widgets/vendors_list.dart b/lib/presentation/pages/add_new_devices_process/choose_device_vendor_to_add/widgets/vendors_list.dart index d094a2252..bffc9b868 100644 --- a/lib/presentation/pages/add_new_devices_process/choose_device_vendor_to_add/widgets/vendors_list.dart +++ b/lib/presentation/pages/add_new_devices_process/choose_device_vendor_to_add/widgets/vendors_list.dart @@ -1,6 +1,6 @@ import 'package:cbj_integrations_controller/domain/vendors/i_vendor_repository.dart'; import 'package:cbj_integrations_controller/domain/vendors/vendor_data.dart'; -import 'package:cybear_jinni/presentation/pages/add_new_devices_process/choose_device_vendor_to_add/widgets/vendor_widget.dart'; +import 'package:cybearjinni/presentation/pages/add_new_devices_process/choose_device_vendor_to_add/widgets/vendor_widget.dart'; import 'package:flutter/material.dart'; import 'package:kt_dart/kt.dart'; diff --git a/lib/presentation/pages/add_new_devices_process/computer_connection_check/computer_connection_check_page.dart b/lib/presentation/pages/add_new_devices_process/computer_connection_check/computer_connection_check_page.dart index 6a7447b14..695281061 100644 --- a/lib/presentation/pages/add_new_devices_process/computer_connection_check/computer_connection_check_page.dart +++ b/lib/presentation/pages/add_new_devices_process/computer_connection_check/computer_connection_check_page.dart @@ -1,9 +1,8 @@ import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/domain/cbj_comp/cbj_comp_entity.dart'; -import 'package:cybear_jinni/presentation/molecules/molecules.dart'; -import 'package:cybear_jinni/presentation/pages/add_new_devices_process/computer_connection_check/widgets/computer_connection_check_widget.dart'; +import 'package:cybearjinni/domain/cbj_comp/cbj_comp_entity.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; +import 'package:cybearjinni/presentation/pages/add_new_devices_process/computer_connection_check/widgets/computer_connection_check_widget.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @RoutePage() @@ -21,11 +20,6 @@ class ComputerConnectionCheckPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - toolbarHeight: 0, - backgroundColor: Colors.black, - systemOverlayStyle: SystemUiOverlayStyle.dark, - ), body: ColoredBox( color: Colors.black87, child: Column( diff --git a/lib/presentation/pages/add_new_devices_process/computer_connection_check/widgets/computer_connection_check_widget.dart b/lib/presentation/pages/add_new_devices_process/computer_connection_check/widgets/computer_connection_check_widget.dart index bf722fef6..aa27d27bd 100644 --- a/lib/presentation/pages/add_new_devices_process/computer_connection_check/widgets/computer_connection_check_widget.dart +++ b/lib/presentation/pages/add_new_devices_process/computer_connection_check/widgets/computer_connection_check_widget.dart @@ -2,15 +2,15 @@ import 'package:another_flushbar/flushbar_helper.dart'; import 'package:cbj_integrations_controller/infrastructure/core/utils.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/value_objects_core.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_light_entity/generic_light_entity.dart'; -import 'package:cybear_jinni/domain/cbj_comp/cbj_comp_entity.dart'; -import 'package:cybear_jinni/domain/cbj_comp/cbj_comp_failures.dart'; -import 'package:cybear_jinni/domain/cbj_comp/cbj_comp_value_objects.dart'; -import 'package:cybear_jinni/domain/cbj_comp/i_cbj_comp_repository.dart'; -import 'package:cybear_jinni/domain/manage_network/i_manage_network_repository.dart'; -import 'package:cybear_jinni/domain/manage_network/manage_network_entity.dart'; -import 'package:cybear_jinni/domain/security_bear/i_security_bear_connection_repository.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/pages/add_new_devices_process/configure_new_cbj_comp/widgets/configure_new_cbj_comp_widget.dart'; +import 'package:cybearjinni/domain/cbj_comp/cbj_comp_entity.dart'; +import 'package:cybearjinni/domain/cbj_comp/cbj_comp_failures.dart'; +import 'package:cybearjinni/domain/cbj_comp/cbj_comp_value_objects.dart'; +import 'package:cybearjinni/domain/cbj_comp/i_cbj_comp_repository.dart'; +import 'package:cybearjinni/domain/manage_network/i_manage_network_repository.dart'; +import 'package:cybearjinni/domain/manage_network/manage_network_entity.dart'; +import 'package:cybearjinni/domain/security_bear/i_security_bear_connection_repository.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/pages/add_new_devices_process/configure_new_cbj_comp/widgets/configure_new_cbj_comp_widget.dart'; import 'package:dartz/dartz.dart' as dartz; import 'package:flutter/material.dart'; import 'package:kt_dart/collection.dart'; diff --git a/lib/presentation/pages/add_new_devices_process/configure_new_cbj_comp/configure_new_cbj_comp_page.dart b/lib/presentation/pages/add_new_devices_process/configure_new_cbj_comp/configure_new_cbj_comp_page.dart index 73d3817cf..a3134cdd3 100644 --- a/lib/presentation/pages/add_new_devices_process/configure_new_cbj_comp/configure_new_cbj_comp_page.dart +++ b/lib/presentation/pages/add_new_devices_process/configure_new_cbj_comp/configure_new_cbj_comp_page.dart @@ -1,9 +1,8 @@ import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/domain/cbj_comp/cbj_comp_entity.dart'; -import 'package:cybear_jinni/presentation/molecules/molecules.dart'; -import 'package:cybear_jinni/presentation/pages/add_new_devices_process/configure_new_cbj_comp/widgets/configure_new_cbj_comp_widget.dart'; +import 'package:cybearjinni/domain/cbj_comp/cbj_comp_entity.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; +import 'package:cybearjinni/presentation/pages/add_new_devices_process/configure_new_cbj_comp/widgets/configure_new_cbj_comp_widget.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @RoutePage() @@ -21,11 +20,6 @@ class ConfigureNewCbjCompPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - toolbarHeight: 0, - backgroundColor: Colors.black, - systemOverlayStyle: SystemUiOverlayStyle.dark, - ), body: ColoredBox( color: Colors.black87, child: Column( diff --git a/lib/presentation/pages/add_new_devices_process/configure_new_cbj_comp/widgets/configure_new_cbj_comp_widget.dart b/lib/presentation/pages/add_new_devices_process/configure_new_cbj_comp/widgets/configure_new_cbj_comp_widget.dart index 9eaa61f40..3935fe098 100644 --- a/lib/presentation/pages/add_new_devices_process/configure_new_cbj_comp/widgets/configure_new_cbj_comp_widget.dart +++ b/lib/presentation/pages/add_new_devices_process/configure_new_cbj_comp/widgets/configure_new_cbj_comp_widget.dart @@ -3,17 +3,17 @@ import 'package:cbj_integrations_controller/infrastructure/core/utils.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/value_objects_core.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_light_entity/generic_light_entity.dart'; -import 'package:cybear_jinni/domain/cbj_comp/cbj_comp_entity.dart'; -import 'package:cybear_jinni/domain/cbj_comp/cbj_comp_failures.dart'; -import 'package:cybear_jinni/domain/cbj_comp/cbj_comp_value_objects.dart'; -import 'package:cybear_jinni/domain/cbj_comp/i_cbj_comp_repository.dart'; -import 'package:cybear_jinni/domain/manage_network/i_manage_network_repository.dart'; -import 'package:cybear_jinni/domain/manage_network/manage_network_entity.dart'; -import 'package:cybear_jinni/domain/security_bear/i_security_bear_connection_repository.dart'; -import 'package:cybear_jinni/domain/security_bear/security_bear_failures.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; -import 'package:cybear_jinni/presentation/molecules/molecules.dart'; +import 'package:cybearjinni/domain/cbj_comp/cbj_comp_entity.dart'; +import 'package:cybearjinni/domain/cbj_comp/cbj_comp_failures.dart'; +import 'package:cybearjinni/domain/cbj_comp/cbj_comp_value_objects.dart'; +import 'package:cybearjinni/domain/cbj_comp/i_cbj_comp_repository.dart'; +import 'package:cybearjinni/domain/manage_network/i_manage_network_repository.dart'; +import 'package:cybearjinni/domain/manage_network/manage_network_entity.dart'; +import 'package:cybearjinni/domain/security_bear/i_security_bear_connection_repository.dart'; +import 'package:cybearjinni/domain/security_bear/security_bear_failures.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.gr.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; import 'package:dartz/dartz.dart' as dartz; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; diff --git a/lib/presentation/pages/add_new_devices_process/connect_to_home_wifi/connect_to_home_wifi_page.dart b/lib/presentation/pages/add_new_devices_process/connect_to_home_wifi/connect_to_home_wifi_page.dart index d4aa535e2..127093b64 100644 --- a/lib/presentation/pages/add_new_devices_process/connect_to_home_wifi/connect_to_home_wifi_page.dart +++ b/lib/presentation/pages/add_new_devices_process/connect_to_home_wifi/connect_to_home_wifi_page.dart @@ -1,9 +1,8 @@ import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/molecules/molecules.dart'; -import 'package:cybear_jinni/presentation/pages/add_new_devices_process/connect_to_home_wifi/widgets/connect_to_home_wifi_widget.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; +import 'package:cybearjinni/presentation/pages/add_new_devices_process/connect_to_home_wifi/widgets/connect_to_home_wifi_widget.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @RoutePage() @@ -15,11 +14,6 @@ class ConnectToHomeWifiPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - toolbarHeight: 0, - backgroundColor: Colors.black, - systemOverlayStyle: SystemUiOverlayStyle.dark, - ), body: Container( decoration: const BoxDecoration( // Box decoration takes a gradient diff --git a/lib/presentation/pages/add_new_devices_process/connect_to_home_wifi/widgets/connect_to_home_wifi_widget.dart b/lib/presentation/pages/add_new_devices_process/connect_to_home_wifi/widgets/connect_to_home_wifi_widget.dart index 4a4dcccb0..7e8d4cc8f 100644 --- a/lib/presentation/pages/add_new_devices_process/connect_to_home_wifi/widgets/connect_to_home_wifi_widget.dart +++ b/lib/presentation/pages/add_new_devices_process/connect_to_home_wifi/widgets/connect_to_home_wifi_widget.dart @@ -1,10 +1,10 @@ import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/domain/home_user/home_user_failures.dart'; -import 'package:cybear_jinni/domain/manage_network/i_manage_network_repository.dart'; -import 'package:cybear_jinni/domain/manage_network/manage_network_entity.dart'; -import 'package:cybear_jinni/domain/manage_network/manage_network_value_objects.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; +import 'package:cybearjinni/domain/home_user/home_user_failures.dart'; +import 'package:cybearjinni/domain/manage_network/i_manage_network_repository.dart'; +import 'package:cybearjinni/domain/manage_network/manage_network_entity.dart'; +import 'package:cybearjinni/domain/manage_network/manage_network_value_objects.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.gr.dart'; import 'package:dartz/dartz.dart' as dartz; import 'package:flutter/material.dart'; diff --git a/lib/presentation/pages/add_new_devices_process/open_access_point/open_access_pointi_page.dart b/lib/presentation/pages/add_new_devices_process/open_access_point/open_access_pointi_page.dart index 5073206c1..b5e500cf2 100644 --- a/lib/presentation/pages/add_new_devices_process/open_access_point/open_access_pointi_page.dart +++ b/lib/presentation/pages/add_new_devices_process/open_access_point/open_access_pointi_page.dart @@ -1,9 +1,8 @@ import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/molecules/molecules.dart'; -import 'package:cybear_jinni/presentation/pages/add_new_devices_process/open_access_point/widgets/open_access_point_widget.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; +import 'package:cybearjinni/presentation/pages/add_new_devices_process/open_access_point/widgets/open_access_point_widget.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @RoutePage() @@ -15,11 +14,6 @@ class OpenAccessPointPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - toolbarHeight: 0, - backgroundColor: Colors.black, - systemOverlayStyle: SystemUiOverlayStyle.dark, - ), body: Container( decoration: BoxDecoration( // Box decoration takes a gradient diff --git a/lib/presentation/pages/add_new_devices_process/open_access_point/widgets/open_access_point_widget.dart b/lib/presentation/pages/add_new_devices_process/open_access_point/widgets/open_access_point_widget.dart index 20a0a2572..f6f293fdf 100644 --- a/lib/presentation/pages/add_new_devices_process/open_access_point/widgets/open_access_point_widget.dart +++ b/lib/presentation/pages/add_new_devices_process/open_access_point/widgets/open_access_point_widget.dart @@ -2,13 +2,13 @@ import 'dart:io'; import 'package:auto_route/auto_route.dart'; import 'package:clipboard/clipboard.dart'; -import 'package:cybear_jinni/domain/home_user/home_user_failures.dart'; -import 'package:cybear_jinni/domain/manage_network/i_manage_network_repository.dart'; -import 'package:cybear_jinni/domain/manage_network/manage_network_entity.dart'; -import 'package:cybear_jinni/domain/manage_network/manage_network_value_objects.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; -import 'package:cybear_jinni/presentation/core/snack_bar_service.dart'; +import 'package:cybearjinni/domain/home_user/home_user_failures.dart'; +import 'package:cybearjinni/domain/manage_network/i_manage_network_repository.dart'; +import 'package:cybearjinni/domain/manage_network/manage_network_entity.dart'; +import 'package:cybearjinni/domain/manage_network/manage_network_value_objects.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.gr.dart'; +import 'package:cybearjinni/presentation/core/snack_bar_service.dart'; import 'package:dartz/dartz.dart' as dartz; import 'package:flutter/material.dart'; diff --git a/lib/presentation/pages/add_new_devices_process/scan_for_new_cbj_comps/scan_for_new_cbj_comps_page.dart b/lib/presentation/pages/add_new_devices_process/scan_for_new_cbj_comps/scan_for_new_cbj_comps_page.dart index 34516c418..dc47f9374 100644 --- a/lib/presentation/pages/add_new_devices_process/scan_for_new_cbj_comps/scan_for_new_cbj_comps_page.dart +++ b/lib/presentation/pages/add_new_devices_process/scan_for_new_cbj_comps/scan_for_new_cbj_comps_page.dart @@ -1,9 +1,8 @@ import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; -import 'package:cybear_jinni/presentation/molecules/molecules.dart'; -import 'package:cybear_jinni/presentation/pages/add_new_devices_process/scan_for_new_cbj_comps/widgets/scan_for_new_cbj_comps_widget.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.gr.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; +import 'package:cybearjinni/presentation/pages/add_new_devices_process/scan_for_new_cbj_comps/widgets/scan_for_new_cbj_comps_widget.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @RoutePage() @@ -15,11 +14,6 @@ class ScanForNewCBJCompsPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - toolbarHeight: 0, - backgroundColor: Colors.black, - systemOverlayStyle: SystemUiOverlayStyle.light, - ), body: ColoredBox( color: Colors.black87, child: Column( diff --git a/lib/presentation/pages/add_new_devices_process/scan_for_new_cbj_comps/widgets/cbj_comp_card.dart b/lib/presentation/pages/add_new_devices_process/scan_for_new_cbj_comps/widgets/cbj_comp_card.dart index 160e73012..f1dd8a737 100644 --- a/lib/presentation/pages/add_new_devices_process/scan_for_new_cbj_comps/widgets/cbj_comp_card.dart +++ b/lib/presentation/pages/add_new_devices_process/scan_for_new_cbj_comps/widgets/cbj_comp_card.dart @@ -1,9 +1,9 @@ import 'package:auto_route/auto_route.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_light_entity/generic_light_entity.dart'; -import 'package:cybear_jinni/domain/cbj_comp/cbj_comp_entity.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; +import 'package:cybearjinni/domain/cbj_comp/cbj_comp_entity.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.gr.dart'; import 'package:flutter/material.dart'; class CBJCompCard extends StatelessWidget { diff --git a/lib/presentation/pages/add_new_devices_process/scan_for_new_cbj_comps/widgets/cbj_comp_card_with_devices_controll.dart b/lib/presentation/pages/add_new_devices_process/scan_for_new_cbj_comps/widgets/cbj_comp_card_with_devices_controll.dart index 5d179c84d..75ab307c1 100644 --- a/lib/presentation/pages/add_new_devices_process/scan_for_new_cbj_comps/widgets/cbj_comp_card_with_devices_controll.dart +++ b/lib/presentation/pages/add_new_devices_process/scan_for_new_cbj_comps/widgets/cbj_comp_card_with_devices_controll.dart @@ -1,9 +1,9 @@ import 'package:auto_route/auto_route.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_light_entity/generic_light_entity.dart'; -import 'package:cybear_jinni/domain/cbj_comp/cbj_comp_entity.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; +import 'package:cybearjinni/domain/cbj_comp/cbj_comp_entity.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.gr.dart'; import 'package:flutter/material.dart'; import 'package:kt_dart/kt.dart'; diff --git a/lib/presentation/pages/add_new_devices_process/scan_for_new_cbj_comps/widgets/scan_for_new_cbj_comps_widget.dart b/lib/presentation/pages/add_new_devices_process/scan_for_new_cbj_comps/widgets/scan_for_new_cbj_comps_widget.dart index fa94e09d5..e41c554d7 100644 --- a/lib/presentation/pages/add_new_devices_process/scan_for_new_cbj_comps/widgets/scan_for_new_cbj_comps_widget.dart +++ b/lib/presentation/pages/add_new_devices_process/scan_for_new_cbj_comps/widgets/scan_for_new_cbj_comps_widget.dart @@ -1,12 +1,12 @@ import 'dart:async'; import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/domain/cbj_comp/cbj_comp_entity.dart'; -import 'package:cybear_jinni/domain/cbj_comp/cbj_comp_failures.dart'; -import 'package:cybear_jinni/domain/cbj_comp/cbj_comp_value_objects.dart'; -import 'package:cybear_jinni/domain/cbj_comp/i_cbj_comp_repository.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; +import 'package:cybearjinni/domain/cbj_comp/cbj_comp_entity.dart'; +import 'package:cybearjinni/domain/cbj_comp/cbj_comp_failures.dart'; +import 'package:cybearjinni/domain/cbj_comp/cbj_comp_value_objects.dart'; +import 'package:cybearjinni/domain/cbj_comp/i_cbj_comp_repository.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.gr.dart'; import 'package:dartz/dartz.dart' as dartz; import 'package:flutter/material.dart'; diff --git a/lib/presentation/pages/add_new_room/add_new_room_page.dart b/lib/presentation/pages/add_new_room/add_new_room_page.dart index ecb34280c..a62bac852 100644 --- a/lib/presentation/pages/add_new_room/add_new_room_page.dart +++ b/lib/presentation/pages/add_new_room/add_new_room_page.dart @@ -1,6 +1,6 @@ import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/pages/add_new_room/widgets/add_new_room_form.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/pages/add_new_room/widgets/add_new_room_form.dart'; import 'package:flutter/material.dart'; @RoutePage() diff --git a/lib/presentation/pages/add_new_room/widgets/add_new_room_form.dart b/lib/presentation/pages/add_new_room/widgets/add_new_room_form.dart index 52e3c4357..295caa264 100644 --- a/lib/presentation/pages/add_new_room/widgets/add_new_room_form.dart +++ b/lib/presentation/pages/add_new_room/widgets/add_new_room_form.dart @@ -5,9 +5,9 @@ import 'package:cbj_integrations_controller/domain/room/room_failures.dart'; import 'package:cbj_integrations_controller/domain/room/value_objects_room.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; -import 'package:cybear_jinni/domain/device/i_device_repository.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/snack_bar_service.dart'; +import 'package:cybearjinni/domain/device/i_device_repository.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/snack_bar_service.dart'; import 'package:dartz/dartz.dart' as dartz; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; @@ -49,7 +49,7 @@ class _AddNewRoomFormState extends State { _allRooms = Set.from(r.iter); }); - (await IDeviceRepository.instance.getAllDevices()).fold((l) => null, (r) { + (await IDeviceRepository.instance.getAllEntites()).fold((l) => null, (r) { _allDevices = Set.from(r.iter); }); _allRooms.removeWhere((element) => element == null); diff --git a/lib/presentation/pages/add_vendors_pages/add_esphome_vendor/add_esphome_vendor_page.dart b/lib/presentation/pages/add_vendors_pages/add_esphome_vendor/add_esphome_vendor_page.dart index 25eea27bb..0b302b546 100644 --- a/lib/presentation/pages/add_vendors_pages/add_esphome_vendor/add_esphome_vendor_page.dart +++ b/lib/presentation/pages/add_vendors_pages/add_esphome_vendor/add_esphome_vendor_page.dart @@ -1,7 +1,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:cbj_integrations_controller/domain/vendors/vendor_data.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/pages/add_vendors_pages/add_esphome_vendor/widgets/esphome_sign_in_form.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/pages/add_vendors_pages/add_esphome_vendor/widgets/esphome_sign_in_form.dart'; import 'package:flutter/material.dart'; @RoutePage() @@ -14,7 +14,6 @@ class AddEspHomeVendorPage extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - backgroundColor: Colors.black, title: const TextAtom('EspHome Sign In'), ), body: EspHomeSignInForm(vendor), diff --git a/lib/presentation/pages/add_vendors_pages/add_esphome_vendor/widgets/esphome_sign_in_form.dart b/lib/presentation/pages/add_vendors_pages/add_esphome_vendor/widgets/esphome_sign_in_form.dart index fe1175849..df9eae279 100644 --- a/lib/presentation/pages/add_vendors_pages/add_esphome_vendor/widgets/esphome_sign_in_form.dart +++ b/lib/presentation/pages/add_vendors_pages/add_esphome_vendor/widgets/esphome_sign_in_form.dart @@ -4,8 +4,8 @@ import 'package:cbj_integrations_controller/domain/vendors/esphome_login/generic import 'package:cbj_integrations_controller/domain/vendors/i_vendor_repository.dart'; import 'package:cbj_integrations_controller/domain/vendors/login_abstract/value_login_objects_core.dart'; import 'package:cbj_integrations_controller/domain/vendors/vendor_data.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/snack_bar_service.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/snack_bar_service.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; diff --git a/lib/presentation/pages/add_vendors_pages/add_ewelink_vendor/add_ewelink_vendor_page.dart b/lib/presentation/pages/add_vendors_pages/add_ewelink_vendor/add_ewelink_vendor_page.dart index e694ad7f2..bdb19a4eb 100644 --- a/lib/presentation/pages/add_vendors_pages/add_ewelink_vendor/add_ewelink_vendor_page.dart +++ b/lib/presentation/pages/add_vendors_pages/add_ewelink_vendor/add_ewelink_vendor_page.dart @@ -1,7 +1,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:cbj_integrations_controller/domain/vendors/vendor_data.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/pages/add_vendors_pages/add_ewelink_vendor/widgets/ewelink_sign_in_form.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/pages/add_vendors_pages/add_ewelink_vendor/widgets/ewelink_sign_in_form.dart'; import 'package:flutter/material.dart'; @RoutePage() diff --git a/lib/presentation/pages/add_vendors_pages/add_ewelink_vendor/widgets/ewelink_sign_in_form.dart b/lib/presentation/pages/add_vendors_pages/add_ewelink_vendor/widgets/ewelink_sign_in_form.dart index 44914d666..ebc20b7f4 100644 --- a/lib/presentation/pages/add_vendors_pages/add_ewelink_vendor/widgets/ewelink_sign_in_form.dart +++ b/lib/presentation/pages/add_vendors_pages/add_ewelink_vendor/widgets/ewelink_sign_in_form.dart @@ -4,8 +4,8 @@ import 'package:cbj_integrations_controller/domain/vendors/ewelink_login/generic import 'package:cbj_integrations_controller/domain/vendors/i_vendor_repository.dart'; import 'package:cbj_integrations_controller/domain/vendors/login_abstract/value_login_objects_core.dart'; import 'package:cbj_integrations_controller/domain/vendors/vendor_data.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/snack_bar_service.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/snack_bar_service.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; diff --git a/lib/presentation/pages/add_vendors_pages/add_lifx_vendor/add_lifx_vendor_page.dart b/lib/presentation/pages/add_vendors_pages/add_lifx_vendor/add_lifx_vendor_page.dart index cbec927f6..4bf965d8e 100644 --- a/lib/presentation/pages/add_vendors_pages/add_lifx_vendor/add_lifx_vendor_page.dart +++ b/lib/presentation/pages/add_vendors_pages/add_lifx_vendor/add_lifx_vendor_page.dart @@ -1,7 +1,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:cbj_integrations_controller/domain/vendors/vendor_data.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/pages/add_vendors_pages/add_lifx_vendor/widgets/lifx_sign_in_form.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/pages/add_vendors_pages/add_lifx_vendor/widgets/lifx_sign_in_form.dart'; import 'package:flutter/material.dart'; @RoutePage() diff --git a/lib/presentation/pages/add_vendors_pages/add_lifx_vendor/widgets/lifx_sign_in_form.dart b/lib/presentation/pages/add_vendors_pages/add_lifx_vendor/widgets/lifx_sign_in_form.dart index 16fb17840..dd24f614a 100644 --- a/lib/presentation/pages/add_vendors_pages/add_lifx_vendor/widgets/lifx_sign_in_form.dart +++ b/lib/presentation/pages/add_vendors_pages/add_lifx_vendor/widgets/lifx_sign_in_form.dart @@ -4,8 +4,8 @@ import 'package:cbj_integrations_controller/domain/vendors/lifx_login/generic_li import 'package:cbj_integrations_controller/domain/vendors/lifx_login/generic_lifx_login_value_objects.dart'; import 'package:cbj_integrations_controller/domain/vendors/login_abstract/value_login_objects_core.dart'; import 'package:cbj_integrations_controller/domain/vendors/vendor_data.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/snack_bar_service.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/snack_bar_service.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:url_launcher/url_launcher.dart'; diff --git a/lib/presentation/pages/change_room_for_devices/change_room_for_devices_page.dart b/lib/presentation/pages/change_room_for_devices/change_room_for_devices_page.dart index c088f6a5c..2b2dd82fa 100644 --- a/lib/presentation/pages/change_room_for_devices/change_room_for_devices_page.dart +++ b/lib/presentation/pages/change_room_for_devices/change_room_for_devices_page.dart @@ -1,10 +1,8 @@ import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/presentation/molecules/molecules.dart'; -import 'package:cybear_jinni/presentation/pages/change_room_for_devices/widgets/change_room_for_devices_widget.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; +import 'package:cybearjinni/presentation/pages/change_room_for_devices/widgets/change_room_for_devices_widget.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:hexcolor/hexcolor.dart'; @RoutePage() class ChangeRoomForDevicesPage extends StatelessWidget { @@ -15,12 +13,6 @@ class ChangeRoomForDevicesPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - toolbarHeight: 0, - backgroundColor: HexColor('#303030'), - systemOverlayStyle: SystemUiOverlayStyle.light, - ), - backgroundColor: HexColor('#303030'), body: Column( children: [ TopBarMolecule( diff --git a/lib/presentation/pages/change_room_for_devices/widgets/change_room_for_devices_widget.dart b/lib/presentation/pages/change_room_for_devices/widgets/change_room_for_devices_widget.dart index 18e7efd2f..f72277f36 100644 --- a/lib/presentation/pages/change_room_for_devices/widgets/change_room_for_devices_widget.dart +++ b/lib/presentation/pages/change_room_for_devices/widgets/change_room_for_devices_widget.dart @@ -3,13 +3,12 @@ import 'package:cbj_integrations_controller/domain/room/i_room_repository.dart'; import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; import 'package:cbj_integrations_controller/domain/room/value_objects_room.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; -import 'package:cybear_jinni/domain/device/i_device_repository.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; -import 'package:cybear_jinni/presentation/core/snack_bar_service.dart'; +import 'package:cybearjinni/domain/device/i_device_repository.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.gr.dart'; +import 'package:cybearjinni/presentation/core/snack_bar_service.dart'; import 'package:dartz/dartz.dart' as dartz; import 'package:flutter/material.dart'; -import 'package:hexcolor/hexcolor.dart'; import 'package:multi_select_flutter/multi_select_flutter.dart'; class ChangeRoomForDevicesWidget extends StatefulWidget { @@ -49,7 +48,7 @@ class _ChangeRoomForDevicesWidgetState _allRooms = Set.from(r.iter); }); - (await IDeviceRepository.instance.getAllDevices()).fold((l) => null, (r) { + (await IDeviceRepository.instance.getAllEntites()).fold((l) => null, (r) { _allDevices = Set.from(r.iter); }); _allRooms.removeWhere((element) => element == null); @@ -102,7 +101,6 @@ class _ChangeRoomForDevicesWidgetState Widget build(BuildContext context) { final Size screenSize = MediaQuery.of(context).size; return Container( - color: HexColor('#3A3A3A'), margin: const EdgeInsets.symmetric(horizontal: 10), child: Column( children: [ @@ -125,7 +123,7 @@ class _ChangeRoomForDevicesWidgetState style: TextStyle( fontSize: 16, color: Colors.white, - backgroundColor: Colors.blue, + backgroundColor: Colors.pink, ), ), ), @@ -133,13 +131,11 @@ class _ChangeRoomForDevicesWidgetState ), DropdownButton( dropdownColor: Colors.black, - style: const TextStyle(color: Colors.white), icon: const Icon(Icons.arrow_drop_down), hint: TextAtom( cbjEntityName.isValid() ? cbjEntityName.getOrCrash() : 'Choose Area', - style: const TextStyle(color: Colors.white), ), elevation: 16, underline: Container( diff --git a/lib/presentation/pages/connect_to_hub/connect_to_hub_page.dart b/lib/presentation/pages/connect_to_hub/connect_to_hub_page.dart index 13c4edb8b..8380df082 100644 --- a/lib/presentation/pages/connect_to_hub/connect_to_hub_page.dart +++ b/lib/presentation/pages/connect_to_hub/connect_to_hub_page.dart @@ -1,10 +1,9 @@ import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/domain/i_hub_connection_repository.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; -import 'package:cybear_jinni/presentation/pages/connect_to_hub/widgets/cbj_hub_in_network_widget.dart'; +import 'package:cybearjinni/domain/i_hub_connection_repository.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.gr.dart'; +import 'package:cybearjinni/presentation/pages/connect_to_hub/widgets/cbj_hub_in_network_widget.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:hexcolor/hexcolor.dart'; @@ -15,12 +14,6 @@ class ConnectToHubPage extends StatelessWidget { final Size screenSize = MediaQuery.of(context).size; return Scaffold( - appBar: AppBar( - toolbarHeight: 0, - backgroundColor: HexColor('#985dc7'), - systemOverlayStyle: SystemUiOverlayStyle.light, - ), - //added CustomScrollView to solve pixel overflow body: Container( decoration: BoxDecoration( gradient: LinearGradient( diff --git a/lib/presentation/pages/connect_to_hub/widgets/cbj_hub_in_network_widget.dart b/lib/presentation/pages/connect_to_hub/widgets/cbj_hub_in_network_widget.dart index bee2ff77e..f388b71d4 100644 --- a/lib/presentation/pages/connect_to_hub/widgets/cbj_hub_in_network_widget.dart +++ b/lib/presentation/pages/connect_to_hub/widgets/cbj_hub_in_network_widget.dart @@ -3,9 +3,9 @@ import 'dart:collection'; import 'package:auto_route/auto_route.dart'; import 'package:cbj_integrations_controller/domain/hub/hub_failures.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; -import 'package:cybear_jinni/domain/connections_service.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; +import 'package:cybearjinni/domain/connections_service.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.gr.dart'; import 'package:flutter/material.dart'; class CbjHubInNetworkWidget extends StatefulWidget { @@ -51,7 +51,9 @@ class _CbjHubInNetworkWidgetState extends State { } foundEntity = true; - context.router.replace(const HomeRoute()); + if (mounted) { + context.router.replace(const HomeRoute()); + } return; } diff --git a/lib/presentation/pages/connect_to_hub_more/connect_to_hub_more_page.dart b/lib/presentation/pages/connect_to_hub_more/connect_to_hub_more_page.dart index 1133128af..9d3304cac 100644 --- a/lib/presentation/pages/connect_to_hub_more/connect_to_hub_more_page.dart +++ b/lib/presentation/pages/connect_to_hub_more/connect_to_hub_more_page.dart @@ -1,8 +1,7 @@ import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/pages/connect_to_hub_more/widgets/connect_to_hub_more_widget.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/pages/connect_to_hub_more/widgets/connect_to_hub_more_widget.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:hexcolor/hexcolor.dart'; @RoutePage() @@ -10,11 +9,6 @@ class ConnectToHubMorePage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - toolbarHeight: 0, - backgroundColor: HexColor('#985dc7'), - systemOverlayStyle: SystemUiOverlayStyle.light, - ), body: Container( decoration: BoxDecoration( gradient: LinearGradient( diff --git a/lib/presentation/pages/connect_to_hub_more/widgets/connect_to_hub_more_widget.dart b/lib/presentation/pages/connect_to_hub_more/widgets/connect_to_hub_more_widget.dart index d478c649a..b27911373 100644 --- a/lib/presentation/pages/connect_to_hub_more/widgets/connect_to_hub_more_widget.dart +++ b/lib/presentation/pages/connect_to_hub_more/widgets/connect_to_hub_more_widget.dart @@ -2,10 +2,10 @@ import 'dart:async'; import 'package:auto_route/auto_route.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; -import 'package:cybear_jinni/domain/connections_service.dart'; -import 'package:cybear_jinni/domain/device/devices_failures.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; +import 'package:cybearjinni/domain/connections_service.dart'; +import 'package:cybearjinni/domain/device/devices_failures.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.gr.dart'; import 'package:dartz/dartz.dart' as dartz; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; diff --git a/lib/presentation/pages/devices_in_room_page.dart b/lib/presentation/pages/devices_in_room_page.dart deleted file mode 100644 index ea7a5c53f..000000000 --- a/lib/presentation/pages/devices_in_room_page.dart +++ /dev/null @@ -1,33 +0,0 @@ -import 'package:auto_route/auto_route.dart'; -import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; -import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cybear_jinni/presentation/core/theme_data.dart'; -import 'package:cybear_jinni/presentation/organisms/organisms.dart'; -import 'package:flutter/material.dart'; - -@RoutePage() -class DevicesInRoomPage extends StatelessWidget { - const DevicesInRoomPage({ - required this.roomEntity, - required this.roomColorGradiant, - required this.entityTypes, - }); - - /// If it have value will only show Printers in this room - final RoomEntity roomEntity; - final ListOfColors? roomColorGradiant; - final Set entityTypes; - - @override - Widget build(BuildContext context) { - return PageOrganism( - pageName: 'Device ${entityTypes.first.name}', - topBarColor: roomColorGradiant!.listOfColors!.last, - child: OpenRoomOrganism( - roomEntity: roomEntity, - roomColorGradiant: roomColorGradiant?.listOfColors, - entityTypes: entityTypes, - ), - ); - } -} diff --git a/lib/presentation/pages/devices_in_network_page.dart b/lib/presentation/pages/entities_in_network_page.dart similarity index 78% rename from lib/presentation/pages/devices_in_network_page.dart rename to lib/presentation/pages/entities_in_network_page.dart index f3fefac62..b0175e247 100644 --- a/lib/presentation/pages/devices_in_network_page.dart +++ b/lib/presentation/pages/entities_in_network_page.dart @@ -1,31 +1,31 @@ import 'package:auto_route/auto_route.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; -import 'package:cybear_jinni/domain/connections_service.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/theme_data.dart'; -import 'package:cybear_jinni/presentation/molecules/molecules.dart'; +import 'package:cybearjinni/domain/connections_service.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/theme_data.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; import 'package:flutter/material.dart'; @RoutePage() -class DevicesInNetworkPage extends StatefulWidget { +class EntitiesInNetworkPage extends StatefulWidget { @override - State createState() => _DevicesInNetworkPageState(); + State createState() => _EntitiesInNetworkPageState(); } -class _DevicesInNetworkPageState extends State { - List? allDevices; +class _EntitiesInNetworkPageState extends State { + List? allEntities; @override void initState() { super.initState(); - initializeAllDevices(); + initializeAllEntities(); } - Future initializeAllDevices() async { - final Map devices = + Future initializeAllEntities() async { + final Map entities = await ConnectionsService.instance.getAllEntities; setState(() { - allDevices = devices.values.toList(); + allEntities = entities.values.toList(); }); } @@ -48,7 +48,7 @@ class _DevicesInNetworkPageState extends State { @override Widget build(BuildContext context) { - if (allDevices == null) { + if (allEntities == null) { return const CircularProgressIndicator(); } @@ -57,13 +57,13 @@ class _DevicesInNetworkPageState extends State { title: const TextAtom('Add and Manage'), backgroundColor: Colors.purple.withOpacity(0.7), ), - backgroundColor: Colors.black.withOpacity(0.7), body: Container( margin: AppThemeData.generalHorizontalEdgeInsets, - child: ListViewSeparatedMolecule( - itemCount: allDevices!.length, + child: ListViewMolecule( + ListViewVeriant.separated, + itemCount: allEntities!.length, itemBuilder: (context, index) { - final DeviceEntityBase device = allDevices!.elementAt(index); + final DeviceEntityBase device = allEntities!.elementAt(index); final String? deviceLastKnownIp = device.deviceLastKnownIp.getOrCrash(); diff --git a/lib/presentation/pages/entities_in_room_page.dart b/lib/presentation/pages/entities_in_room_page.dart new file mode 100644 index 000000000..34a06317f --- /dev/null +++ b/lib/presentation/pages/entities_in_room_page.dart @@ -0,0 +1,79 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; +import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; +import 'package:cybearjinni/domain/connections_service.dart'; +import 'package:cybearjinni/presentation/atoms/circular_progress_indicator_atom.dart'; +import 'package:cybearjinni/presentation/organisms/organisms.dart'; +import 'package:flutter/material.dart'; + +@RoutePage() +class EntitiesInRoomPage extends StatefulWidget { + const EntitiesInRoomPage({ + required this.roomEntity, + required this.entityTypes, + }); + + /// If it have value will only show Printers in this room + final RoomEntity roomEntity; + final Set entityTypes; + + @override + State createState() => _EntitiesInRoomPageState(); +} + +class _EntitiesInRoomPageState extends State { + Set? devices; + late bool showAllTypes; + + @override + void initState() { + super.initState(); + showAllTypes = widget.entityTypes.isEmpty; + initialzeDevices(); + } + + Future initialzeDevices() async { + final Map devicesMap = + await ConnectionsService.instance.getAllEntities; + final Set deviceIdsInRoom = + widget.roomEntity.roomDevicesId.getOrCrash(); + final Set entityTypes = widget.entityTypes; + final Set tempDevices; + + tempDevices = devicesMap.values + .where( + (element) => + deviceIdsInRoom.contains(element.getCbjDeviceId) && + (showAllTypes || entityTypes.contains(element.entityTypes.type)), + ) + .toSet(); + + setState(() { + devices = tempDevices; + }); + } + + @override + Widget build(BuildContext context) { + String pageName = ''; + + if (showAllTypes) { + pageName = '${widget.roomEntity.cbjEntityName.getOrCrash()} Entities'; + } else if (devices != null) { + pageName = + '${widget.roomEntity.cbjEntityName.getOrCrash()} ${widget.entityTypes.firstOrNull?.name}'; + } + + return PageOrganism( + pageName: pageName, + child: devices != null + ? OpenRoomOrganism( + roomEntity: widget.roomEntity, + entityTypes: widget.entityTypes, + devices: devices!, + ) + : const CircularProgressIndicatorAtom(), + ); + } +} diff --git a/lib/presentation/pages/home_page/home_page.dart b/lib/presentation/pages/home_page/home_page.dart index a24f882bb..77a53dbbc 100644 --- a/lib/presentation/pages/home_page/home_page.dart +++ b/lib/presentation/pages/home_page/home_page.dart @@ -1,11 +1,10 @@ import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; -import 'package:cybear_jinni/presentation/molecules/molecules.dart'; -import 'package:cybear_jinni/presentation/pages/home_page/tabs/scenes_in_folders_tab/scenes_in_folders_tab.dart'; -import 'package:cybear_jinni/presentation/pages/home_page/tabs/smart_devices_tab/smart_devices_widgets.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.gr.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; +import 'package:cybearjinni/presentation/pages/home_page/tabs/scenes_in_folders_tab/scenes_in_folders_tab.dart'; +import 'package:cybearjinni/presentation/pages/home_page/tabs/smart_devices_tab/smart_devices_widgets.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; @@ -47,7 +46,7 @@ class _HomePageState extends State { BottomNavigationBarItemAtom( activeIcon: Icon(MdiIcons.lightbulbOn), icon: Icon(MdiIcons.lightbulbOutline), - label: 'Devices', + label: 'Entities', ), // BottomNavigationBarItemAtom( // icon: const FaIcon(FontAwesomeIcons.history), @@ -73,18 +72,10 @@ class _HomePageState extends State { @override Widget build(BuildContext context) { - return Container( - width: MediaQuery.of(context).size.width, - color: const Color.fromRGBO(251, 245, 249, 1.0), - child: Stack( + return Scaffold( + body: Stack( children: [ Scaffold( - appBar: AppBar( - toolbarHeight: 0, - backgroundColor: Colors.white, - systemOverlayStyle: SystemUiOverlayStyle.dark, - ), - backgroundColor: Colors.transparent, body: PageView( onPageChanged: (index) { setState(() { diff --git a/lib/presentation/pages/home_page/tabs/scenes_in_folders_tab/scenes_in_folders_tab.dart b/lib/presentation/pages/home_page/tabs/scenes_in_folders_tab/scenes_in_folders_tab.dart index fb1d50289..882e7be63 100644 --- a/lib/presentation/pages/home_page/tabs/scenes_in_folders_tab/scenes_in_folders_tab.dart +++ b/lib/presentation/pages/home_page/tabs/scenes_in_folders_tab/scenes_in_folders_tab.dart @@ -1,8 +1,8 @@ import 'package:adaptive_action_sheet/adaptive_action_sheet.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/snack_bar_service.dart'; -import 'package:cybear_jinni/presentation/molecules/molecules.dart'; -import 'package:cybear_jinni/presentation/pages/home_page/tabs/scenes_in_folders_tab/widgets/scenes_in_folders_l.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/snack_bar_service.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; +import 'package:cybearjinni/presentation/pages/home_page/tabs/scenes_in_folders_tab/widgets/scenes_in_folders_l.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; diff --git a/lib/presentation/pages/home_page/tabs/scenes_in_folders_tab/widgets/scenes_in_folders_l.dart b/lib/presentation/pages/home_page/tabs/scenes_in_folders_tab/widgets/scenes_in_folders_l.dart index 54d14a2ad..37abbf6df 100644 --- a/lib/presentation/pages/home_page/tabs/scenes_in_folders_tab/widgets/scenes_in_folders_l.dart +++ b/lib/presentation/pages/home_page/tabs/scenes_in_folders_tab/widgets/scenes_in_folders_l.dart @@ -4,8 +4,8 @@ import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; import 'package:cbj_integrations_controller/domain/room/room_failures.dart'; import 'package:cbj_integrations_controller/domain/scene/i_scene_cbj_repository.dart'; import 'package:cbj_integrations_controller/domain/scene/scene_cbj_entity.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.gr.dart'; import 'package:dartz/dartz.dart' as dartz; import 'package:flutter/material.dart'; import 'package:kt_dart/collection.dart'; diff --git a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/blinds_in_the_room.dart b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/blinds_in_the_room.dart deleted file mode 100644 index 47fa86d27..000000000 --- a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/blinds_in_the_room.dart +++ /dev/null @@ -1,272 +0,0 @@ -import 'dart:collection'; - -import 'package:another_flushbar/flushbar_helper.dart'; -import 'package:auto_route/auto_route.dart'; -import 'package:auto_size_text/auto_size_text.dart'; -import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; -import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/entity_type_utils.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_blinds_entity/generic_blinds_entity.dart'; -import 'package:cybear_jinni/domain/connections_service.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; -import 'package:cybear_jinni/presentation/core/theme_data.dart'; -import 'package:easy_localization/easy_localization.dart'; -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; - -class BlindsInTheRoom extends StatefulWidget { - const BlindsInTheRoom({ - required this.roomEntity, - this.entities, - this.roomColorGradiant, - }); - - factory BlindsInTheRoom.withAbstractDevice({ - required RoomEntity roomEntity, - required List tempDeviceInRoom, - required ListOfColors tempRoomColorGradiant, - }) { - final List tempLightsInRoom = []; - - for (final element in tempDeviceInRoom) { - tempLightsInRoom.add(element as GenericBlindsDE); - } - - return BlindsInTheRoom( - roomEntity: roomEntity, - entities: tempLightsInRoom, - roomColorGradiant: tempRoomColorGradiant, - ); - } - - final RoomEntity roomEntity; - final List? entities; - final ListOfColors? roomColorGradiant; - - @override - State createState() => _BlindsInTheRoomState(); -} - -class _BlindsInTheRoomState extends State { - Future _moveUpAllBlinds() async { - FlushbarHelper.createLoading( - message: 'Pulling_Up_all_blinds'.tr(), - linearProgressIndicator: const LinearProgressIndicator(), - ).show(context); - - setEntityState(EntityActions.moveUp); - } - - Future _moveDownAllBlinds() async { - FlushbarHelper.createLoading( - message: 'Pulling_down_all_blinds'.tr(), - linearProgressIndicator: const LinearProgressIndicator(), - ).show(context); - - setEntityState(EntityActions.moveDown); - } - - void setEntityState(EntityActions action) { - final VendorsAndServices? vendor = - widget.entities?.first?.cbjDeviceVendor.vendorsAndServices; - if (vendor == null) { - return; - } - - ConnectionsService.instance.setEntityState( - uniqueIdByVendor: getUniqueIdByVendor(), - property: EntityProperties.blindsSwitchState, - actionType: action, - ); - } - - HashMap>? _uniqueIdByVendor; - - HashMap> getUniqueIdByVendor() { - if (_uniqueIdByVendor != null) { - return _uniqueIdByVendor!; - } - - final HashMap> uniqueIdByVendor = - HashMap(); - for (final GenericBlindsDE? element in widget.entities!) { - final VendorsAndServices? vendor = - element?.cbjDeviceVendor.vendorsAndServices; - - if (vendor == null) { - continue; - } - final HashSet idsInVendor = - uniqueIdByVendor[vendor] ??= HashSet(); - - final String deviceCbjUniqueId = element!.deviceCbjUniqueId.getOrCrash(); - - idsInVendor.add(deviceCbjUniqueId); - - uniqueIdByVendor.addEntries([MapEntry(vendor, idsInVendor)]); - } - return _uniqueIdByVendor = uniqueIdByVendor; - } - - @override - Widget build(BuildContext context) { - String deviceText; - if (widget.entities!.length == 1) { - deviceText = widget.entities![0]!.cbjEntityName.getOrCrash()!; - } else { - deviceText = - '_Blinds'.tr(args: [widget.roomEntity.cbjEntityName.getOrCrash()]); - } - - return GestureDetector( - onTap: () { - context.router.push( - DevicesInRoomRoute( - entityTypes: const {EntityTypes.blinds}, - roomEntity: widget.roomEntity, - roomColorGradiant: widget.roomColorGradiant, - ), - ); - }, - child: Container( - decoration: BoxDecoration( - color: Colors.amber.withOpacity(0.03), - borderRadius: const BorderRadius.all(Radius.circular(20)), - ), - margin: const EdgeInsets.symmetric(horizontal: 5), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Expanded(child: TextAtom('')), - Expanded( - child: Column( - children: [ - const SizedBox(height: 10), - Transform.scale( - scale: 1.2, - child: const CircleAvatar( - child: FaIcon( - FontAwesomeIcons.alignJustify, - color: Colors.grey, - ), - ), - ), - ], - ), - ), - if (widget.entities!.length > 1) - Expanded( - child: Container( - height: 55, - alignment: Alignment.topLeft, - child: Container( - width: 28, - decoration: BoxDecoration( - border: Border.all( - color: Theme.of(context) - .textTheme - .bodyLarge! - .color! - .withOpacity(0.5), - ), - borderRadius: BorderRadius.circular(10), - ), - child: TextAtom( - widget.entities!.length.toString(), - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 13, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ), - ), - ) - else - const Expanded(child: TextAtom('')), - ], - ), - const SizedBox(height: 5), - Stack( - children: [ - AutoSizeText( - deviceText, - maxLines: 1, - style: TextStyle( - foreground: Paint() - ..style = PaintingStyle.stroke - ..strokeWidth = 0.8 - ..color = Colors.black38, - ), - ), - AutoSizeText( - deviceText, - maxLines: 1, - style: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ], - ), - const SizedBox( - height: 10, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - TextButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( - Colors.grey.withOpacity(0.6), - ), - side: MaterialStateProperty.all( - const BorderSide(width: 0.2), - ), - padding: MaterialStateProperty.all( - EdgeInsets.zero, - ), - ), - onPressed: _moveDownAllBlinds, - child: FaIcon( - FontAwesomeIcons.chevronDown, - color: Theme.of(context).textTheme.bodyMedium!.color, - ), - ), - TextAtom( - '·', - style: TextStyle( - fontSize: 14, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - TextButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( - Colors.grey.withOpacity(0.6), - ), - side: MaterialStateProperty.all( - const BorderSide(width: 0.2), - ), - padding: MaterialStateProperty.all( - EdgeInsets.zero, - ), - ), - onPressed: _moveUpAllBlinds, - child: FaIcon( - FontAwesomeIcons.chevronUp, - color: Theme.of(context).textTheme.bodyMedium!.color, - ), - ), - ], - ), - ], - ), - ), - ); - } -} diff --git a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/boilers_in_the_room.dart b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/boilers_in_the_room.dart deleted file mode 100644 index 644015f20..000000000 --- a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/boilers_in_the_room.dart +++ /dev/null @@ -1,155 +0,0 @@ -import 'package:auto_route/auto_route.dart'; -import 'package:auto_size_text/auto_size_text.dart'; -import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; -import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_boiler_entity/generic_boiler_entity.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; -import 'package:cybear_jinni/presentation/core/theme_data.dart'; -import 'package:easy_localization/easy_localization.dart'; -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; - -class BoilersInTheRoom extends StatelessWidget { - const BoilersInTheRoom({ - required this.roomEntity, - this.boilersInRoom, - this.roomColorGradiant, - }); - - factory BoilersInTheRoom.withAbstractDevice({ - required RoomEntity roomEntity, - required List tempDeviceInRoom, - required ListOfColors tempRoomColorGradiant, - }) { - final List tempLightsInRoom = []; - - for (final element in tempDeviceInRoom) { - tempLightsInRoom.add(element as GenericBoilerDE); - } - - return BoilersInTheRoom( - roomEntity: roomEntity, - boilersInRoom: tempLightsInRoom, - roomColorGradiant: tempRoomColorGradiant, - ); - } - - final RoomEntity roomEntity; - final List? boilersInRoom; - final ListOfColors? roomColorGradiant; - - @override - Widget build(BuildContext context) { - String deviceText; - if (boilersInRoom!.length == 1) { - deviceText = boilersInRoom![0].cbjEntityName.getOrCrash()!; - } else { - deviceText = '_Blinds'.tr(args: [roomEntity.cbjEntityName.getOrCrash()]); - } - - return GestureDetector( - onTap: () { - context.router.push( - DevicesInRoomRoute( - entityTypes: const {EntityTypes.boiler}, - roomEntity: roomEntity, - roomColorGradiant: roomColorGradiant, - ), - ); - }, - child: Container( - decoration: BoxDecoration( - color: Colors.amber.withOpacity(0.03), - borderRadius: const BorderRadius.all(Radius.circular(20)), - ), - margin: const EdgeInsets.symmetric(horizontal: 5), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Expanded(child: TextAtom('')), - Expanded( - child: Column( - children: [ - const SizedBox(height: 10), - Transform.scale( - scale: 1.2, - child: const CircleAvatar( - child: FaIcon( - FontAwesomeIcons.temperatureThreeQuarters, - color: Colors.redAccent, - ), - ), - ), - ], - ), - ), - if (boilersInRoom!.length > 1) - Expanded( - child: Container( - height: 55, - alignment: Alignment.topLeft, - child: Container( - width: 28, - decoration: BoxDecoration( - border: Border.all( - color: Theme.of(context) - .textTheme - .bodyLarge! - .color! - .withOpacity(0.5), - ), - borderRadius: BorderRadius.circular(10), - ), - child: TextAtom( - boilersInRoom!.length.toString(), - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 13, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ), - ), - ) - else - const Expanded(child: TextAtom('')), - ], - ), - const SizedBox( - height: 10, - ), - Stack( - children: [ - AutoSizeText( - deviceText, - maxLines: 1, - style: TextStyle( - foreground: Paint() - ..style = PaintingStyle.stroke - ..strokeWidth = 0.8 - ..color = Colors.black38, - ), - ), - AutoSizeText( - deviceText, - maxLines: 1, - style: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ], - ), - const SizedBox( - height: 5, - ), - ], - ), - ), - ); - } -} diff --git a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/lights_in_the_room_block.dart b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/lights_in_the_room_block.dart deleted file mode 100644 index 72239e589..000000000 --- a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/lights_in_the_room_block.dart +++ /dev/null @@ -1,316 +0,0 @@ -import 'dart:collection'; - -import 'package:another_flushbar/flushbar_helper.dart'; -import 'package:auto_route/auto_route.dart'; -import 'package:auto_size_text/auto_size_text.dart'; -import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; -import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/entity_type_utils.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_dimmable_light_entity/generic_dimmable_light_entity.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_light_entity/generic_light_entity.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_rgbw_light_entity/generic_rgbw_light_entity.dart'; -import 'package:cybear_jinni/domain/connections_service.dart'; -import 'package:cybear_jinni/infrastructure/core/logger.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; -import 'package:cybear_jinni/presentation/core/theme_data.dart'; -import 'package:easy_localization/easy_localization.dart'; -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; - -class LightsInTheRoomBlock extends StatefulWidget { - const LightsInTheRoomBlock({ - required this.roomEntity, - required this.lightsInRoom, - required this.entities, - required this.dimmableLightsInRoom, - required this.rgbwLightsInRoom, - required this.roomColorGradiant, - }); - - factory LightsInTheRoomBlock.withAbstractDevice({ - required RoomEntity roomEntity, - required List entities, - required ListOfColors tempRoomColorGradiant, - }) { - final List tempLightsInRoom = []; - final List tempDimmableLightsInRoom = []; - final List tempRgbwLightsInRoom = []; - - for (final element in entities) { - if (element.entityTypes.getOrCrash() == EntityTypes.light.toString()) { - tempLightsInRoom.add(element as GenericLightDE); - } else if (element.entityTypes.getOrCrash() == - EntityTypes.dimmableLight.toString()) { - tempDimmableLightsInRoom.add(element as GenericDimmableLightDE); - } else if (element.entityTypes.getOrCrash() == - EntityTypes.rgbwLights.toString()) { - tempRgbwLightsInRoom.add(element as GenericRgbwLightDE); - } else { - logger.e('Unsupported light type ${element.entityTypes.getOrCrash()}'); - } - } - - return LightsInTheRoomBlock( - roomEntity: roomEntity, - lightsInRoom: tempLightsInRoom, - entities: entities, - dimmableLightsInRoom: tempDimmableLightsInRoom, - rgbwLightsInRoom: tempRgbwLightsInRoom, - roomColorGradiant: tempRoomColorGradiant, - ); - } - - final RoomEntity roomEntity; - final List lightsInRoom; - final List dimmableLightsInRoom; - final List rgbwLightsInRoom; - final ListOfColors roomColorGradiant; - final List entities; - - @override - State createState() => _LightsInTheRoomBlockState(); -} - -class _LightsInTheRoomBlockState extends State { - Future _turnOffAllLights() async { - FlushbarHelper.createLoading( - message: 'Turning Off all lights', - linearProgressIndicator: const LinearProgressIndicator(), - ).show(context); - - setEntityState(EntityActions.off); - } - - Future _turnOnAllLights() async { - FlushbarHelper.createLoading( - message: 'Turning On all lights', - linearProgressIndicator: const LinearProgressIndicator(), - ).show(context); - - setEntityState(EntityActions.on); - } - - void setEntityState(EntityActions action) { - final VendorsAndServices? vendor = - widget.entities.first.cbjDeviceVendor.vendorsAndServices; - if (vendor == null) { - return; - } - - ConnectionsService.instance.setEntityState( - uniqueIdByVendor: getUniqueIdByVendor(), - property: EntityProperties.lightSwitchState, - actionType: action, - ); - } - - HashMap>? _uniqueIdByVendor; - - HashMap> getUniqueIdByVendor() { - if (_uniqueIdByVendor != null) { - return _uniqueIdByVendor!; - } - - final HashMap> uniqueIdByVendor = - HashMap(); - for (final DeviceEntityBase? element in widget.entities) { - final VendorsAndServices? vendor = - element?.cbjDeviceVendor.vendorsAndServices; - - if (vendor == null) { - continue; - } - final HashSet idsInVendor = - uniqueIdByVendor[vendor] ??= HashSet(); - - final String deviceCbjUniqueId = element!.deviceCbjUniqueId.getOrCrash(); - - idsInVendor.add(deviceCbjUniqueId); - - uniqueIdByVendor.addEntries([MapEntry(vendor, idsInVendor)]); - } - return _uniqueIdByVendor = uniqueIdByVendor; - } - - @override - Widget build(BuildContext context) { - String deviceText; - - final int totalLightsInTheRoom = widget.lightsInRoom.length + - widget.dimmableLightsInRoom.length + - widget.rgbwLightsInRoom.length; - - if (totalLightsInTheRoom == 1) { - if (widget.lightsInRoom.isNotEmpty) { - deviceText = widget.lightsInRoom.first.cbjEntityName.getOrCrash()!; - } else if (widget.dimmableLightsInRoom.isNotEmpty) { - deviceText = - widget.dimmableLightsInRoom.first.cbjEntityName.getOrCrash()!; - } else if (widget.rgbwLightsInRoom.isNotEmpty) { - deviceText = widget.rgbwLightsInRoom.first.cbjEntityName.getOrCrash()!; - } else { - logger.w('Missing a line here'); - deviceText = 'Light'; - } - } else { - deviceText = - '_Lights'.tr(args: [widget.roomEntity.cbjEntityName.getOrCrash()]); - } - - return GestureDetector( - onTap: () { - context.router.push( - DevicesInRoomRoute( - entityTypes: const { - EntityTypes.light, - EntityTypes.rgbLights, - EntityTypes.rgbwLights, - EntityTypes.rgbcctLights, - }, - roomEntity: widget.roomEntity, - roomColorGradiant: widget.roomColorGradiant, - ), - ); - }, - child: Container( - decoration: BoxDecoration( - color: Colors.amber.withOpacity(0.03), - borderRadius: const BorderRadius.all(Radius.circular(20)), - ), - margin: const EdgeInsets.symmetric(horizontal: 5), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Expanded(child: TextAtom('')), - Expanded( - child: Column( - children: [ - const SizedBox(height: 10), - Transform.scale( - scale: 1.2, - child: const CircleAvatar( - child: FaIcon( - FontAwesomeIcons.solidLightbulb, - color: Colors.amberAccent, - ), - ), - ), - ], - ), - ), - if (totalLightsInTheRoom > 1) - Expanded( - child: Container( - height: 55, - alignment: Alignment.topLeft, - child: Container( - width: 28, - decoration: BoxDecoration( - border: Border.all( - color: Theme.of(context) - .textTheme - .bodyLarge! - .color! - .withOpacity(0.5), - ), - borderRadius: BorderRadius.circular(10), - ), - child: TextAtom( - totalLightsInTheRoom.toString(), - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 13, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ), - ), - ) - else - const Expanded(child: TextAtom('')), - ], - ), - const SizedBox(height: 5), - Stack( - children: [ - AutoSizeText( - deviceText, - maxLines: 1, - style: TextStyle( - foreground: Paint() - ..style = PaintingStyle.stroke - ..strokeWidth = 0.8 - ..color = Colors.black38, - ), - ), - AutoSizeText( - deviceText, - maxLines: 1, - style: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ], - ), - const SizedBox( - height: 10, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - TextButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( - Colors.grey.withOpacity(0.6), - ), - side: MaterialStateProperty.all( - const BorderSide(width: 0.2), - ), - ), - onPressed: _turnOffAllLights, - child: TextAtom( - 'Off', - style: TextStyle( - fontSize: 14, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ), - TextAtom( - '·', - style: TextStyle( - fontSize: 14, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - TextButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( - Colors.grey.withOpacity(0.6), - ), - side: MaterialStateProperty.all( - const BorderSide(width: 0.2), - ), - ), - onPressed: _turnOnAllLights, - child: TextAtom( - 'On', - style: TextStyle( - fontSize: 14, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ), - ], - ), - ], - ), - ), - ); - } -} diff --git a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/printers_in_the_room_block.dart b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/printers_in_the_room_block.dart deleted file mode 100644 index 3ed43f4c8..000000000 --- a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/printers_in_the_room_block.dart +++ /dev/null @@ -1,164 +0,0 @@ -import 'package:auto_route/auto_route.dart'; -import 'package:auto_size_text/auto_size_text.dart'; -import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; -import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_printer_entity/generic_printer_entity.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; -import 'package:cybear_jinni/presentation/core/theme_data.dart'; -import 'package:easy_localization/easy_localization.dart'; -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; - -class PrintersInTheRoomBlock extends StatelessWidget { - const PrintersInTheRoomBlock({ - required this.roomEntity, - required this.printersInRoom, - required this.roomColorGradiant, - }); - - factory PrintersInTheRoomBlock.withAbstractDevice({ - required RoomEntity roomEntityTemp, - required List tempDeviceInRoom, - required ListOfColors tempRoomColorGradiant, - }) { - final List tempPrintersInRoom = []; - - for (final element in tempDeviceInRoom) { - tempPrintersInRoom.add(element as GenericPrinterDE); - } - - return PrintersInTheRoomBlock( - roomEntity: roomEntityTemp, - printersInRoom: tempPrintersInRoom, - roomColorGradiant: tempRoomColorGradiant, - ); - } - - final RoomEntity roomEntity; - final List printersInRoom; - final ListOfColors roomColorGradiant; - - @override - Widget build(BuildContext context) { - String deviceText; - if (printersInRoom.length == 1) { - deviceText = printersInRoom[0].cbjEntityName.getOrCrash()!; - } else { - deviceText = - '_Printers'.tr(args: [roomEntity.cbjEntityName.getOrCrash()]); - } - - return GestureDetector( - onTap: () { - context.router.push( - DevicesInRoomRoute( - entityTypes: const {EntityTypes.printer}, - roomEntity: roomEntity, - roomColorGradiant: roomColorGradiant, - ), - ); - }, - child: Container( - decoration: BoxDecoration( - color: Colors.amber.withOpacity(0.03), - borderRadius: const BorderRadius.all(Radius.circular(20)), - ), - margin: const EdgeInsets.symmetric(horizontal: 5), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Expanded(child: TextAtom('')), - Expanded( - child: Column( - children: [ - const SizedBox(height: 10), - Transform.scale( - scale: 1.2, - child: const CircleAvatar( - child: FaIcon( - FontAwesomeIcons.print, - color: Colors.white70, - ), - ), - ), - ], - ), - ), - if (printersInRoom.length > 1) - Expanded( - child: Container( - height: 55, - alignment: Alignment.topLeft, - child: Container( - width: 28, - decoration: BoxDecoration( - border: Border.all( - color: Theme.of(context) - .textTheme - .bodyLarge! - .color! - .withOpacity(0.5), - ), - borderRadius: BorderRadius.circular(10), - ), - child: TextAtom( - printersInRoom.length.toString(), - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 13, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ), - ), - ) - else - const Expanded(child: TextAtom('')), - ], - ), - const SizedBox(height: 5), - Stack( - children: [ - AutoSizeText( - deviceText, - maxLines: 1, - textAlign: TextAlign.center, - style: TextStyle( - foreground: Paint() - ..style = PaintingStyle.stroke - ..strokeWidth = 0.8 - ..color = Colors.black38, - ), - ), - AutoSizeText( - deviceText, - textAlign: TextAlign.center, - maxLines: 1, - style: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ], - ), - const SizedBox( - height: 10, - ), - ], - ), - ), - ); - } - - List extractDevicesId() { - final List devicesIdList = []; - for (final element in printersInRoom) { - devicesIdList.add(element.uniqueId.getOrCrash()); - } - return devicesIdList; - } -} diff --git a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/security_cameras_in_the_room_block.dart b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/security_cameras_in_the_room_block.dart deleted file mode 100644 index e7ac3e118..000000000 --- a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/security_cameras_in_the_room_block.dart +++ /dev/null @@ -1,162 +0,0 @@ -import 'package:auto_route/auto_route.dart'; -import 'package:auto_size_text/auto_size_text.dart'; -import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_security_camera_entity/generic_security_camera_entity.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; -import 'package:cybear_jinni/presentation/core/theme_data.dart'; -import 'package:easy_localization/easy_localization.dart'; -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; - -class SecurityCamerasInTheRoomBlock extends StatelessWidget { - const SecurityCamerasInTheRoomBlock({ - required this.roomEntity, - required this.securityCamerasInRoom, - required this.roomColorGradiant, - }); - - factory SecurityCamerasInTheRoomBlock.withAbstractDevice({ - required RoomEntity roomEntityTemp, - required List tempDeviceInRoom, - required ListOfColors tempRoomColorGradiant, - }) { - final List tempSecurityCamerasInRoom = []; - - for (final element in tempDeviceInRoom) { - tempSecurityCamerasInRoom.add(element as GenericSecurityCameraDE); - } - - return SecurityCamerasInTheRoomBlock( - roomEntity: roomEntityTemp, - securityCamerasInRoom: tempSecurityCamerasInRoom, - roomColorGradiant: tempRoomColorGradiant, - ); - } - - final RoomEntity roomEntity; - final List securityCamerasInRoom; - final ListOfColors roomColorGradiant; - - @override - Widget build(BuildContext context) { - String deviceText; - if (securityCamerasInRoom.length == 1) { - deviceText = securityCamerasInRoom[0].cbjEntityName.getOrCrash()!; - } else { - deviceText = - '_SecurityCameras'.tr(args: [roomEntity.cbjEntityName.getOrCrash()]); - } - - return GestureDetector( - onTap: () { - context.router.push( - VideoStreamOutputContainerRoute( - streamAddress: - securityCamerasInRoom.first.deviceLastKnownIp.getOrCrash()!, - ), - ); - }, - child: Container( - decoration: BoxDecoration( - color: Colors.amber.withOpacity(0.03), - borderRadius: const BorderRadius.all(Radius.circular(20)), - ), - margin: const EdgeInsets.symmetric(horizontal: 5), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Expanded(child: TextAtom('')), - Expanded( - child: Column( - children: [ - const SizedBox(height: 10), - Transform.scale( - scale: 1.2, - child: const CircleAvatar( - child: FaIcon( - FontAwesomeIcons.camera, - color: Colors.white70, - ), - ), - ), - ], - ), - ), - if (securityCamerasInRoom.length > 1) - Expanded( - child: Container( - height: 55, - alignment: Alignment.topLeft, - child: Container( - width: 28, - decoration: BoxDecoration( - border: Border.all( - color: Theme.of(context) - .textTheme - .bodyLarge! - .color! - .withOpacity(0.5), - ), - borderRadius: BorderRadius.circular(10), - ), - child: TextAtom( - securityCamerasInRoom.length.toString(), - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 13, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ), - ), - ) - else - const Expanded(child: TextAtom('')), - ], - ), - const SizedBox(height: 5), - Stack( - children: [ - AutoSizeText( - deviceText, - maxLines: 1, - textAlign: TextAlign.center, - style: TextStyle( - foreground: Paint() - ..style = PaintingStyle.stroke - ..strokeWidth = 0.8 - ..color = Colors.black38, - ), - ), - AutoSizeText( - deviceText, - textAlign: TextAlign.center, - maxLines: 1, - style: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ], - ), - const SizedBox( - height: 10, - ), - ], - ), - ), - ); - } - - List extractDevicesId() { - final List devicesIdList = []; - for (final element in securityCamerasInRoom) { - devicesIdList.add(element.uniqueId.getOrCrash()); - } - return devicesIdList; - } -} diff --git a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/smart_computers_in_the_room_block.dart b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/smart_computers_in_the_room_block.dart deleted file mode 100644 index c2663c5b8..000000000 --- a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/smart_computers_in_the_room_block.dart +++ /dev/null @@ -1,162 +0,0 @@ -import 'package:auto_route/auto_route.dart'; -import 'package:auto_size_text/auto_size_text.dart'; -import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; -import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_smart_computer_entity/generic_smart_computer_entity.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; -import 'package:cybear_jinni/presentation/core/theme_data.dart'; -import 'package:easy_localization/easy_localization.dart'; -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; - -class SmartComputersInTheRoomBlock extends StatelessWidget { - const SmartComputersInTheRoomBlock({ - required this.roomEntity, - required this.smartComputersInRoom, - required this.roomColorGradiant, - }); - - factory SmartComputersInTheRoomBlock.withAbstractDevice({ - required RoomEntity roomEntityTemp, - required List tempDeviceInRoom, - required ListOfColors tempRoomColorGradiant, - }) { - final List tempSmartComputersInRoom = []; - - for (final element in tempDeviceInRoom) { - tempSmartComputersInRoom.add(element as GenericSmartComputerDE); - } - - return SmartComputersInTheRoomBlock( - roomEntity: roomEntityTemp, - smartComputersInRoom: tempSmartComputersInRoom, - roomColorGradiant: tempRoomColorGradiant, - ); - } - - final RoomEntity roomEntity; - final List smartComputersInRoom; - final ListOfColors roomColorGradiant; - - @override - Widget build(BuildContext context) { - String deviceText; - if (smartComputersInRoom.length == 1) { - deviceText = smartComputersInRoom[0].cbjEntityName.getOrCrash()!; - } else { - deviceText = - '_SmartComputers'.tr(args: [roomEntity.cbjEntityName.getOrCrash()]); - } - - return GestureDetector( - onTap: () { - context.router.push( - DevicesInRoomRoute( - entityTypes: const {EntityTypes.smartComputer}, - roomEntity: roomEntity, - roomColorGradiant: roomColorGradiant, - ), - ); - }, - child: Container( - decoration: BoxDecoration( - color: Colors.amber.withOpacity(0.03), - borderRadius: const BorderRadius.all(Radius.circular(20)), - ), - margin: const EdgeInsets.symmetric(horizontal: 5), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Expanded(child: TextAtom('')), - Expanded( - child: Column( - children: [ - const SizedBox(height: 10), - Transform.scale( - scale: 1.2, - child: const CircleAvatar( - child: FaIcon( - FontAwesomeIcons.computer, - color: Colors.white70, - ), - ), - ), - ], - ), - ), - if (smartComputersInRoom.length > 1) - Expanded( - child: Container( - height: 55, - alignment: Alignment.topLeft, - child: Container( - width: 28, - decoration: BoxDecoration( - border: Border.all( - color: Theme.of(context) - .textTheme - .bodyLarge! - .color! - .withOpacity(0.5), - ), - borderRadius: BorderRadius.circular(10), - ), - child: TextAtom( - smartComputersInRoom.length.toString(), - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 13, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ), - ), - ) - else - const Expanded(child: TextAtom('')), - ], - ), - const SizedBox(height: 5), - Stack( - children: [ - AutoSizeText( - deviceText, - maxLines: 1, - style: TextStyle( - foreground: Paint() - ..style = PaintingStyle.stroke - ..strokeWidth = 0.8 - ..color = Colors.black38, - ), - ), - AutoSizeText( - deviceText, - maxLines: 1, - style: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ], - ), - const SizedBox( - height: 10, - ), - ], - ), - ), - ); - } - - List extractDevicesId() { - final List devicesIdList = []; - for (final element in smartComputersInRoom) { - devicesIdList.add(element.uniqueId.getOrCrash()); - } - return devicesIdList; - } -} diff --git a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/smart_plug_in_the_room_block.dart b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/smart_plug_in_the_room_block.dart deleted file mode 100644 index b53c367bb..000000000 --- a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/smart_plug_in_the_room_block.dart +++ /dev/null @@ -1,284 +0,0 @@ -import 'dart:collection'; - -import 'package:another_flushbar/flushbar_helper.dart'; -import 'package:auto_route/auto_route.dart'; -import 'package:auto_size_text/auto_size_text.dart'; -import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; -import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/entity_type_utils.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_smart_plug_entity/generic_smart_plug_entity.dart'; -import 'package:cybear_jinni/domain/connections_service.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; -import 'package:cybear_jinni/presentation/core/theme_data.dart'; -import 'package:easy_localization/easy_localization.dart'; -import 'package:flutter/material.dart'; -import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; - -class SmartPlugsInTheRoomBlock extends StatefulWidget { - const SmartPlugsInTheRoomBlock({ - required this.roomEntity, - required this.smartPlugsInRoom, - required this.roomColorGradiant, - required this.entities, - }); - - factory SmartPlugsInTheRoomBlock.withAbstractDevice({ - required RoomEntity roomEntityTemp, - required List entities, - required ListOfColors tempRoomColorGradiant, - }) { - final List tempSmartPlugsInRoom = []; - - for (final element in entities) { - tempSmartPlugsInRoom.add(element as GenericSmartPlugDE); - } - - return SmartPlugsInTheRoomBlock( - roomEntity: roomEntityTemp, - smartPlugsInRoom: tempSmartPlugsInRoom, - roomColorGradiant: tempRoomColorGradiant, - entities: entities, - ); - } - - final RoomEntity roomEntity; - final List smartPlugsInRoom; - final ListOfColors roomColorGradiant; - final List entities; - - @override - State createState() => - _SmartPlugsInTheRoomBlockState(); -} - -class _SmartPlugsInTheRoomBlockState extends State { - Future _turnOffAllSmartPlugs() async { - FlushbarHelper.createLoading( - message: 'Turning Off all smartPlugs', - linearProgressIndicator: const LinearProgressIndicator(), - ).show(context); - - setEntityState(EntityActions.off); - } - - Future _turnOnAllSmartPlugs() async { - FlushbarHelper.createLoading( - message: 'Turning On all smartPlugs', - linearProgressIndicator: const LinearProgressIndicator(), - ).show(context); - - setEntityState(EntityActions.on); - } - - void setEntityState(EntityActions action) { - final VendorsAndServices? vendor = - widget.entities.first.cbjDeviceVendor.vendorsAndServices; - if (vendor == null) { - return; - } - - ConnectionsService.instance.setEntityState( - uniqueIdByVendor: getUniqueIdByVendor(), - property: EntityProperties.smartPlugState, - actionType: action, - ); - } - - HashMap>? _uniqueIdByVendor; - - HashMap> getUniqueIdByVendor() { - if (_uniqueIdByVendor != null) { - return _uniqueIdByVendor!; - } - - final HashMap> uniqueIdByVendor = - HashMap(); - for (final DeviceEntityBase? element in widget.entities) { - final VendorsAndServices? vendor = - element?.cbjDeviceVendor.vendorsAndServices; - - if (vendor == null) { - continue; - } - final HashSet idsInVendor = - uniqueIdByVendor[vendor] ??= HashSet(); - - final String deviceCbjUniqueId = element!.deviceCbjUniqueId.getOrCrash(); - - idsInVendor.add(deviceCbjUniqueId); - - uniqueIdByVendor.addEntries([MapEntry(vendor, idsInVendor)]); - } - return _uniqueIdByVendor = uniqueIdByVendor; - } - - @override - Widget build(BuildContext context) { - String deviceText; - if (widget.smartPlugsInRoom.length == 1) { - deviceText = widget.smartPlugsInRoom[0].cbjEntityName.getOrCrash()!; - } else { - deviceText = '_SmartPlugs' - .tr(args: [widget.roomEntity.cbjEntityName.getOrCrash()]); - } - - return GestureDetector( - onTap: () { - context.router.push( - DevicesInRoomRoute( - entityTypes: const {EntityTypes.smartPlug}, - roomEntity: widget.roomEntity, - roomColorGradiant: widget.roomColorGradiant, - ), - ); - }, - child: Container( - decoration: BoxDecoration( - color: Colors.amber.withOpacity(0.03), - borderRadius: const BorderRadius.all(Radius.circular(20)), - ), - margin: const EdgeInsets.symmetric(horizontal: 5), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Expanded(child: TextAtom('')), - Expanded( - child: Column( - children: [ - const SizedBox(height: 10), - Transform.scale( - scale: 1.2, - child: CircleAvatar( - child: Icon( - MdiIcons.powerSocketAu, - color: Colors.white70, - ), - ), - ), - ], - ), - ), - if (widget.smartPlugsInRoom.length > 1) - Expanded( - child: Container( - height: 55, - alignment: Alignment.topLeft, - child: Container( - width: 28, - decoration: BoxDecoration( - border: Border.all( - color: Theme.of(context) - .textTheme - .bodyLarge! - .color! - .withOpacity(0.5), - ), - borderRadius: BorderRadius.circular(10), - ), - child: TextAtom( - widget.smartPlugsInRoom.length.toString(), - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 13, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ), - ), - ) - else - const Expanded(child: TextAtom('')), - ], - ), - const SizedBox(height: 5), - Stack( - children: [ - AutoSizeText( - deviceText, - maxLines: 1, - style: TextStyle( - foreground: Paint() - ..style = PaintingStyle.stroke - ..strokeWidth = 0.8 - ..color = Colors.black38, - ), - ), - AutoSizeText( - deviceText, - maxLines: 1, - style: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ], - ), - const SizedBox( - height: 10, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - TextButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( - Colors.grey.withOpacity(0.6), - ), - side: MaterialStateProperty.all( - const BorderSide(width: 0.2), - ), - ), - onPressed: _turnOffAllSmartPlugs, - child: TextAtom( - 'Off', - style: TextStyle( - fontSize: 14, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ), - TextAtom( - '·', - style: TextStyle( - fontSize: 14, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - TextButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( - Colors.grey.withOpacity(0.6), - ), - side: MaterialStateProperty.all( - const BorderSide(width: 0.2), - ), - ), - onPressed: _turnOnAllSmartPlugs, - child: TextAtom( - 'On', - style: TextStyle( - fontSize: 14, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ), - ], - ), - ], - ), - ), - ); - } - - List extractDevicesId() { - final List devicesIdList = []; - for (final element in widget.smartPlugsInRoom) { - devicesIdList.add(element.uniqueId.getOrCrash()); - } - return devicesIdList; - } -} diff --git a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/smart_tv_in_the_room.dart b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/smart_tv_in_the_room.dart deleted file mode 100644 index 7c625868a..000000000 --- a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/smart_tv_in_the_room.dart +++ /dev/null @@ -1,159 +0,0 @@ -import 'package:auto_route/auto_route.dart'; -import 'package:auto_size_text/auto_size_text.dart'; -import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; -import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_smart_tv_entity/generic_smart_tv_entity.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; -import 'package:cybear_jinni/presentation/core/theme_data.dart'; -import 'package:easy_localization/easy_localization.dart'; -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; - -class SmartTvInTheRoom extends StatelessWidget { - const SmartTvInTheRoom({ - required this.roomEntity, - this.smartTvsInRoom, - this.roomColorGradiant, - }); - - factory SmartTvInTheRoom.withAbstractDevice({ - required RoomEntity roomEntity, - required List tempDeviceInRoom, - required ListOfColors tempRoomColorGradiant, - }) { - final List tempLightsInRoom = []; - - for (final element in tempDeviceInRoom) { - tempLightsInRoom.add(element as GenericSmartTvDE); - } - - return SmartTvInTheRoom( - roomEntity: roomEntity, - smartTvsInRoom: tempLightsInRoom, - roomColorGradiant: tempRoomColorGradiant, - ); - } - - final RoomEntity roomEntity; - final List? smartTvsInRoom; - final ListOfColors? roomColorGradiant; - - @override - Widget build(BuildContext context) { - String deviceText; - if (smartTvsInRoom!.length == 1) { - deviceText = smartTvsInRoom![0].cbjEntityName.getOrCrash()!; - } else { - deviceText = - '_SmartTvs'.tr(args: [roomEntity.cbjEntityName.getOrCrash()]); - } - - return GestureDetector( - onTap: () { - context.router.push( - DevicesInRoomRoute( - entityTypes: const {EntityTypes.smartTV}, - roomEntity: roomEntity, - roomColorGradiant: roomColorGradiant, - ), - ); - }, - child: Container( - decoration: BoxDecoration( - color: Colors.amber.withOpacity(0.03), - borderRadius: const BorderRadius.all(Radius.circular(20)), - ), - margin: const EdgeInsets.all(5), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Expanded(child: TextAtom('')), - Expanded( - child: Column( - children: [ - const SizedBox(height: 10), - Transform.scale( - scale: 1.2, - child: const CircleAvatar( - child: FaIcon( - FontAwesomeIcons.tv, - color: Colors.green, - ), - ), - ), - ], - ), - ), - if (smartTvsInRoom!.length > 1) - Expanded( - child: Container( - height: 55, - alignment: Alignment.topLeft, - child: Container( - width: 28, - decoration: BoxDecoration( - border: Border.all( - color: Theme.of(context) - .textTheme - .bodyLarge! - .color! - .withOpacity(0.5), - ), - borderRadius: BorderRadius.circular(10), - ), - child: TextAtom( - smartTvsInRoom!.length.toString(), - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 13, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ), - ), - ) - else - const Expanded(child: TextAtom('')), - ], - ), - const SizedBox(height: 10), - Stack( - children: [ - AutoSizeText( - deviceText, - maxLines: 1, - style: TextStyle( - foreground: Paint() - ..style = PaintingStyle.stroke - ..strokeWidth = 0.8 - ..color = Colors.black38, - ), - ), - AutoSizeText( - deviceText, - maxLines: 1, - style: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ], - ), - ], - ), - ), - ); - } - - List extractDevicesId() { - final List devicesIdList = []; - for (final element in smartTvsInRoom!) { - devicesIdList.add(element.uniqueId.getOrCrash()); - } - return devicesIdList; - } -} diff --git a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/switches_in_the_room_block.dart b/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/switches_in_the_room_block.dart deleted file mode 100644 index 27d1e632f..000000000 --- a/lib/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/switches_in_the_room_block.dart +++ /dev/null @@ -1,299 +0,0 @@ -import 'dart:collection'; - -import 'package:another_flushbar/flushbar_helper.dart'; -import 'package:auto_route/auto_route.dart'; -import 'package:auto_size_text/auto_size_text.dart'; -import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; -import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/entity_type_utils.dart'; -import 'package:cbj_integrations_controller/infrastructure/generic_entities/generic_switch_entity/generic_switch_entity.dart'; -import 'package:cybear_jinni/domain/connections_service.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; -import 'package:cybear_jinni/presentation/core/theme_data.dart'; -import 'package:easy_localization/easy_localization.dart'; -import 'package:flutter/material.dart'; -import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; - -class SwitchesInTheRoomBlock extends StatefulWidget { - const SwitchesInTheRoomBlock({ - required this.roomEntity, - required this.switchesInRoom, - required this.roomColorGradiant, - required this.entities, - }); - - factory SwitchesInTheRoomBlock.withAbstractDevice({ - required RoomEntity roomEntityTemp, - required List entities, - required ListOfColors tempRoomColorGradiant, - }) { - final List tempSwitchesInRoom = []; - - for (final element in entities) { - tempSwitchesInRoom.add(element as GenericSwitchDE); - } - - return SwitchesInTheRoomBlock( - roomEntity: roomEntityTemp, - switchesInRoom: tempSwitchesInRoom, - roomColorGradiant: tempRoomColorGradiant, - entities: entities, - ); - } - - final RoomEntity roomEntity; - final List switchesInRoom; - final ListOfColors roomColorGradiant; - final List entities; - - @override - State createState() => _SwitchesInTheRoomBlockState(); -} - -class _SwitchesInTheRoomBlockState extends State { - Future _turnOffAllSwitches( - BuildContext context, - List? switchesIdToTurnOff, - ) async { - FlushbarHelper.createLoading( - message: 'Turning Off all switches', - linearProgressIndicator: const LinearProgressIndicator(), - ).show(context); - - setEntityState(EntityActions.off); - } - - Future _turnOnAllSwitches( - BuildContext context, - List? switchesIdToTurnOn, - ) async { - FlushbarHelper.createLoading( - message: 'Turning On all switches', - linearProgressIndicator: const LinearProgressIndicator(), - ).show(context); - - setEntityState(EntityActions.on); - } - - void setEntityState(EntityActions action) { - final VendorsAndServices? vendor = - widget.entities.first.cbjDeviceVendor.vendorsAndServices; - if (vendor == null) { - return; - } - - ConnectionsService.instance.setEntityState( - uniqueIdByVendor: getUniqueIdByVendor(), - property: EntityProperties.switchState, - actionType: action, - ); - } - - HashMap>? _uniqueIdByVendor; - - HashMap> getUniqueIdByVendor() { - if (_uniqueIdByVendor != null) { - return _uniqueIdByVendor!; - } - - final HashMap> uniqueIdByVendor = - HashMap(); - for (final DeviceEntityBase? element in widget.entities) { - final VendorsAndServices? vendor = - element?.cbjDeviceVendor.vendorsAndServices; - - if (vendor == null) { - continue; - } - final HashSet idsInVendor = - uniqueIdByVendor[vendor] ??= HashSet(); - - final String deviceCbjUniqueId = element!.deviceCbjUniqueId.getOrCrash(); - - idsInVendor.add(deviceCbjUniqueId); - - uniqueIdByVendor.addEntries([MapEntry(vendor, idsInVendor)]); - } - return _uniqueIdByVendor = uniqueIdByVendor; - } - - @override - Widget build(BuildContext context) { - String deviceText; - if (widget.switchesInRoom.length == 1) { - deviceText = widget.switchesInRoom[0].cbjEntityName.getOrCrash()!; - } else { - deviceText = - '_Switches'.tr(args: [widget.roomEntity.cbjEntityName.getOrCrash()]); - } - - return GestureDetector( - onTap: () { - context.router.push( - DevicesInRoomRoute( - entityTypes: const {EntityTypes.switch_}, - roomEntity: widget.roomEntity, - roomColorGradiant: widget.roomColorGradiant, - ), - ); - }, - child: Container( - decoration: BoxDecoration( - color: Colors.amber.withOpacity(0.03), - borderRadius: const BorderRadius.all(Radius.circular(20)), - ), - margin: const EdgeInsets.symmetric(horizontal: 5), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Expanded(child: TextAtom('')), - Expanded( - child: Column( - children: [ - const SizedBox(height: 10), - Transform.scale( - scale: 1.2, - child: CircleAvatar( - child: Icon( - MdiIcons.lightSwitch, - color: Colors.white70, - ), - ), - ), - ], - ), - ), - if (widget.switchesInRoom.length > 1) - Expanded( - child: Container( - height: 55, - alignment: Alignment.topLeft, - child: Container( - width: 28, - decoration: BoxDecoration( - border: Border.all( - color: Theme.of(context) - .textTheme - .bodyLarge! - .color! - .withOpacity(0.5), - ), - borderRadius: BorderRadius.circular(10), - ), - child: TextAtom( - widget.switchesInRoom.length.toString(), - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 13, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ), - ), - ) - else - const Expanded(child: TextAtom('')), - ], - ), - const SizedBox(height: 5), - Stack( - children: [ - AutoSizeText( - deviceText, - maxLines: 1, - style: TextStyle( - foreground: Paint() - ..style = PaintingStyle.stroke - ..strokeWidth = 0.8 - ..color = Colors.black38, - ), - ), - AutoSizeText( - deviceText, - maxLines: 1, - style: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ], - ), - const SizedBox( - height: 10, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - TextButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( - Colors.grey.withOpacity(0.6), - ), - side: MaterialStateProperty.all( - const BorderSide(width: 0.2), - ), - ), - onPressed: () { - _turnOffAllSwitches( - context, - extractDevicesId(), - ); - }, - child: TextAtom( - 'Off', - style: TextStyle( - fontSize: 14, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ), - TextAtom( - '·', - style: TextStyle( - fontSize: 14, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - TextButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( - Colors.grey.withOpacity(0.6), - ), - side: MaterialStateProperty.all( - const BorderSide(width: 0.2), - ), - ), - onPressed: () { - _turnOnAllSwitches( - context, - extractDevicesId(), - ); - }, - child: TextAtom( - 'On', - style: TextStyle( - fontSize: 14, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ), - ], - ), - ], - ), - ), - ); - } - - List extractDevicesId() { - final List devicesIdList = []; - for (final element in widget.switchesInRoom) { - devicesIdList.add(element.uniqueId.getOrCrash()); - } - return devicesIdList; - } -} diff --git a/lib/presentation/pages/home_page/tabs/smart_devices_tab/rooms_widgets/rom_widget.dart b/lib/presentation/pages/home_page/tabs/smart_devices_tab/rooms_widgets/rom_widget.dart index 55abf613b..f68c1d0a6 100644 --- a/lib/presentation/pages/home_page/tabs/smart_devices_tab/rooms_widgets/rom_widget.dart +++ b/lib/presentation/pages/home_page/tabs/smart_devices_tab/rooms_widgets/rom_widget.dart @@ -1,23 +1,12 @@ import 'dart:collection'; -import 'package:another_flushbar/flushbar_helper.dart'; +import 'package:auto_route/auto_route.dart'; import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; -import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; -import 'package:cybear_jinni/infrastructure/core/logger.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/theme_data.dart'; -import 'package:cybear_jinni/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/blinds_in_the_room.dart'; -import 'package:cybear_jinni/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/boilers_in_the_room.dart'; -import 'package:cybear_jinni/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/lights_in_the_room_block.dart'; -import 'package:cybear_jinni/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/printers_in_the_room_block.dart'; -import 'package:cybear_jinni/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/security_cameras_in_the_room_block.dart'; -import 'package:cybear_jinni/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/smart_computers_in_the_room_block.dart'; -import 'package:cybear_jinni/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/smart_plug_in_the_room_block.dart'; -import 'package:cybear_jinni/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/smart_tv_in_the_room.dart'; -import 'package:cybear_jinni/presentation/pages/home_page/tabs/smart_devices_tab/devices_in_the_room_blocks/switches_in_the_room_block.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.gr.dart'; +import 'package:cybearjinni/presentation/organisms/organisms.dart'; import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; class RoomWidget extends StatefulWidget { const RoomWidget({ @@ -25,19 +14,9 @@ class RoomWidget extends StatefulWidget { required this.rooms, required this.entities, required this.entitiesInTheRoom, - required this.bottomMargin, - required this.leftMargin, - required this.rightMargin, - required this.borderRadius, - required this.roomColorGradiant, }); final RoomEntity room; - final double bottomMargin; - final double leftMargin; - final double rightMargin; - final double borderRadius; - final ListOfColors roomColorGradiant; final HashMap rooms; final Set entitiesInTheRoom; final HashMap entities; @@ -52,188 +31,61 @@ class _RoomWidgetState extends State { if (widget.entitiesInTheRoom.isEmpty) { return const SizedBox(); } + + final ThemeData themeData = Theme.of(context); + final TextTheme textTheme = themeData.textTheme; + final ColorScheme colorScheme = themeData.colorScheme; + final int numberOfDevicesInTheRoom = widget.entitiesInTheRoom.length; - return Container( - margin: EdgeInsets.only( - bottom: widget.bottomMargin, - left: widget.leftMargin, - right: widget.rightMargin, - ), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: widget.roomColorGradiant.listOfColors!.toList(), - begin: Alignment.bottomLeft, - end: Alignment.topLeft, - ), - color: Colors.white, - borderRadius: BorderRadius.circular(widget.borderRadius), - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.6), - spreadRadius: 2, - blurRadius: 5, - offset: const Offset(0, 3), - ), - ], - ), - child: AnimatedSize( - duration: const Duration(milliseconds: 300), - child: Container( - margin: const EdgeInsets.all(3), - decoration: BoxDecoration( - color: Colors.black.withOpacity(0.07), - borderRadius: BorderRadius.circular(widget.borderRadius), - ), - child: Column( - children: [ - Container( - margin: const EdgeInsets.only(top: 12), - alignment: Alignment.topCenter, - child: Stack( - children: [ - TextAtom( - widget.room.cbjEntityName.getOrCrash(), - style: TextStyle( - fontSize: 23, - foreground: Paint() - ..style = PaintingStyle.stroke - ..strokeWidth = 1.2 - ..color = Colors.black, - ), - ), - TextAtom( - widget.room.cbjEntityName.getOrCrash(), - style: TextStyle( - fontSize: 23, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ], + return AnimatedSize( + duration: const Duration(milliseconds: 300), + child: Column( + children: [ + TextButton( + onPressed: () { + context.router.push( + EntitiesInRoomRoute( + entityTypes: const {}, + roomEntity: widget.room, ), + ); + }, + child: Container( + margin: const EdgeInsets.symmetric(horizontal: 5), + child: Row( + children: [ + TextAtom( + widget.room.cbjEntityName.getOrCrash(), + style: textTheme.headlineSmall! + .copyWith(color: colorScheme.secondary), + ), + const Expanded( + child: SizedBox(), + ), + TextAtom( + numberOfDevicesInTheRoom >= 2 + ? numberOfDevicesInTheRoom.toString() + : '', + style: textTheme.bodyLarge, + ), + ], ), - if (numberOfDevicesInTheRoom == 1) - TextAtom( - '_device', - style: const TextStyle(fontSize: 12), - translationArgs: [numberOfDevicesInTheRoom.toString()], - ) - else - TextAtom( - '_devices', - style: const TextStyle(fontSize: 12), - translationArgs: [numberOfDevicesInTheRoom.toString()], - ), - - /// Build the devices in the room by type - GridView.builder( - padding: EdgeInsets.zero, - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent( - maxCrossAxisExtent: 200, - childAspectRatio: 1.2, - crossAxisSpacing: 10, - mainAxisSpacing: 15, + ), + ), + const SeparatorAtom(variant: SeparatorVariant.closeWidgets), + DevicesListView( + HashSet.from(widget.entities.values), + (entity) { + context.router.push( + EntitiesInRoomRoute( + entityTypes: entity, + roomEntity: widget.room, ), - itemCount: widget.entitiesInTheRoom.length, - itemBuilder: (BuildContext ctx, secondIndex) { - final DeviceEntityBase? entity = widget.entities[ - widget.entitiesInTheRoom.elementAt(secondIndex)]; - if (entity == null) { - return const SizedBox(); - } - - final EntityTypes deviceType = entity.entityTypes.type; - - if (deviceType == EntityTypes.light || - deviceType == EntityTypes.dimmableLight || - deviceType == EntityTypes.rgbwLights) { - return LightsInTheRoomBlock.withAbstractDevice( - roomEntity: widget.room, - entities: [entity], - tempRoomColorGradiant: widget.roomColorGradiant, - ); - } else if (deviceType == EntityTypes.switch_) { - return SwitchesInTheRoomBlock.withAbstractDevice( - roomEntityTemp: widget.room, - entities: [entity], - tempRoomColorGradiant: widget.roomColorGradiant, - ); - } else if (deviceType == EntityTypes.blinds) { - return BlindsInTheRoom.withAbstractDevice( - roomEntity: widget.room, - tempDeviceInRoom: [entity], - tempRoomColorGradiant: widget.roomColorGradiant, - ); - } else if (deviceType == EntityTypes.boiler) { - return BoilersInTheRoom.withAbstractDevice( - roomEntity: widget.room, - tempDeviceInRoom: [entity], - tempRoomColorGradiant: widget.roomColorGradiant, - ); - } else if (deviceType == EntityTypes.smartTV) { - return SmartTvInTheRoom.withAbstractDevice( - roomEntity: widget.room, - tempDeviceInRoom: [entity], - tempRoomColorGradiant: widget.roomColorGradiant, - ); - } else if (deviceType == EntityTypes.smartPlug) { - return SmartPlugsInTheRoomBlock.withAbstractDevice( - roomEntityTemp: widget.room, - entities: [entity], - tempRoomColorGradiant: widget.roomColorGradiant, - ); - } else if (deviceType == EntityTypes.smartComputer) { - return SmartComputersInTheRoomBlock.withAbstractDevice( - roomEntityTemp: widget.room, - tempDeviceInRoom: [entity], - tempRoomColorGradiant: widget.roomColorGradiant, - ); - } else if (deviceType == EntityTypes.printer) { - return PrintersInTheRoomBlock.withAbstractDevice( - roomEntityTemp: widget.room, - tempDeviceInRoom: [entity], - tempRoomColorGradiant: widget.roomColorGradiant, - ); - } else if (deviceType == EntityTypes.securityCamera) { - return SecurityCamerasInTheRoomBlock.withAbstractDevice( - roomEntityTemp: widget.room, - tempDeviceInRoom: [entity], - tempRoomColorGradiant: widget.roomColorGradiant, - ); - } - - logger.w('Arrived here unsupported device type $deviceType'); - - return TextButton( - onPressed: () { - FlushbarHelper.createInformation( - message: - 'This device is not supported\nName: ${entity.cbjEntityName.getOrCrash()}', - ).show(context); - }, - child: const Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - CircleAvatar( - child: FaIcon( - FontAwesomeIcons.eyeLowVision, - color: Colors.red, - ), - ), - TextAtom( - 'Unsupported Type', - style: TextStyle(color: Colors.white), - ), - ], - ), - ); - }, - ), - ], + ); + }, ), - ), + ], ), ); } diff --git a/lib/presentation/pages/home_page/tabs/smart_devices_tab/rooms_widgets/rooms_list_view_widget.dart b/lib/presentation/pages/home_page/tabs/smart_devices_tab/rooms_widgets/rooms_list_view_widget.dart index 01273436c..416f8eda1 100644 --- a/lib/presentation/pages/home_page/tabs/smart_devices_tab/rooms_widgets/rooms_list_view_widget.dart +++ b/lib/presentation/pages/home_page/tabs/smart_devices_tab/rooms_widgets/rooms_list_view_widget.dart @@ -2,8 +2,7 @@ import 'dart:collection'; import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; -import 'package:cybear_jinni/presentation/core/theme_data.dart'; -import 'package:cybear_jinni/presentation/pages/home_page/tabs/smart_devices_tab/rooms_widgets/rom_widget.dart'; +import 'package:cybearjinni/presentation/pages/home_page/tabs/smart_devices_tab/rooms_widgets/rom_widget.dart'; import 'package:flutter/material.dart'; class RoomsListViewWidget extends StatelessWidget { @@ -30,12 +29,6 @@ class RoomsListViewWidget extends StatelessWidget { final HashMap> devicesByRooms = initialzeEntitiesByRooms(); - int gradientColorCounter = 1; - - ListOfColors roomColorGradiant = ListOfColors( - gradientColorsList.elementAt(gradientColorCounter).toSet(), - ); - return ListView.builder( shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), @@ -49,46 +42,11 @@ class RoomsListViewWidget extends StatelessWidget { return const SizedBox(); } - double bottomMargin = 15; - double leftMargin = 0; - double rightMargin = 0; - double borderRadius = 5; - - if (gradientColorCounter >= gradientColorsList.length) { - gradientColorCounter = 1; - } else { - gradientColorCounter++; - } - - roomColorGradiant = ListOfColors( - gradientColorsList.elementAt(gradientColorCounter).toSet(), - ); - - /// Color for Summary page - if (index == gradientColorsList.length - 1) { - leftMargin = 10; - rightMargin = 10; - bottomMargin = 15; - borderRadius = 40; - - roomColorGradiant = ListOfColors(gradientColorsList.first.toSet()); - if (gradientColorCounter < 1) { - gradientColorCounter--; - } else { - gradientColorCounter = gradientColorsList.length; - } - bottomMargin = 0; - } return RoomWidget( room: room, rooms: rooms, entities: entities, entitiesInTheRoom: entitiesInTheRoom, - borderRadius: borderRadius, - bottomMargin: bottomMargin, - leftMargin: leftMargin, - rightMargin: rightMargin, - roomColorGradiant: roomColorGradiant, ); }, itemCount: devicesByRooms.length, diff --git a/lib/presentation/pages/home_page/tabs/smart_devices_tab/settings_page_of_smart_devices.dart b/lib/presentation/pages/home_page/tabs/smart_devices_tab/settings_page_of_smart_devices.dart index f71a98cf2..c74b7fba1 100644 --- a/lib/presentation/pages/home_page/tabs/smart_devices_tab/settings_page_of_smart_devices.dart +++ b/lib/presentation/pages/home_page/tabs/smart_devices_tab/settings_page_of_smart_devices.dart @@ -1,8 +1,7 @@ import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/molecules/molecules.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; class SettingsPageSmartDevices extends StatelessWidget { @@ -13,11 +12,6 @@ class SettingsPageSmartDevices extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - toolbarHeight: 0, - backgroundColor: Colors.black, - systemOverlayStyle: SystemUiOverlayStyle.dark, - ), body: Container( width: MediaQuery.of(context).size.width, decoration: BoxDecoration( diff --git a/lib/presentation/pages/home_page/tabs/smart_devices_tab/smart_devices_by_rooms.dart b/lib/presentation/pages/home_page/tabs/smart_devices_tab/smart_devices_by_rooms.dart index 9fed9ca52..1eddba309 100644 --- a/lib/presentation/pages/home_page/tabs/smart_devices_tab/smart_devices_by_rooms.dart +++ b/lib/presentation/pages/home_page/tabs/smart_devices_tab/smart_devices_by_rooms.dart @@ -5,11 +5,11 @@ import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; import 'package:cbj_integrations_controller/domain/room/value_objects_room.dart'; import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart'; import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; -import 'package:cybear_jinni/domain/connections_service.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/snack_bar_service.dart'; -import 'package:cybear_jinni/presentation/organisms/organisms.dart'; -import 'package:cybear_jinni/presentation/pages/home_page/tabs/smart_devices_tab/rooms_widgets/rooms_list_view_widget.dart'; +import 'package:cybearjinni/domain/connections_service.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/snack_bar_service.dart'; +import 'package:cybearjinni/presentation/organisms/organisms.dart'; +import 'package:cybearjinni/presentation/pages/home_page/tabs/smart_devices_tab/rooms_widgets/rooms_list_view_widget.dart'; import 'package:flutter/material.dart'; class SmartDevicesByRooms extends StatefulWidget { @@ -24,7 +24,7 @@ class _SmartDevicesByRoomsState extends State { @override void initState() { super.initState(); - addDiscoverdRoom(); + addDiscoveredRoom(); _watchEntities(); } @@ -34,7 +34,7 @@ class _SmartDevicesByRoomsState extends State { super.dispose(); } - void addDiscoverdRoom() { + void addDiscoveredRoom() { final RoomEntity discoveredRoom = RoomEntity( uniqueId: RoomUniqueId.discovered(), cbjEntityName: RoomDefaultName('Discovered'), @@ -129,42 +129,25 @@ class _SmartDevicesByRoomsState extends State { ); } + final ThemeData themeData = Theme.of(context); + final TextTheme textTheme = themeData.textTheme; + final ColorScheme colorScheme = themeData.colorScheme; + return SingleChildScrollView( reverse: true, child: Column( children: [ - Container( - padding: const EdgeInsets.symmetric(horizontal: 50), - margin: const EdgeInsets.symmetric(vertical: 20), - decoration: BoxDecoration( - color: Colors.black.withOpacity(0.2), - borderRadius: BorderRadius.circular(10), - ), - child: Stack( - children: [ - TextAtom( - 'Areas', - style: TextStyle( - fontSize: 35, - foreground: Paint() - ..style = PaintingStyle.stroke - ..strokeWidth = 3 - ..color = Colors.black.withOpacity(0.2), - ), - ), - TextAtom( - 'Areas', - style: TextStyle( - fontSize: 35, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ], - ), + TextAtom( + 'Areas', + style: + textTheme.headlineLarge!.copyWith(color: colorScheme.primary), ), - RoomsListViewWidget( - entities: devices, - rooms: rooms, + const SeparatorAtom(variant: SeparatorVariant.farAppart), + MarginedExpandedAtom( + child: RoomsListViewWidget( + entities: devices, + rooms: rooms, + ), ), ], ), diff --git a/lib/presentation/pages/home_page/tabs/smart_devices_tab/smart_devices_widgets.dart b/lib/presentation/pages/home_page/tabs/smart_devices_tab/smart_devices_widgets.dart index 179dd72aa..15a740832 100644 --- a/lib/presentation/pages/home_page/tabs/smart_devices_tab/smart_devices_widgets.dart +++ b/lib/presentation/pages/home_page/tabs/smart_devices_tab/smart_devices_widgets.dart @@ -1,9 +1,9 @@ import 'package:adaptive_action_sheet/adaptive_action_sheet.dart'; import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; -import 'package:cybear_jinni/presentation/molecules/molecules.dart'; -import 'package:cybear_jinni/presentation/pages/home_page/tabs/smart_devices_tab/smart_devices_by_rooms.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.gr.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; +import 'package:cybearjinni/presentation/pages/home_page/tabs/smart_devices_tab/smart_devices_by_rooms.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -15,7 +15,7 @@ class SmartDevicesWidgets extends StatelessWidget { actions: [ BottomSheetAction( title: const TextAtom( - '⚙️ Change Area For Devices', + '⚙️ Change Area For Entities', style: TextStyle(color: Colors.blueGrey, fontSize: 23), ), onPressed: (_) { @@ -40,7 +40,7 @@ class SmartDevicesWidgets extends StatelessWidget { return Column( children: [ TopBarMolecule( - pageName: 'Devices', + pageName: 'Entities', rightIcon: Icons.more_vert, rightIconFunction: userCogFunction, leftIcon: FontAwesomeIcons.solidLightbulb, diff --git a/lib/presentation/pages/introduction_screen/introduction_screen_body.dart b/lib/presentation/pages/introduction_screen/introduction_screen_body.dart index fd132d3a9..2b9d98497 100644 --- a/lib/presentation/pages/introduction_screen/introduction_screen_body.dart +++ b/lib/presentation/pages/introduction_screen/introduction_screen_body.dart @@ -1,36 +1,48 @@ +import 'dart:collection'; + import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; -import 'package:cybear_jinni/presentation/pages/introduction_screen/introductions_view_model_body/introduction_screen_body_about_page.dart'; -import 'package:cybear_jinni/presentation/pages/introduction_screen/introductions_view_model_body/introduction_screen_body_welcome_page.dart'; +import 'package:cbj_integrations_controller/infrastructure/generic_entities/abstract_entity/device_entity_base.dart'; +import 'package:cybearjinni/domain/connections_service.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.gr.dart'; +import 'package:cybearjinni/presentation/pages/introduction_screen/introductions_view_model_body/introduction_screen_body_about_page.dart'; +import 'package:cybearjinni/presentation/pages/introduction_screen/introductions_view_model_body/introduction_screen_body_welcome_page.dart'; import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; import 'package:introduction_screen/introduction_screen.dart'; -class IntroductionScreenBody extends StatelessWidget { +class IntroductionScreenBody extends StatefulWidget { + @override + State createState() => _IntroductionScreenBodyState(); +} + +class _IntroductionScreenBodyState extends State { @override Widget build(BuildContext context) { + final ThemeData themeData = Theme.of(context); + final TextTheme textTheme = themeData.textTheme; + + final Size screenSize = MediaQuery.of(context).size; + final double sizeWidth = screenSize.width; + final double sizeHeight = screenSize.height; + return Container( - decoration: const BoxDecoration( - // Box decoration takes a gradient + decoration: BoxDecoration( gradient: LinearGradient( - // Where the linear gradient begins and ends - begin: Alignment.topLeft, - end: Alignment.bottomRight, - // Add one stop for each color. Stops should increase from 0 to 1 - stops: [0.06, 0.9], + begin: Alignment.centerRight, + end: Alignment.centerLeft, + stops: const [0.06, 0.9], colors: [ - // Colors are easy thanks to Flutter's Colors class. - Colors.grey, - Colors.deepPurple, + HexColor('#ca6ce3'), + HexColor('#aa5fe4'), ], ), ), child: IntroductionScreen( - showNextButton: false, dotsDecorator: DotsDecorator( size: const Size.square(10.0), activeSize: const Size(20.0, 10.0), - activeColor: Theme.of(context).textTheme.bodyLarge!.color, + activeColor: Colors.white, color: Colors.black26, spacing: const EdgeInsets.symmetric(horizontal: 3.0), activeShape: RoundedRectangleBorder( @@ -40,51 +52,42 @@ class IntroductionScreenBody extends StatelessWidget { globalBackgroundColor: Colors.transparent, pages: [ PageViewModel( - titleWidget: Column( - children: [ - Container( - margin: const EdgeInsets.only(top: 20, bottom: 5), - child: const Center( - child: ImageAtom( - 'assets/cbj_logo.png', - height: 200.0, - ), + useScrollView: false, + titleWidget: const SizedBox(), + bodyWidget: SizedBox( + width: sizeWidth, + height: sizeHeight - 195, + child: Column( + children: [ + const Expanded( + child: SizedBox(), ), - ), - Stack( - children: [ - TextAtom( - 'CyBear Jinni', - style: TextStyle( - fontSize: 48, - foreground: Paint() - ..style = PaintingStyle.stroke - ..strokeWidth = 5 - ..color = Colors.pink.withOpacity(0.13), + const Expanded( + child: Center( + child: ImageAtom( + 'assets/cbj_logo.png', + hero: 'full_logo', ), ), - TextAtom( - 'CyBear Jinni', - style: TextStyle( - fontSize: 48, - color: Theme.of(context).textTheme.bodyLarge!.color, + ), + Expanded( + child: MarginedExpandedAtom( + child: Column( + children: [ + TextAtom( + 'CyBear Jinni', + style: textTheme.displaySmall! + .copyWith(color: Colors.white), + ), + const SeparatorAtom( + variant: SeparatorVariant.farAppart, + ), + IntroductionScreenBodyWelcomePage(), + ], ), ), - ], - ), - ], - ), - bodyWidget: IntroductionScreenBodyWelcomePage(), - decoration: PageDecoration( - titleTextStyle: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - fontSize: 25, - ), - pageColor: Colors.transparent, - bodyTextStyle: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - fontWeight: FontWeight.w700, - fontSize: 20.0, + ), + ], ), ), ), @@ -96,36 +99,31 @@ class IntroductionScreenBody extends StatelessWidget { ), TextAtom( 'Our Vision', - style: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - fontSize: 30, - ), + style: textTheme.displaySmall!.copyWith(color: Colors.white), ), ], ), bodyWidget: IntroductionScreenBodyAboutPage(), - decoration: PageDecoration( - titleTextStyle: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - fontSize: 30, - ), - pageColor: Colors.transparent, - bodyTextStyle: TextStyle( - color: Theme.of(context).textTheme.bodyLarge!.color, - fontWeight: FontWeight.w700, - fontSize: 20.0, - ), - ), ), ], + next: TextAtom( + 'Next', + style: textTheme.titleMedium!.copyWith(color: Colors.white), + ), done: TextAtom( 'Done', - style: TextStyle( - fontWeight: FontWeight.w600, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), + style: textTheme.titleMedium!.copyWith(color: Colors.white), ), - onDone: () { + onDone: () async { + final HashMap entities = + await ConnectionsService.instance.getAllEntities; + if (!mounted) { + return; + } + if (entities.isNotEmpty) { + context.router.replace(const HomeRoute()); + return; + } context.router.replace(const ConnectToHubRoute()); }, ), diff --git a/lib/presentation/pages/introduction_screen/introduction_screen_page.dart b/lib/presentation/pages/introduction_screen/introduction_screen_page.dart index 82f376bf5..7d4abaf4c 100644 --- a/lib/presentation/pages/introduction_screen/introduction_screen_page.dart +++ b/lib/presentation/pages/introduction_screen/introduction_screen_page.dart @@ -1,5 +1,5 @@ import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/presentation/pages/introduction_screen/introduction_screen_body.dart'; +import 'package:cybearjinni/presentation/pages/introduction_screen/introduction_screen_body.dart'; import 'package:flutter/material.dart'; @RoutePage() diff --git a/lib/presentation/pages/introduction_screen/introductions_view_model_body/introduction_screen_body_about_page.dart b/lib/presentation/pages/introduction_screen/introductions_view_model_body/introduction_screen_body_about_page.dart index 9b2464e0c..be5d241ca 100644 --- a/lib/presentation/pages/introduction_screen/introductions_view_model_body/introduction_screen_body_about_page.dart +++ b/lib/presentation/pages/introduction_screen/introductions_view_model_body/introduction_screen_body_about_page.dart @@ -1,18 +1,19 @@ -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; import 'package:flutter/material.dart'; class IntroductionScreenBodyAboutPage extends StatelessWidget { @override Widget build(BuildContext context) { + final ThemeData themeData = Theme.of(context); + final TextTheme textTheme = themeData.textTheme; + final ColorScheme colorScheme = themeData.colorScheme; + return Column( children: [ - const SizedBox( - height: 20, - ), + const SeparatorAtom(), Container( decoration: BoxDecoration( - color: - Theme.of(context).textTheme.bodyLarge!.color!.withOpacity(0.55), + color: colorScheme.background, border: Border.all( color: Theme.of(context).textTheme.bodyLarge!.color!, ), @@ -21,19 +22,24 @@ class IntroductionScreenBodyAboutPage extends StatelessWidget { ), child: Container( padding: const EdgeInsets.all(20), - child: const SingleChildScrollView( + child: SingleChildScrollView( child: TextAtom( - 'You are now starting a journey into the world of CyBear ' - 'Jinni.\n\nWe are trying to build an ecosystem of smart' + 'You are now starting a journey into the world of CyBear' + ' Jinni.\n\nWe are trying to build an ecosystem of smart' ' home that is built upon openness and trust.\n\n' - 'Our products are open source to show you that we ' - 'protect your privacy by default.\n\n' - 'The functionality of the devices will support local ' - 'WiFi execution whenever possible, this way you will' - ' be able to control your smart home even if you are' - ' disconnected from the world (as long as you are ' - 'connected to your home WiFi).\n', - style: TextStyle(fontSize: 17, color: Colors.black), + 'Our products are open source to show you that we' + ' protect your privacy by default.\n\n' + 'The functionality of the devices will support local' + ' WiFi execution whenever possible, this way you will' + ' be able to control your smart home reliably even if you are' + ' disconnected from the world or the vendor decided to' + ' drop support.\n\n' + 'For controlling out side of the home WiFi you will need a CBJ Hub which grants' + ' a lot of extra functionality (very recommended).\n' + 'You can create a Hub by following the simple documentation from the site.\n\n' + "Thanks for joining and let's continue to make the future better for everyone by choosing open-source technology.", + style: textTheme.bodyLarge! + .copyWith(color: colorScheme.onBackground), ), ), ), diff --git a/lib/presentation/pages/introduction_screen/introductions_view_model_body/introduction_screen_body_welcome_page.dart b/lib/presentation/pages/introduction_screen/introductions_view_model_body/introduction_screen_body_welcome_page.dart index 4bae29077..d91206d3c 100644 --- a/lib/presentation/pages/introduction_screen/introductions_view_model_body/introduction_screen_body_welcome_page.dart +++ b/lib/presentation/pages/introduction_screen/introductions_view_model_body/introduction_screen_body_welcome_page.dart @@ -1,126 +1,55 @@ import 'package:animated_text_kit/animated_text_kit.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; import 'package:flutter/material.dart'; class IntroductionScreenBodyWelcomePage extends StatelessWidget { @override Widget build(BuildContext context) { - return Column( - children: [ - SizedBox( - height: 60, - child: Row( - children: [ - TextAtom( - 'We', - style: TextStyle( - fontSize: 17.0, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - const SizedBox(width: 10.0), - AnimatedTextKit( - animatedTexts: [ - TypewriterAnimatedText( - 'are OPEN SOURCE', - textStyle: TextStyle( - fontSize: 20.0, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - TypewriterAnimatedText( - 'are FAIR', - textStyle: TextStyle( - fontSize: 20.0, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - TypewriterAnimatedText( - 'are INNOVATIVE', - textStyle: TextStyle( - fontSize: 20.0, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - TypewriterAnimatedText( - 'are PRIVATE', - textStyle: TextStyle( - fontSize: 20.0, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - TypewriterAnimatedText( - 'are SECURE', - textStyle: TextStyle( - fontSize: 20.0, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - TypewriterAnimatedText( - 'are EASY TO USE', - textStyle: TextStyle( - fontSize: 20.0, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - TypewriterAnimatedText( - 'support LOCAL CONNECTION', - textStyle: TextStyle( - fontSize: 20.0, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - TypewriterAnimatedText( - 'want a BETTER FUTURE', - textStyle: TextStyle( - fontSize: 20.0, - color: Theme.of(context).textTheme.bodyLarge!.color, - ), - ), - ], - ), - ], - ), + final ThemeData themeData = Theme.of(context); + final TextTheme textTheme = themeData.textTheme; + + return Row( + children: [ + TextAtom( + 'We', + style: textTheme.bodyLarge!.copyWith(color: Colors.white), ), - Container( - decoration: BoxDecoration( - color: (Theme.of(context).textTheme.bodyLarge!.color!) - .withOpacity(0.3), - border: Border.all( - color: Theme.of(context).textTheme.bodyLarge!.color!, + const SizedBox(width: 10.0), + AnimatedTextKit( + animatedTexts: [ + TypewriterAnimatedText( + 'are OPEN SOURCE', + textStyle: textTheme.titleMedium!.copyWith(color: Colors.white), + ), + TypewriterAnimatedText( + 'are FAIR', + textStyle: textTheme.titleMedium!.copyWith(color: Colors.white), + ), + TypewriterAnimatedText( + 'are INNOVATIVE', + textStyle: textTheme.titleMedium!.copyWith(color: Colors.white), + ), + TypewriterAnimatedText( + 'are PRIVATE', + textStyle: textTheme.titleMedium!.copyWith(color: Colors.white), + ), + TypewriterAnimatedText( + 'are SECURE', + textStyle: textTheme.titleMedium!.copyWith(color: Colors.white), + ), + TypewriterAnimatedText( + 'are EASY TO USE', + textStyle: textTheme.titleMedium!.copyWith(color: Colors.white), + ), + TypewriterAnimatedText( + 'support LOCAL CONNECTION', + textStyle: textTheme.titleMedium!.copyWith(color: Colors.white), ), - // Make rounded corners - borderRadius: BorderRadius.circular(30), - ), - height: 160, - child: SizedBox( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - CircleAvatar( - backgroundColor: Colors.transparent, - radius: 55.0, - child: Image.network( - 'https://i.ibb.co/tHWm1NV/Cy-Bear-Jinni-smart-device-logo.png', - ), - ), - CircleAvatar( - backgroundColor: Colors.transparent, - radius: 55.0, - child: Image.network( - 'https://user-images.githubusercontent.com/9304740/97423649-3ab85300-1918-11eb-8c2e-50ce0445c457.png', - ), - ), - CircleAvatar( - backgroundColor: Colors.transparent, - radius: 55.0, - child: Image.network( - 'https://user-images.githubusercontent.com/62209650/95081236-8e6cbd80-0719-11eb-99b9-8efc34e711b0.png', - ), - ), - ], + TypewriterAnimatedText( + 'want a BETTER FUTURE', + textStyle: textTheme.titleMedium!.copyWith(color: Colors.white), ), - ), + ], ), ], ); diff --git a/lib/presentation/pages/pages.dart b/lib/presentation/pages/pages.dart index 02756308e..7bfe00b29 100644 --- a/lib/presentation/pages/pages.dart +++ b/lib/presentation/pages/pages.dart @@ -1,30 +1,30 @@ -export 'package:cybear_jinni/presentation/pages/add_new_automation_process/add_action/add_action_page.dart'; -export 'package:cybear_jinni/presentation/pages/add_new_automation_process/add_bindings/add_binding_page.dart'; -export 'package:cybear_jinni/presentation/pages/add_new_automation_process/add_routine/add_routine_page.dart'; -export 'package:cybear_jinni/presentation/pages/add_new_automation_process/add_routine/pick_repeat_time/pick_repeat_time_page.dart'; -export 'package:cybear_jinni/presentation/pages/add_new_automation_process/add_scene/add_scene_page.dart'; -export 'package:cybear_jinni/presentation/pages/add_new_automation_process/choose_automation_type_to_add/choose_automation_type_to_add_page.dart'; -export 'package:cybear_jinni/presentation/pages/add_new_devices_process/choose_device_vendor_to_add/choose_device_vendor_to_add_page.dart'; -export 'package:cybear_jinni/presentation/pages/add_new_devices_process/computer_connection_check/computer_connection_check_page.dart'; -export 'package:cybear_jinni/presentation/pages/add_new_devices_process/configure_new_cbj_comp/configure_new_cbj_comp_page.dart'; -export 'package:cybear_jinni/presentation/pages/add_new_devices_process/connect_to_home_wifi/connect_to_home_wifi_page.dart'; -export 'package:cybear_jinni/presentation/pages/add_new_devices_process/open_access_point/open_access_pointi_page.dart'; -export 'package:cybear_jinni/presentation/pages/add_new_devices_process/scan_for_new_cbj_comps/scan_for_new_cbj_comps_page.dart'; -export 'package:cybear_jinni/presentation/pages/add_new_room/add_new_room_page.dart'; -export 'package:cybear_jinni/presentation/pages/add_vendors_pages/add_esphome_vendor/add_esphome_vendor_page.dart'; -export 'package:cybear_jinni/presentation/pages/add_vendors_pages/add_ewelink_vendor/add_ewelink_vendor_page.dart'; -export 'package:cybear_jinni/presentation/pages/add_vendors_pages/add_lifx_vendor/add_lifx_vendor_page.dart'; -export 'package:cybear_jinni/presentation/pages/change_room_for_devices/change_room_for_devices_page.dart'; -export 'package:cybear_jinni/presentation/pages/connect_to_hub/connect_to_hub_page.dart'; -export 'package:cybear_jinni/presentation/pages/connect_to_hub_more/connect_to_hub_more_page.dart'; -export 'package:cybear_jinni/presentation/pages/devices_in_network_page.dart'; -export 'package:cybear_jinni/presentation/pages/devices_in_room_page.dart'; -export 'package:cybear_jinni/presentation/pages/home_page/home_page.dart'; -export 'package:cybear_jinni/presentation/pages/introduction_screen/introduction_screen_page.dart'; -export 'package:cybear_jinni/presentation/pages/plus_button/plus_button.dart'; -export 'package:cybear_jinni/presentation/pages/remote_pipes/remote_pipes_page.dart'; -export 'package:cybear_jinni/presentation/pages/scenes/scenes_page.dart'; -export 'package:cybear_jinni/presentation/pages/smart_camera_container_page.dart'; -export 'package:cybear_jinni/presentation/pages/software_info/software_info_page.dart'; -export 'package:cybear_jinni/presentation/pages/splash_page.dart'; -export 'package:cybear_jinni/presentation/pages/video_stream_output_container_page.dart'; +export 'package:cybearjinni/presentation/pages/add_new_automation_process/add_action/add_action_page.dart'; +export 'package:cybearjinni/presentation/pages/add_new_automation_process/add_bindings/add_binding_page.dart'; +export 'package:cybearjinni/presentation/pages/add_new_automation_process/add_routine/add_routine_page.dart'; +export 'package:cybearjinni/presentation/pages/add_new_automation_process/add_routine/pick_repeat_time/pick_repeat_time_page.dart'; +export 'package:cybearjinni/presentation/pages/add_new_automation_process/add_scene/add_scene_page.dart'; +export 'package:cybearjinni/presentation/pages/add_new_automation_process/choose_automation_type_to_add/choose_automation_type_to_add_page.dart'; +export 'package:cybearjinni/presentation/pages/add_new_devices_process/choose_device_vendor_to_add/choose_device_vendor_to_add_page.dart'; +export 'package:cybearjinni/presentation/pages/add_new_devices_process/computer_connection_check/computer_connection_check_page.dart'; +export 'package:cybearjinni/presentation/pages/add_new_devices_process/configure_new_cbj_comp/configure_new_cbj_comp_page.dart'; +export 'package:cybearjinni/presentation/pages/add_new_devices_process/connect_to_home_wifi/connect_to_home_wifi_page.dart'; +export 'package:cybearjinni/presentation/pages/add_new_devices_process/open_access_point/open_access_pointi_page.dart'; +export 'package:cybearjinni/presentation/pages/add_new_devices_process/scan_for_new_cbj_comps/scan_for_new_cbj_comps_page.dart'; +export 'package:cybearjinni/presentation/pages/add_new_room/add_new_room_page.dart'; +export 'package:cybearjinni/presentation/pages/add_vendors_pages/add_esphome_vendor/add_esphome_vendor_page.dart'; +export 'package:cybearjinni/presentation/pages/add_vendors_pages/add_ewelink_vendor/add_ewelink_vendor_page.dart'; +export 'package:cybearjinni/presentation/pages/add_vendors_pages/add_lifx_vendor/add_lifx_vendor_page.dart'; +export 'package:cybearjinni/presentation/pages/change_room_for_devices/change_room_for_devices_page.dart'; +export 'package:cybearjinni/presentation/pages/connect_to_hub/connect_to_hub_page.dart'; +export 'package:cybearjinni/presentation/pages/connect_to_hub_more/connect_to_hub_more_page.dart'; +export 'package:cybearjinni/presentation/pages/entities_in_network_page.dart'; +export 'package:cybearjinni/presentation/pages/entities_in_room_page.dart'; +export 'package:cybearjinni/presentation/pages/home_page/home_page.dart'; +export 'package:cybearjinni/presentation/pages/introduction_screen/introduction_screen_page.dart'; +export 'package:cybearjinni/presentation/pages/plus_button/plus_button.dart'; +export 'package:cybearjinni/presentation/pages/remote_pipes/remote_pipes_page.dart'; +export 'package:cybearjinni/presentation/pages/scenes/scenes_page.dart'; +export 'package:cybearjinni/presentation/pages/smart_camera_container_page.dart'; +export 'package:cybearjinni/presentation/pages/software_info/software_info_page.dart'; +export 'package:cybearjinni/presentation/pages/splash_page.dart'; +export 'package:cybearjinni/presentation/pages/video_stream_output_container_page.dart'; diff --git a/lib/presentation/pages/plus_button/plus_button.dart b/lib/presentation/pages/plus_button/plus_button.dart index d588d098c..dfed42253 100644 --- a/lib/presentation/pages/plus_button/plus_button.dart +++ b/lib/presentation/pages/plus_button/plus_button.dart @@ -1,19 +1,24 @@ import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/pages/plus_button/widgets/plus_button_wighet.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; +import 'package:cybearjinni/presentation/pages/plus_button/widgets/plus_button_wighet.dart'; import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @RoutePage() class PlusButtonPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - title: const TextAtom('Add and Manage'), - backgroundColor: Colors.purple.withOpacity(0.7), + body: Column( + children: [ + TopBarMolecule( + pageName: 'Add and Manage', + leftIcon: FontAwesomeIcons.arrowLeft, + leftIconFunction: (_) => context.router.pop(), + ), + PlusButtonWidget(), + ], ), - backgroundColor: Colors.black.withOpacity(0.7), - body: PlusButtonWidget(), ); } } diff --git a/lib/presentation/pages/plus_button/widgets/plus_button_wighet.dart b/lib/presentation/pages/plus_button/widgets/plus_button_wighet.dart index 661cec7a8..80ed5bff2 100644 --- a/lib/presentation/pages/plus_button/widgets/plus_button_wighet.dart +++ b/lib/presentation/pages/plus_button/widgets/plus_button_wighet.dart @@ -1,9 +1,9 @@ import 'package:auto_route/auto_route.dart'; import 'package:cbj_integrations_controller/domain/hub/hub_entity.dart'; -import 'package:cybear_jinni/domain/connections_service.dart'; -import 'package:cybear_jinni/domain/i_hub_connection_repository.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/routes/app_router.gr.dart'; +import 'package:cybearjinni/domain/connections_service.dart'; +import 'package:cybearjinni/domain/i_hub_connection_repository.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.gr.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:iconify_flutter/iconify_flutter.dart'; @@ -18,6 +18,10 @@ class PlusButtonWidget extends StatelessWidget { @override Widget build(BuildContext context) { + final ThemeData themeData = Theme.of(context); + final TextTheme textTheme = themeData.textTheme; + final ColorScheme colorScheme = themeData.colorScheme; + return SingleChildScrollView( child: Column( children: [ @@ -27,12 +31,9 @@ class PlusButtonWidget extends StatelessWidget { Container( padding: const EdgeInsets.symmetric(horizontal: 15), alignment: Alignment.topLeft, - child: const TextAtom( + child: TextAtom( 'Add:', - style: TextStyle( - color: Colors.white, - fontSize: 20, - ), + style: textTheme.titleMedium, ), ), const SizedBox( @@ -48,8 +49,7 @@ class PlusButtonWidget extends StatelessWidget { child: ListTile( leading: FaIcon( FontAwesomeIcons.camera, - color: Theme.of(context).textTheme.bodyLarge!.color, - size: 25, + color: colorScheme.background, ), title: TextAtom( 'Turn Phone To a Security Camera', @@ -71,11 +71,10 @@ class PlusButtonWidget extends StatelessWidget { child: ListTile( leading: FaIcon( FontAwesomeIcons.solidLightbulb, - color: Theme.of(context).textTheme.bodyLarge!.color, - size: 25, + color: colorScheme.background, ), title: TextAtom( - 'Add Device', + 'Add Entity', style: TextStyle( color: Theme.of(context).textTheme.bodyLarge!.color, ), @@ -91,8 +90,7 @@ class PlusButtonWidget extends StatelessWidget { child: ListTile( leading: FaIcon( FontAwesomeIcons.globe, - color: Theme.of(context).textTheme.bodyLarge!.color, - size: 25, + color: colorScheme.background, ), title: TextAtom( 'Add Remote Control Support', @@ -111,8 +109,7 @@ class PlusButtonWidget extends StatelessWidget { child: ListTile( leading: FaIcon( FontAwesomeIcons.sitemap, - color: Theme.of(context).textTheme.bodyLarge!.color, - size: 25, + color: colorScheme.background, ), title: TextAtom( 'Add Automation', @@ -136,12 +133,9 @@ class PlusButtonWidget extends StatelessWidget { Container( alignment: Alignment.topLeft, padding: const EdgeInsets.symmetric(horizontal: 15), - child: const TextAtom( + child: TextAtom( 'Manage:', - style: TextStyle( - color: Colors.white, - fontSize: 20, - ), + style: textTheme.titleMedium, ), ), const SizedBox( @@ -159,17 +153,16 @@ class PlusButtonWidget extends StatelessWidget { child: ListTile( leading: FaIcon( FontAwesomeIcons.computer, - color: Theme.of(context).textTheme.bodyLarge!.color, - size: 25, + color: colorScheme.background, ), title: TextAtom( - 'All Devices in the network', + 'All Entities in the network', style: TextStyle( color: Theme.of(context).textTheme.bodyLarge!.color, ), ), onTap: () => - context.router.push(const DevicesInNetworkRoute()), + context.router.push(const EntitiesInNetworkRoute()), ), ), const SizedBox( @@ -180,8 +173,7 @@ class PlusButtonWidget extends StatelessWidget { child: ListTile( leading: Iconify( SimpleIcons.node_red, - color: Theme.of(context).textTheme.bodyLarge!.color, - size: 23, + color: colorScheme.background, ), title: TextAtom( 'Open Node-RED of Hub', @@ -221,8 +213,7 @@ class PlusButtonWidget extends StatelessWidget { child: ListTile( leading: FaIcon( FontAwesomeIcons.info, - color: Theme.of(context).textTheme.bodyLarge!.color, - size: 25, + color: colorScheme.background, ), title: TextAtom( 'Software Info', @@ -243,8 +234,7 @@ class PlusButtonWidget extends StatelessWidget { child: ListTile( leading: FaIcon( FontAwesomeIcons.rightFromBracket, - color: Theme.of(context).textTheme.bodyLarge!.color, - size: 25, + color: colorScheme.background, ), title: TextAtom( 'Log Out', diff --git a/lib/presentation/pages/remote_pipes/remote_pipes_page.dart b/lib/presentation/pages/remote_pipes/remote_pipes_page.dart index edcbe39c1..1fedc23bb 100644 --- a/lib/presentation/pages/remote_pipes/remote_pipes_page.dart +++ b/lib/presentation/pages/remote_pipes/remote_pipes_page.dart @@ -1,10 +1,9 @@ import 'package:adaptive_action_sheet/adaptive_action_sheet.dart'; import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/molecules/molecules.dart'; -import 'package:cybear_jinni/presentation/pages/remote_pipes/widgets/manage_remote_pipes_widget.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; +import 'package:cybearjinni/presentation/pages/remote_pipes/widgets/manage_remote_pipes_widget.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @RoutePage() @@ -34,11 +33,6 @@ class RemotePipesPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - toolbarHeight: 0, - backgroundColor: Colors.black, - systemOverlayStyle: SystemUiOverlayStyle.dark, - ), body: Column( children: [ TopBarMolecule( diff --git a/lib/presentation/pages/remote_pipes/widgets/error_remote_pipes_card_widget.dart b/lib/presentation/pages/remote_pipes/widgets/error_remote_pipes_card_widget.dart index 396c0dea5..1beff35bb 100644 --- a/lib/presentation/pages/remote_pipes/widgets/error_remote_pipes_card_widget.dart +++ b/lib/presentation/pages/remote_pipes/widgets/error_remote_pipes_card_widget.dart @@ -1,5 +1,5 @@ -import 'package:cybear_jinni/domain/home_user/home_user_entity.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/domain/home_user/home_user_entity.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; import 'package:flutter/material.dart'; class ErrorRemotePipesCard extends StatelessWidget { diff --git a/lib/presentation/pages/remote_pipes/widgets/manage_remote_pipes_widget.dart b/lib/presentation/pages/remote_pipes/widgets/manage_remote_pipes_widget.dart index 6f61c7cd0..d92973b0e 100644 --- a/lib/presentation/pages/remote_pipes/widgets/manage_remote_pipes_widget.dart +++ b/lib/presentation/pages/remote_pipes/widgets/manage_remote_pipes_widget.dart @@ -2,8 +2,8 @@ import 'package:auto_route/auto_route.dart'; import 'package:cbj_integrations_controller/domain/remote_pipes/i_remote_pipes_repository.dart'; import 'package:cbj_integrations_controller/domain/remote_pipes/remote_pipes_entity.dart'; import 'package:cbj_integrations_controller/domain/remote_pipes/remote_pipes_value_objects.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/snack_bar_service.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/snack_bar_service.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; diff --git a/lib/presentation/pages/remote_pipes/widgets/remote_pipes_card_widget.dart b/lib/presentation/pages/remote_pipes/widgets/remote_pipes_card_widget.dart index 411b80674..5a87e7b16 100644 --- a/lib/presentation/pages/remote_pipes/widgets/remote_pipes_card_widget.dart +++ b/lib/presentation/pages/remote_pipes/widgets/remote_pipes_card_widget.dart @@ -1,5 +1,5 @@ -import 'package:cybear_jinni/domain/home_user/home_user_entity.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/domain/home_user/home_user_entity.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; diff --git a/lib/presentation/pages/scenes/scenes_page.dart b/lib/presentation/pages/scenes/scenes_page.dart index 01851d724..f3999c2d3 100644 --- a/lib/presentation/pages/scenes/scenes_page.dart +++ b/lib/presentation/pages/scenes/scenes_page.dart @@ -3,11 +3,10 @@ import 'dart:ui'; import 'package:adaptive_action_sheet/adaptive_action_sheet.dart'; import 'package:auto_route/auto_route.dart'; import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/molecules/molecules.dart'; -import 'package:cybear_jinni/presentation/pages/scenes/widgets/folder_of_scenes.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; +import 'package:cybearjinni/presentation/pages/scenes/widgets/folder_of_scenes.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @RoutePage() @@ -46,11 +45,6 @@ class ScenesPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - toolbarHeight: 0, - backgroundColor: Colors.black, - systemOverlayStyle: SystemUiOverlayStyle.dark, - ), body: Container( decoration: BoxDecoration( image: DecorationImage( diff --git a/lib/presentation/pages/scenes/widgets/folder_of_scenes.dart b/lib/presentation/pages/scenes/widgets/folder_of_scenes.dart index 8a6ae674f..b6ac321b3 100644 --- a/lib/presentation/pages/scenes/widgets/folder_of_scenes.dart +++ b/lib/presentation/pages/scenes/widgets/folder_of_scenes.dart @@ -2,8 +2,8 @@ import 'package:cbj_integrations_controller/domain/room/room_entity.dart'; import 'package:cbj_integrations_controller/domain/scene/i_scene_cbj_repository.dart'; import 'package:cbj_integrations_controller/domain/scene/scene_cbj_entity.dart'; import 'package:cbj_integrations_controller/domain/scene/scene_cbj_failures.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/pages/scenes/widgets/scene_widget.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/pages/scenes/widgets/scene_widget.dart'; import 'package:dartz/dartz.dart' as dartz; import 'package:flutter/material.dart'; diff --git a/lib/presentation/pages/scenes/widgets/scene_widget.dart b/lib/presentation/pages/scenes/widgets/scene_widget.dart index 2fe70e94a..312048ff0 100644 --- a/lib/presentation/pages/scenes/widgets/scene_widget.dart +++ b/lib/presentation/pages/scenes/widgets/scene_widget.dart @@ -1,7 +1,7 @@ import 'package:cbj_integrations_controller/domain/scene/i_scene_cbj_repository.dart'; import 'package:cbj_integrations_controller/domain/scene/scene_cbj_entity.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/core/snack_bar_service.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/snack_bar_service.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; diff --git a/lib/presentation/pages/software_info/software_info_page.dart b/lib/presentation/pages/software_info/software_info_page.dart index 36ae8ed0f..033728f47 100644 --- a/lib/presentation/pages/software_info/software_info_page.dart +++ b/lib/presentation/pages/software_info/software_info_page.dart @@ -1,10 +1,9 @@ import 'package:adaptive_action_sheet/adaptive_action_sheet.dart'; import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; -import 'package:cybear_jinni/presentation/molecules/molecules.dart'; -import 'package:cybear_jinni/presentation/pages/software_info/widgets/software_info_widget.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/molecules/molecules.dart'; +import 'package:cybearjinni/presentation/pages/software_info/widgets/software_info_widget.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @RoutePage() @@ -34,28 +33,18 @@ class SoftwareInfoPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - toolbarHeight: 0, - backgroundColor: Colors.black, - systemOverlayStyle: const SystemUiOverlayStyle( - statusBarIconBrightness: Brightness.light, - ), - ), - body: ColoredBox( - color: Colors.black87, - child: Column( - children: [ - TopBarMolecule( - pageName: 'Software Info', - rightIconFunction: userCogFunction, - leftIcon: FontAwesomeIcons.arrowLeft, - leftIconFunction: leftIconFunction, - ), - Expanded( - child: SoftwareInfoWidget(), - ), - ], - ), + body: Column( + children: [ + TopBarMolecule( + pageName: 'Software Info', + rightIconFunction: userCogFunction, + leftIcon: FontAwesomeIcons.arrowLeft, + leftIconFunction: leftIconFunction, + ), + Expanded( + child: SoftwareInfoWidget(), + ), + ], ), ); } diff --git a/lib/presentation/pages/software_info/widgets/error_software_info_card_widget.dart b/lib/presentation/pages/software_info/widgets/error_software_info_card_widget.dart index d28f0e8fa..ac74e2636 100644 --- a/lib/presentation/pages/software_info/widgets/error_software_info_card_widget.dart +++ b/lib/presentation/pages/software_info/widgets/error_software_info_card_widget.dart @@ -1,5 +1,5 @@ -import 'package:cybear_jinni/domain/home_user/home_user_entity.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/domain/home_user/home_user_entity.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; import 'package:flutter/material.dart'; class ErrorSoftwareInfoCard extends StatelessWidget { diff --git a/lib/presentation/pages/software_info/widgets/software_info_card_widget.dart b/lib/presentation/pages/software_info/widgets/software_info_card_widget.dart index b56f634b2..e9230606a 100644 --- a/lib/presentation/pages/software_info/widgets/software_info_card_widget.dart +++ b/lib/presentation/pages/software_info/widgets/software_info_card_widget.dart @@ -1,5 +1,5 @@ -import 'package:cybear_jinni/domain/home_user/home_user_entity.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/domain/home_user/home_user_entity.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; diff --git a/lib/presentation/pages/software_info/widgets/software_info_widget.dart b/lib/presentation/pages/software_info/widgets/software_info_widget.dart index 40c94e363..ed320cc10 100644 --- a/lib/presentation/pages/software_info/widgets/software_info_widget.dart +++ b/lib/presentation/pages/software_info/widgets/software_info_widget.dart @@ -1,6 +1,6 @@ -import 'package:cybear_jinni/domain/software_info/i_software_info_repository.dart'; -import 'package:cybear_jinni/domain/software_info/software_info_entity.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/domain/software_info/i_software_info_repository.dart'; +import 'package:cybearjinni/domain/software_info/software_info_entity.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; import 'package:flutter/material.dart'; /// Show light toggles in a container with the background color from smart room @@ -90,7 +90,7 @@ class _SoftwareInfoWidgetState extends State { ListTile( title: Row( children: [ - const TextAtom('Device name: '), + const TextAtom('Entitey name: '), TextAtom( softwareInfoEntity?.deviceName.getOrCrash() ?? 'No Info', diff --git a/lib/presentation/pages/splash_page.dart b/lib/presentation/pages/splash_page.dart index d6e02b515..27b8d4464 100644 --- a/lib/presentation/pages/splash_page.dart +++ b/lib/presentation/pages/splash_page.dart @@ -1,7 +1,21 @@ +import 'dart:io'; + import 'package:auto_route/auto_route.dart'; -import 'package:cybear_jinni/presentation/atoms/atoms.dart'; +import 'package:cbj_integrations_controller/domain/i_saved_devices_repo.dart'; +import 'package:cbj_integrations_controller/domain/local_db/i_local_db_repository.dart'; +import 'package:cbj_integrations_controller/infrastructure/node_red/node_red_repository.dart'; +import 'package:cbj_integrations_controller/infrastructure/system_commands/system_commands_manager_d.dart'; +import 'package:cbj_smart_device_flutter/commands/flutter_commands.dart'; +import 'package:cybearjinni/domain/connections_service.dart'; +import 'package:cybearjinni/domain/i_local_db_repository.dart'; +import 'package:cybearjinni/infrastructure/app_commands.dart'; +import 'package:cybearjinni/infrastructure/mqtt.dart'; +import 'package:cybearjinni/presentation/atoms/atoms.dart'; +import 'package:cybearjinni/presentation/core/routes/app_router.gr.dart'; +import 'package:flutter/foundation.dart' show kIsWeb; import 'package:flutter/material.dart'; -import 'package:url_launcher/url_launcher.dart'; +import 'package:hexcolor/hexcolor.dart'; +import 'package:hive_flutter/hive_flutter.dart'; @RoutePage() class SplashPage extends StatefulWidget { @@ -13,86 +27,55 @@ class _SplashPageState extends State { @override void initState() { super.initState(); - - // _navigate(); - openUpdateDialog(); + initilizeApp(); } - Future openUpdateDialog() async { - await Future.delayed(const Duration(seconds: 1)); - if (context.mounted) { - await showDialog( - context: context, - builder: (BuildContext context) => UpdateDialog(), - ); - } + Future initilizeApp() async { + await Hive.initFlutter(); + AppCommands(); + await Future.value([ + IDbRepository.instance.initializeDb(isFlutter: true), + ILocalDbRepository.instance.asyncConstructor(), + ISavedDevicesRepo.instance.setUpAllFromDb(), + ]); + MqttServerRepository(); + PhoneCommandsD(); + SystemCommandsManager(); + NodeRedRepository(); + ConnectionsService.instance; + _navigate(); } - // Future _navigate() async { - // (await ILocalDbRepository.instance.getHubEntityNetworkName()).fold( - // (l) { - // if (kIsWeb || Platform.isLinux || Platform.isWindows) { - // return context.router.replace(const ConnectToHubRoute()); - // } - // return context.router.replace(const IntroductionRouteRoute()); - // }, - // (r) => context.router.replace(const HomeRoute()), - // ); - // } - - @override - Widget build(BuildContext context) { - return const Scaffold( - body: Center( - child: ImageAtom( - 'assets/cbj_logo.png', - ), - ), - ); + void _navigate() { + if (kIsWeb || Platform.isLinux || Platform.isWindows) { + context.router.replace(const ConnectToHubRoute()); + return; + } + context.router.replace(const IntroductionRouteRoute()); + return; } -} -class UpdateDialog extends StatelessWidget { @override Widget build(BuildContext context) { - final ThemeData themeData = Theme.of(context); - final TextTheme textTheme = themeData.textTheme; - final ColorScheme colorScheme = themeData.colorScheme; - - return Center( - child: AlertDialog( - title: TextAtom('A New App', style: textTheme.titleLarge), - content: SizedBox( - height: 170, - child: Column( - children: [ - TextAtom( - 'We have moved to a new app.\n' - 'Please download the new app and delete this one.\n' - 'See you in the other side :D', - style: textTheme.titleMedium, - ), - const Expanded( - child: SizedBox(), - ), - ElevatedButton( - child: TextAtom( - 'Download', - style: textTheme.titleMedium, - ), - onPressed: () { - launchUrl( - Uri.parse( - 'https://play.google.com/store/apps/details?id=com.cybearjinni.app', - ), - mode: LaunchMode.externalApplication, - ); - }, - ), + return Scaffold( + body: Container( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.centerRight, + end: Alignment.centerLeft, + stops: const [0.06, 0.9], + colors: [ + HexColor('#ca6ce3'), + HexColor('#aa5fe4'), ], ), ), - actions: [], + child: const Center( + child: ImageAtom( + 'assets/cbj_logo.png', + hero: 'full_logo', + ), + ), ), ); } diff --git a/linux/CMakeLists.txt b/linux/CMakeLists.txt index 7612d732e..0256aaf8b 100644 --- a/linux/CMakeLists.txt +++ b/linux/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) set(BINARY_NAME "CyBear-Jinni_App") -set(APPLICATION_ID "com.cybear_jinni.smart_home") +set(APPLICATION_ID "com.cybearjinni.app") cmake_policy(SET CMP0063 NEW) diff --git a/macos/Runner/Configs/AppInfo.xcconfig b/macos/Runner/Configs/AppInfo.xcconfig index d527eb760..e830064d8 100644 --- a/macos/Runner/Configs/AppInfo.xcconfig +++ b/macos/Runner/Configs/AppInfo.xcconfig @@ -11,4 +11,4 @@ PRODUCT_NAME = CyBear Jinni App PRODUCT_BUNDLE_IDENTIFIER = com.cybearjinni.smarthome // The copyright displayed in application information -PRODUCT_COPYRIGHT = Copyright © 2021 com.cybear_jinni.smart_home. All rights reserved. +PRODUCT_COPYRIGHT = Copyright © 2021 com.cybearjinni.app. All rights reserved. diff --git a/pubspec.yaml b/pubspec.yaml index 3825fc6d3..48c84cf7c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ -name: cybear_jinni +name: cybearjinni description: CyBear Jinni app to interact with your CyBear Jinni Smart Devices -version: 1.4.4+68 +version: 1.4.6+70 homepage: https://cybearjinni.com publish_to: 'none'