Skip to content

Commit

Permalink
Added support for searching devices
Browse files Browse the repository at this point in the history
* this way if you have many devices you can easily find the correct one
* removed the blur effect, as it didn't have a visual effect anymore, but did cost alot of perfomance
* fixed remove device function, since the code was never migrated so it just pooped the dialog instead of doing something
* started using the riverpod generator, since this will be easier to understand for new people, what it actually does
* added new log screen in the heater model, since these devices send logs which are interesting to see, when something doesn't work
* fixed connection beeing broke when one unfocuses the app, since on windows this isn't needed whatsover and on android the wrong check was used
* reworked the add devices dialog, so multiple devices can be added at the same time by ticking the checkbox of each one
  • Loading branch information
susch19 committed Oct 22, 2023
1 parent 6a5db4c commit bf6ea3b
Show file tree
Hide file tree
Showing 12 changed files with 370 additions and 163 deletions.
176 changes: 88 additions & 88 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,88 +1,88 @@
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1.1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.1'
}

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: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 33

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

lintOptions {
disable 'InvalidPackage'
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "de.susch19.smarthome"
resValue "string", "app_name", "Smarthome"
minSdkVersion 16
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}

signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}

buildTypes {
release {
signingConfig signingConfigs.release
}
profile {
applicationIdSuffix ".profile"
versionNameSuffix "-profile"
resValue "string", "app_name", "Smarthome Profile"

}
debug {
applicationIdSuffix ".debug"
versionNameSuffix "-debug"
resValue "string", "app_name", "Smarthome Debug"
}
}
}

flutter {
source '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1.1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.1'
}

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: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 33

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

lintOptions {
disable 'InvalidPackage'
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "de.susch19.smarthome"
resValue "string", "app_name", "Smarthome"
minSdkVersion flutter.minSdkVersion
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}

signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}

buildTypes {
release {
signingConfig signingConfigs.release
}
profile {
applicationIdSuffix ".profile"
versionNameSuffix "-profile"
resValue "string", "app_name", "Smarthome Profile"

}
debug {
applicationIdSuffix ".debug"
versionNameSuffix "-debug"
resValue "string", "app_name", "Smarthome Debug"
}
}
}

