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.h
|
||||
windows/flutter/generated_plugins.cmake
|
||||
*.swift
|
||||
*.cmake
|
||||
*.cc
|
||||
*.h
|
||||
|
|
|
@ -26,7 +26,7 @@ android {
|
|||
namespace "com.example.openshock_android"
|
||||
compileSdkVersion flutter.compileSdkVersion
|
||||
ndkVersion flutter.ndkVersion
|
||||
|
||||
compileSdkVersion 34
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
|
@ -42,11 +42,11 @@ android {
|
|||
|
||||
defaultConfig {
|
||||
// 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.
|
||||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
|
||||
minSdkVersion flutter.minSdkVersion
|
||||
targetSdkVersion flutter.targetSdkVersion
|
||||
minSdkVersion 30
|
||||
targetSdkVersion 30
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
versionName flutterVersionName
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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/api_handler.dart' show sendApiRequest;
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
@ -14,16 +15,15 @@ class MyApp extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder<bool>(
|
||||
// Fetch isDarkMode from SharedPreferences
|
||||
future: getIsDarkMode(),
|
||||
builder: (context, snapshot) {
|
||||
final isDarkMode = snapshot.data ?? false; // Use false as a default value
|
||||
final isDarkMode = snapshot.data ?? false;
|
||||
|
||||
return MaterialApp(
|
||||
theme: isDarkMode ? darkTheme : lightTheme,
|
||||
home: const SliderPage(),
|
||||
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,
|
||||
children: [
|
||||
ElevatedButton.icon(
|
||||
icon: const Icon(Icons.flash_on), // Lightning bolt icon
|
||||
icon: const Icon(Icons.flash_on),
|
||||
label: const Text('Shock'),
|
||||
onPressed: () {
|
||||
if (intensityValue < 1 || timeValue < 1) {
|
||||
// Display a warning, no need for a toast
|
||||
} else {
|
||||
HapticFeedback.vibrate(); // Add haptic feedback
|
||||
HapticFeedback.vibrate();
|
||||
sendApiRequest(intensityValue, timeValue, 1);
|
||||
showToast('API request sent');
|
||||
}
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 8.0), // Reduced padding here
|
||||
const SizedBox(width: 8.0),
|
||||
ElevatedButton.icon(
|
||||
icon: const Icon(Icons.vibration), // Vibration icon
|
||||
icon: const Icon(Icons.vibration),
|
||||
label: const Text('Vibrate'),
|
||||
onPressed: () {
|
||||
if (intensityValue < 1 || timeValue < 1) {
|
||||
// Display a warning, no need for a toast
|
||||
} else {
|
||||
HapticFeedback.vibrate(); // Add haptic feedback
|
||||
HapticFeedback.vibrate();
|
||||
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(
|
||||
|
|
|
@ -136,6 +136,14 @@ packages:
|
|||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
fluttertoast:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: fluttertoast
|
||||
sha256: "69a5c4fcfe9a163bc927ff386c0dedd62575913bba942d0ce80c1fd092885255"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "8.2.3"
|
||||
http:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
|
@ -21,6 +21,7 @@ dependencies:
|
|||
http: ^0.13.3
|
||||
shared_preferences: ^2.0.8
|
||||
flutter_launcher_icons: ^0.9.2
|
||||
fluttertoast: ^8.2.3
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:openshock_android/main.dart';
|
||||
import 'package:OpenshockCompanion/main.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
||||
|
|
Loading…
Reference in a new issue