Toast on api request, reduced padding, maybe fixed building stuff
This commit is contained in:
parent
f7f37bebec
commit
fd1371fd30
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -57,3 +57,7 @@ linux/flutter/generated_plugin_registrant.cc
|
||||||
windows/flutter/generated_plugin_registrant.cc
|
windows/flutter/generated_plugin_registrant.cc
|
||||||
windows/flutter/generated_plugin_registrant.h
|
windows/flutter/generated_plugin_registrant.h
|
||||||
windows/flutter/generated_plugins.cmake
|
windows/flutter/generated_plugins.cmake
|
||||||
|
*.swift
|
||||||
|
*.cmake
|
||||||
|
*.cc
|
||||||
|
*.h
|
||||||
|
|
|
@ -26,7 +26,7 @@ android {
|
||||||
namespace "com.example.openshock_android"
|
namespace "com.example.openshock_android"
|
||||||
compileSdkVersion flutter.compileSdkVersion
|
compileSdkVersion flutter.compileSdkVersion
|
||||||
ndkVersion flutter.ndkVersion
|
ndkVersion flutter.ndkVersion
|
||||||
|
compileSdkVersion 34
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
|
@ -42,11 +42,11 @@ android {
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||||
applicationId "com.example.openshock_android"
|
applicationId "com.olbiaphlee.openshock_android"
|
||||||
// You can update the following values to match your application needs.
|
// You can update the following values to match your application needs.
|
||||||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
|
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
|
||||||
minSdkVersion flutter.minSdkVersion
|
minSdkVersion 30
|
||||||
targetSdkVersion flutter.targetSdkVersion
|
targetSdkVersion 30
|
||||||
versionCode flutterVersionCode.toInteger()
|
versionCode flutterVersionCode.toInteger()
|
||||||
versionName flutterVersionName
|
versionName flutterVersionName
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart'; // Import HapticFeedback
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
import 'package:OpenshockCompanion/settings_page.dart' show SettingsPage;
|
import 'package:OpenshockCompanion/settings_page.dart' show SettingsPage;
|
||||||
import 'package:OpenshockCompanion/api_handler.dart' show sendApiRequest;
|
import 'package:OpenshockCompanion/api_handler.dart' show sendApiRequest;
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
@ -14,16 +15,15 @@ class MyApp extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return FutureBuilder<bool>(
|
return FutureBuilder<bool>(
|
||||||
// Fetch isDarkMode from SharedPreferences
|
|
||||||
future: getIsDarkMode(),
|
future: getIsDarkMode(),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
final isDarkMode = snapshot.data ?? false; // Use false as a default value
|
final isDarkMode = snapshot.data ?? false;
|
||||||
|
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
theme: isDarkMode ? darkTheme : lightTheme,
|
theme: isDarkMode ? darkTheme : lightTheme,
|
||||||
home: const SliderPage(),
|
home: const SliderPage(),
|
||||||
darkTheme: darkTheme,
|
darkTheme: darkTheme,
|
||||||
themeMode: ThemeMode.system, // Use ThemeMode.dark for always dark mode, ThemeMode.light for always light mode
|
themeMode: ThemeMode.system,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -96,27 +96,29 @@ class _SliderPageState extends State<SliderPage> {
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
ElevatedButton.icon(
|
ElevatedButton.icon(
|
||||||
icon: const Icon(Icons.flash_on), // Lightning bolt icon
|
icon: const Icon(Icons.flash_on),
|
||||||
label: const Text('Shock'),
|
label: const Text('Shock'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (intensityValue < 1 || timeValue < 1) {
|
if (intensityValue < 1 || timeValue < 1) {
|
||||||
// Display a warning, no need for a toast
|
// Display a warning, no need for a toast
|
||||||
} else {
|
} else {
|
||||||
HapticFeedback.vibrate(); // Add haptic feedback
|
HapticFeedback.vibrate();
|
||||||
sendApiRequest(intensityValue, timeValue, 1);
|
sendApiRequest(intensityValue, timeValue, 1);
|
||||||
|
showToast('API request sent');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8.0), // Reduced padding here
|
const SizedBox(width: 8.0),
|
||||||
ElevatedButton.icon(
|
ElevatedButton.icon(
|
||||||
icon: const Icon(Icons.vibration), // Vibration icon
|
icon: const Icon(Icons.vibration),
|
||||||
label: const Text('Vibrate'),
|
label: const Text('Vibrate'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (intensityValue < 1 || timeValue < 1) {
|
if (intensityValue < 1 || timeValue < 1) {
|
||||||
// Display a warning, no need for a toast
|
// Display a warning, no need for a toast
|
||||||
} else {
|
} else {
|
||||||
HapticFeedback.vibrate(); // Add haptic feedback
|
HapticFeedback.vibrate();
|
||||||
sendApiRequest(intensityValue, timeValue, 2);
|
sendApiRequest(intensityValue, timeValue, 2);
|
||||||
|
showToast('API request sent');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -136,6 +138,18 @@ class _SliderPageState extends State<SliderPage> {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void showToast(String message) {
|
||||||
|
Fluttertoast.showToast(
|
||||||
|
msg: message,
|
||||||
|
toastLength: Toast.LENGTH_SHORT,
|
||||||
|
gravity: ToastGravity.BOTTOM,
|
||||||
|
timeInSecForIosWeb: 1,
|
||||||
|
backgroundColor: Colors.green,
|
||||||
|
textColor: Colors.white,
|
||||||
|
fontSize: 16.0,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final ThemeData lightTheme = ThemeData(
|
final ThemeData lightTheme = ThemeData(
|
||||||
|
|
|
@ -136,6 +136,14 @@ packages:
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
fluttertoast:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: fluttertoast
|
||||||
|
sha256: "69a5c4fcfe9a163bc927ff386c0dedd62575913bba942d0ce80c1fd092885255"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "8.2.3"
|
||||||
http:
|
http:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -21,6 +21,7 @@ dependencies:
|
||||||
http: ^0.13.3
|
http: ^0.13.3
|
||||||
shared_preferences: ^2.0.8
|
shared_preferences: ^2.0.8
|
||||||
flutter_launcher_icons: ^0.9.2
|
flutter_launcher_icons: ^0.9.2
|
||||||
|
fluttertoast: ^8.2.3
|
||||||
|
|
||||||
# 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.
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
import 'package:openshock_android/main.dart';
|
import 'package:OpenshockCompanion/main.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
||||||
|
|
Loading…
Reference in a new issue