flutter {
source '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
3 changes: 0 additions & 3 deletions lib/controls/blurry_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const EdgeInsets defaultMargin = EdgeInsets.all(0);
class BlurryCard extends StatelessWidget {
final Widget? child;
final BorderRadius borderRadius;
final double blur;
final MaterialColor lightColor;
final MaterialColor darkColor;
final Color lightShadowColor;
Expand All @@ -23,7 +22,6 @@ class BlurryCard extends StatelessWidget {
{final Key? key,
this.child,
this.borderRadius = defaultBorderRadius,
this.blur = 5,
this.lightColor = defaultLightColor,
this.darkColor = defaultBlackColor,
this.lightShadowColor = defaultLightShadowColor,
Expand All @@ -41,7 +39,6 @@ class BlurryCard extends StatelessWidget {
color: AdaptiveTheme.of(context).brightness == Brightness.light
? defaultLightShadowColor
: defaultDarkShadowColor,
blur: blur,
child: Card(
color: Colors.transparent,
shadowColor: Colors.transparent,
Expand Down
32 changes: 18 additions & 14 deletions lib/controls/blurry_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@
import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:smarthome/helper/preference_manager.dart';

const double kBlur = 1.0;
const EdgeInsetsGeometry kDefaultPadding = EdgeInsets.all(0);
const EdgeInsetsGeometry kDefaultMargin = EdgeInsets.all(0);
const Color kDefaultColor = Colors.transparent;
const BorderRadius kBorderRadius = BorderRadius.all(Radius.circular(10));
const BlendMode kblendMode = BlendMode.srcOver;

class BlurryContainer extends StatelessWidget {
final blurryContainerBlurProvider = StateProvider<double>((ref) {
return PreferencesManager.instance.getDouble("BlurryContainerBlur") ?? 0;
});

class BlurryContainer extends ConsumerWidget {
final Widget? child;
final double blur;
final EdgeInsetsGeometry padding;
final Color color;
final EdgeInsetsGeometry margin;
Expand All @@ -22,7 +26,6 @@ class BlurryContainer extends StatelessWidget {

const BlurryContainer(
{this.child,
this.blur = 5,
this.padding = kDefaultPadding,
this.color = kDefaultColor,
this.borderRadius = kBorderRadius,
Expand All @@ -32,19 +35,20 @@ class BlurryContainer extends StatelessWidget {
: super(key: key);

@override
Widget build(final BuildContext context) {
Widget build(final BuildContext context, final WidgetRef ref) {
final blur = ref.watch(blurryContainerBlurProvider);
return ClipRRect(
borderRadius: borderRadius,
child: BackdropFilter(
blendMode: blendMode,
filter: ImageFilter.blur(sigmaX: blur, sigmaY: blur),
child: Container(
padding: padding,
margin: margin,
color: color,
child: child,
),
// child: BackdropFilter(
// blendMode: blendMode,
// filter: ImageFilter.blur(sigmaX: blur, sigmaY: blur),
child: Container(
padding: padding,
margin: margin,
color: color,
child: child,
),
// ),
);
}
}
2 changes: 1 addition & 1 deletion lib/devices/base_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ part 'base_model.g.dart';

final baseModelProvider = StateProvider<List<BaseModel>>((final ref) => []);

final baseModelASMapProvider = StateProvider<Map<int, BaseModel>>(
final baseModelASMapProvider = Provider<Map<int, BaseModel>>(
(final ref) => ref.watch(baseModelProvider).toMap((final bm) => bm.id, (final bm) => bm));

final baseModelFriendlyNamesMapProvider = Provider<Map<int, String>>((final ref) {
Expand Down
37 changes: 33 additions & 4 deletions lib/devices/heater/heater.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:smarthome/devices/device_manager.dart';
import 'package:smarthome/devices/generic/stores/store_service.dart';
import 'package:smarthome/devices/generic/stores/value_store.dart';
import 'package:smarthome/devices/heater/heater_config.dart';
import 'package:smarthome/devices/heater/log_screen.dart';
import 'package:smarthome/helper/connection_manager.dart';
import 'package:smarthome/helper/settings_manager.dart';
import 'package:smarthome/helper/theme_manager.dart';
Expand Down Expand Up @@ -196,6 +197,14 @@ class _HeaterScreenState extends ConsumerState<HeaterScreen> {
res.item2.map((final f) => jsonEncode(f)).toList(), ref.read(hubConnectionProvider));
}

_pushLogView(final BuildContext context) async {
await Navigator.push(
context,
MaterialPageRoute(
builder: (final BuildContext context) => LogScreen(HeaterModel.logsProvider, heater.id),
fullscreenDialog: true));
}

buildColumnView(final double width, final double value) {
return Column(
children: [
Expand Down Expand Up @@ -255,10 +264,12 @@ class _HeaterScreenState extends ConsumerState<HeaterScreen> {
Container(
margin: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 8.0),
child: const Icon(Icons.receipt)),
Consumer(builder: (final context, final ref, final child) {
final version = ref.watch(HeaterModel.versionProvider(widget.device.id));
return Text(version);
}),
Consumer(
builder: (final context, final ref, final child) {
final version = ref.watch(HeaterModel.versionProvider(widget.device.id));
return Text(version);
},
),
],
),
)
Expand Down Expand Up @@ -388,6 +399,24 @@ class _HeaterScreenState extends ConsumerState<HeaterScreen> {
),
),
),
BlurryCard(
margin: const EdgeInsets.only(left: 8, right: 8, top: 8),
child: MaterialButton(
onPressed: () => _pushLogView(context),
child: Row(
children: [
Container(
margin: const EdgeInsets.symmetric(vertical: 4.0),
child: const Icon(Icons.settings),
),
TextButton(
onPressed: () => _pushLogView(context),
child: const Text("Logs"),
),
],
),
),
),
],
);
}
Expand Down
Loading

0 comments on commit bf6ea3b

Please sign in to comment.