fixed vibration switch
This commit is contained in:
parent
ba2dc23c6c
commit
eed999d2ab
|
|
@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
|
||||||
import 'screens/home_screen.dart';
|
import 'screens/home_screen.dart';
|
||||||
import 'package:QuickSSH/classes/theme_provider.dart';
|
import 'package:QuickSSH/classes/theme_provider.dart';
|
||||||
import 'package:QuickSSH/services/theme_controller.dart';
|
import 'package:QuickSSH/services/theme_controller.dart';
|
||||||
import 'package:QuickSSH/services/settings_controller.dart';
|
|
||||||
|
|
||||||
final themeController = ThemeController();
|
final themeController = ThemeController();
|
||||||
final settingsController = SettingsController();
|
final settingsController = SettingsController();
|
||||||
|
|
|
||||||
|
|
@ -13,105 +13,113 @@ class _SettingsState extends State<Settings> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = Theme.of(context).colorScheme;
|
final theme = Theme.of(context).colorScheme;
|
||||||
return Scaffold(
|
return ListenableBuilder(
|
||||||
appBar: AppBar(
|
listenable: settingsController,
|
||||||
backgroundColor: theme.surface,
|
builder: (context, child) {
|
||||||
title: Text("Settings", style: TextStyle(color: theme.onSurface)),
|
return Scaffold(
|
||||||
leading: Builder(
|
appBar: AppBar(
|
||||||
builder: (context) {
|
backgroundColor: theme.surface,
|
||||||
return IconButton(
|
title: Text("Settings", style: TextStyle(color: theme.onSurface)),
|
||||||
icon: Icon(Icons.arrow_back_ios_rounded, color: theme.onSurface),
|
leading: Builder(
|
||||||
onPressed: () {
|
builder: (context) {
|
||||||
Navigator.pop(context);
|
return IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
Icons.arrow_back_ios_rounded,
|
||||||
|
color: theme.onSurface,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
),
|
||||||
},
|
),
|
||||||
),
|
body: Padding(
|
||||||
),
|
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||||
body: Padding(
|
child: Column(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Row(
|
||||||
child: Text(
|
children: [
|
||||||
"Appearance",
|
Expanded(
|
||||||
style: TextStyle(
|
child: Text(
|
||||||
fontWeight: FontWeight.bold,
|
"Appearance",
|
||||||
fontSize: 20,
|
style: TextStyle(
|
||||||
color: theme.onSurface,
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 20,
|
||||||
|
color: theme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 12,
|
||||||
|
vertical: 4,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: theme.primaryContainer,
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
),
|
||||||
|
child: DropdownButton<ThemeMode>(
|
||||||
|
value: themeController.themeMode,
|
||||||
|
underline: Container(),
|
||||||
|
items: const [
|
||||||
|
DropdownMenuItem(
|
||||||
|
value: ThemeMode.system,
|
||||||
|
child: Text("System Default"),
|
||||||
|
),
|
||||||
|
DropdownMenuItem(
|
||||||
|
value: ThemeMode.dark,
|
||||||
|
child: Text("Dark"),
|
||||||
|
),
|
||||||
|
DropdownMenuItem(
|
||||||
|
value: ThemeMode.light,
|
||||||
|
child: Text("Light"),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
onChanged: (ThemeMode? newMode) {
|
||||||
|
themeController.updateTheme(newMode);
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
Expanded(
|
SizedBox(height: 20),
|
||||||
child: Container(
|
Row(
|
||||||
padding: const EdgeInsets.symmetric(
|
children: [
|
||||||
horizontal: 12,
|
Expanded(
|
||||||
vertical: 4,
|
child: Text(
|
||||||
),
|
"Vibrations",
|
||||||
decoration: BoxDecoration(
|
style: TextStyle(
|
||||||
color: theme.primaryContainer,
|
fontWeight: FontWeight.bold,
|
||||||
borderRadius: BorderRadius.circular(16),
|
fontSize: 20,
|
||||||
),
|
color: theme.onSurface,
|
||||||
child: DropdownButton<ThemeMode>(
|
|
||||||
value: themeController.themeMode,
|
|
||||||
underline: Container(),
|
|
||||||
items: const [
|
|
||||||
DropdownMenuItem(
|
|
||||||
value: ThemeMode.system,
|
|
||||||
child: Text("System Default"),
|
|
||||||
),
|
),
|
||||||
DropdownMenuItem(
|
),
|
||||||
value: ThemeMode.dark,
|
|
||||||
child: Text("Dark"),
|
|
||||||
),
|
|
||||||
DropdownMenuItem(
|
|
||||||
value: ThemeMode.light,
|
|
||||||
child: Text("Light"),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
onChanged: (ThemeMode? newMode) {
|
|
||||||
themeController.updateTheme(newMode);
|
|
||||||
setState(() {});
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
Expanded(
|
||||||
|
child: Switch(
|
||||||
|
activeTrackColor: theme.primary,
|
||||||
|
activeThumbColor: theme.onPrimary,
|
||||||
|
inactiveThumbColor: theme.onSurface,
|
||||||
|
inactiveTrackColor: theme.surface,
|
||||||
|
value: settingsController.vibrationEnabled,
|
||||||
|
onChanged: (bool value) {
|
||||||
|
settingsController.toggleVibration(value);
|
||||||
|
if (value) HapticFeedback.mediumImpact();
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(height: 20),
|
),
|
||||||
Row(
|
);
|
||||||
children: [
|
},
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
"Vibrations",
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 20,
|
|
||||||
color: theme.onSurface,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: Switch(
|
|
||||||
activeTrackColor: theme.primary,
|
|
||||||
activeThumbColor: theme.onPrimary,
|
|
||||||
inactiveThumbColor: theme.onSurface,
|
|
||||||
inactiveTrackColor: theme.surface,
|
|
||||||
value: settingsController.vibrationEnabled,
|
|
||||||
onChanged: (bool value) {
|
|
||||||
settingsController.toggleVibration(value);
|
|
||||||
if (value) HapticFeedback.mediumImpact();
|
|
||||||
setState(() {});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ class SettingsController extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> toggleVibration(bool value) async {
|
Future<void> toggleVibration(bool value) async {
|
||||||
|
print("Toggling vibration to: $value");
|
||||||
_vibrationEnabled = value;
|
_vibrationEnabled = value;
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
await prefs.setBool('vibration_enabled', value);
|
await prefs.setBool('vibration_enabled', value);
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,13 @@ import FlutterMacOS
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
import flutter_secure_storage_macos
|
import flutter_secure_storage_macos
|
||||||
|
import local_auth_darwin
|
||||||
import path_provider_foundation
|
import path_provider_foundation
|
||||||
import shared_preferences_foundation
|
import shared_preferences_foundation
|
||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
|
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
|
||||||
|
LocalAuthPlugin.register(with: registry.registrar(forPlugin: "LocalAuthPlugin"))
|
||||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
56
pubspec.lock
56
pubspec.lock
|
|
@ -158,6 +158,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.0.0"
|
version: "5.0.0"
|
||||||
|
flutter_plugin_android_lifecycle:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_plugin_android_lifecycle
|
||||||
|
sha256: ee8068e0e1cd16c4a82714119918efdeed33b3ba7772c54b5d094ab53f9b7fd1
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.33"
|
||||||
flutter_secure_storage:
|
flutter_secure_storage:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|
@ -224,6 +232,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.7.2"
|
version: "4.7.2"
|
||||||
|
intl:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: intl
|
||||||
|
sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.20.2"
|
||||||
js:
|
js:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
@ -272,6 +288,46 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.1.1"
|
version: "5.1.1"
|
||||||
|
local_auth:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: local_auth
|
||||||
|
sha256: "434d854cf478f17f12ab29a76a02b3067f86a63a6d6c4eb8fbfdcfe4879c1b7b"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.3.0"
|
||||||
|
local_auth_android:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: local_auth_android
|
||||||
|
sha256: a0bdfcc0607050a26ef5b31d6b4b254581c3d3ce3c1816ab4d4f4a9173e84467
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.56"
|
||||||
|
local_auth_darwin:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: local_auth_darwin
|
||||||
|
sha256: "699873970067a40ef2f2c09b4c72eb1cfef64224ef041b3df9fdc5c4c1f91f49"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.6.1"
|
||||||
|
local_auth_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: local_auth_platform_interface
|
||||||
|
sha256: f98b8e388588583d3f781f6806e4f4c9f9e189d898d27f0c249b93a1973dd122
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.0"
|
||||||
|
local_auth_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: local_auth_windows
|
||||||
|
sha256: bc4e66a29b0fdf751aafbec923b5bed7ad6ed3614875d8151afe2578520b2ab5
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.11"
|
||||||
matcher:
|
matcher:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ dependencies:
|
||||||
shared_preferences: ^2.5.0
|
shared_preferences: ^2.5.0
|
||||||
dartssh2: ^2.0.0
|
dartssh2: ^2.0.0
|
||||||
flutter_secure_storage: ^9.2.2
|
flutter_secure_storage: ^9.2.2
|
||||||
|
local_auth: ^2.3.0
|
||||||
|
|
||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,11 @@
|
||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
|
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
|
||||||
|
#include <local_auth_windows/local_auth_plugin.h>
|
||||||
|
|
||||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||||
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
|
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
|
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
|
||||||
|
LocalAuthPluginRegisterWithRegistrar(
|
||||||
|
registry->GetRegistrarForPlugin("LocalAuthPlugin"));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
flutter_secure_storage_windows
|
flutter_secure_storage_windows
|
||||||
|
local_auth_windows
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue