finish save data

This commit is contained in:
Josef Seiringer 2025-04-04 23:47:32 +02:00
parent cccadf4dab
commit 2673d00708
21 changed files with 764 additions and 119 deletions

View File

@ -21,7 +21,7 @@ linter:
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
# Additional information about this file can be found at

View File

@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"

View File

@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"

43
ios/Podfile Normal file
View File

@ -0,0 +1,43 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '12.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
end
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end

23
ios/Podfile.lock Normal file
View File

@ -0,0 +1,23 @@
PODS:
- Flutter (1.0.0)
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
DEPENDENCIES:
- Flutter (from `Flutter`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
EXTERNAL SOURCES:
Flutter:
:path: Flutter
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564
PODFILE CHECKSUM: 4305caec6b40dde0ae97be1573c53de1882a07e5
COCOAPODS: 1.16.2

View File

@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
016AA27A0B1AB36724C71419 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E11D951A81950627C0487557 /* Pods_Runner.framework */; };
0428FA5AFA87759C76195229 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2A4BBC43DD42DE6C4BF78E6E /* Pods_RunnerTests.framework */; };
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
@ -42,9 +44,13 @@
/* Begin PBXFileReference section */
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
2A4BBC43DD42DE6C4BF78E6E /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = "<group>"; };
331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
449DE05A9D06BCC93465BFD1 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
4A45284835CCEFD0E4FA891B /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = "<group>"; };
6E05BF36E95D891D0522C650 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
@ -55,13 +61,26 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
BD0EDE36369146708550036D /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = "<group>"; };
DD8CB3D193CEC406065D6819 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = "<group>"; };
E11D951A81950627C0487557 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
EC779E0DBFB241CF71D4FB74 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
1B2E9C703AD16BD2C39AC81B /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
0428FA5AFA87759C76195229 /* Pods_RunnerTests.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
97C146EB1CF9000F007C117D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
016AA27A0B1AB36724C71419 /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -76,6 +95,15 @@
path = RunnerTests;
sourceTree = "<group>";
};
822138DE292A21094ABA7149 /* Frameworks */ = {
isa = PBXGroup;
children = (
E11D951A81950627C0487557 /* Pods_Runner.framework */,
2A4BBC43DD42DE6C4BF78E6E /* Pods_RunnerTests.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
@ -94,6 +122,8 @@
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
331C8082294A63A400263BE5 /* RunnerTests */,
E90EABED7EBC102E5B636F66 /* Pods */,
822138DE292A21094ABA7149 /* Frameworks */,
);
sourceTree = "<group>";
};
@ -121,6 +151,20 @@
path = Runner;
sourceTree = "<group>";
};
E90EABED7EBC102E5B636F66 /* Pods */ = {
isa = PBXGroup;
children = (
6E05BF36E95D891D0522C650 /* Pods-Runner.debug.xcconfig */,
EC779E0DBFB241CF71D4FB74 /* Pods-Runner.release.xcconfig */,
449DE05A9D06BCC93465BFD1 /* Pods-Runner.profile.xcconfig */,
DD8CB3D193CEC406065D6819 /* Pods-RunnerTests.debug.xcconfig */,
BD0EDE36369146708550036D /* Pods-RunnerTests.release.xcconfig */,
4A45284835CCEFD0E4FA891B /* Pods-RunnerTests.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@ -128,8 +172,10 @@
isa = PBXNativeTarget;
buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */;
buildPhases = (
B57BA05D06F4A34EA5DB43A0 /* [CP] Check Pods Manifest.lock */,
331C807D294A63A400263BE5 /* Sources */,
331C807F294A63A400263BE5 /* Resources */,
1B2E9C703AD16BD2C39AC81B /* Frameworks */,
);
buildRules = (
);
@ -145,12 +191,14 @@
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
24002F274FA95331F7B504E5 /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
CF7F156A5BE2A4218E0346A8 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
@ -222,6 +270,28 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
24002F274FA95331F7B504E5 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
@ -253,6 +323,45 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
B57BA05D06F4A34EA5DB43A0 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
CF7F156A5BE2A4218E0346A8 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@ -379,6 +488,7 @@
};
331C8088294A63A400263BE5 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = DD8CB3D193CEC406065D6819 /* Pods-RunnerTests.debug.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
@ -396,6 +506,7 @@
};
331C8089294A63A400263BE5 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = BD0EDE36369146708550036D /* Pods-RunnerTests.release.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
@ -411,6 +522,7 @@
};
331C808A294A63A400263BE5 /* Profile */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 4A45284835CCEFD0E4FA891B /* Pods-RunnerTests.profile.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;

View File

@ -4,4 +4,7 @@
<FileRef
location = "group:Runner.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>

View File

@ -0,0 +1,228 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:intl/intl.dart';
class HomeController extends GetxController {
final isloadingData = false.obs;
final box = GetStorage();
final listKantine = <dynamic>[].obs;
final newBelegName = '?'.obs;
final newBelegDate = '?'.obs;
final newBelegBetrag = '?'.obs;
@override
void onInit() async {
super.onInit();
await _loadFromNotionKantine();
// Initialize any necessary data or services here
}
@override
void onClose() {}
Future<void> _loadFromNotionKantine() async {
isloadingData(true);
var postUrl = box.read('BASEURL');
var baeraToken = box.read('TOKEN'); // baeraToken aus GetStorage lesen
var headers = Map<String, String>.from(box.read('HEADERS') ?? {});
headers['Authorization'] = 'Bearer $baeraToken';
var httpClient = GetHttpClient(timeout: const Duration(seconds: 20));
var response = await httpClient.post(postUrl, headers: headers);
if (response.isOk) {
// Parse the response data and update your UI accordingly
var data = response.body;
var allJsonDataDynamicList = (data['results']);
for (var item in allJsonDataDynamicList) {
Map<String, dynamic> properties =
item['properties'] as Map<String, dynamic>;
properties['id'] = item['id'];
listKantine.add(properties);
}
listKantine.removeWhere((element) => element['Gelöscht']['number'] == 1);
listKantine.sort((a, b) {
var dateA = DateTime.parse(a['Verkaufsdatum']['date']['start']);
var dateB = DateTime.parse(b['Verkaufsdatum']['date']['start']);
return dateB.compareTo(dateA); // Sort in descending order
});
} else {
// Handle error
print('Error: ${response.statusCode}');
}
isloadingData(false);
httpClient.close();
update();
}
Future<void> addBeleg() async {
var dateFormat = DateFormat('yyyy-MM-dd');
DateTime selectedDate = DateTime.now(); // Standardwert für das Datum
await Get.defaultDialog(
title: 'Beleg hinzufügen',
content: Column(
children: [
TextField(
decoration: InputDecoration(
labelText: 'Beleg Name',
border: OutlineInputBorder(),
),
onChanged: (value) {
newBelegName(value); // Beleg Name speichern
},
),
const SizedBox(height: 10),
TextButton(
onPressed: () async {
DateTime? pickedDate = await showDatePicker(
context: Get.context!,
initialDate: selectedDate,
firstDate: DateTime(2025),
lastDate: DateTime(2100),
);
if (pickedDate != null) {
selectedDate = pickedDate;
newBelegDate.value = dateFormat.format(
selectedDate,
); // Datum speichern
}
},
child: Obx(
() => Text(
'Datum auswählen: ${newBelegDate.value == '?' ? 'Kein Datum' : dateFormat.format(selectedDate)}',
style: TextStyle(
color: newBelegDate.value == '?' ? Colors.red : Colors.black,
fontSize: 20,
),
textAlign: TextAlign.center,
),
),
),
TextField(
decoration: InputDecoration(
labelText: 'Beleg Betrag',
border: OutlineInputBorder(),
),
onChanged: (value) {
newBelegBetrag(value); // Beleg Betrag speichern
},
),
],
),
textConfirm: 'Hinzufügen',
textCancel: 'Abbrechen',
confirmTextColor: Colors.white,
cancelTextColor: Colors.red,
buttonColor: Colors.blue,
onCancel: () {
// Handle cancel action
Get.back();
},
onConfirm: () {
// Handle adding the receipt
print('Beleg Name: ${newBelegName.value}');
print('Beleg Datum: ${newBelegDate.value}');
print('Beleg Betrag: ${newBelegBetrag.value}');
Get.back();
},
);
update();
_saveData();
}
Map<String, dynamic> currentBodyItem(
String currentDate,
String preis,
String belegName,
String dbId,
) {
return {
'parent': {'database_id': dbId},
'properties': {
'Verkaufsdatum': {
'date': {'start': currentDate},
},
'Gelöscht': {'number': 0},
'Betrag': {'number': double.parse(preis)},
'BelegName': {
'id': 'title',
'type': 'title',
'title': [
{
'type': 'text',
'text': {'content': belegName},
},
],
},
},
};
}
Future<void> _saveData() async {
isloadingData(true);
var dbId = 'd036c0bc06304126aedaa8c5ad92b406';
var baeraToken = box.read('TOKEN');
var saveUrl = 'https://api.notion.com/v1/pages/';
var headers = Map<String, String>.from(box.read('HEADERS') ?? {});
headers['Authorization'] = 'Bearer $baeraToken';
var kantinData = currentBodyItem(
newBelegDate.value,
newBelegBetrag.value,
newBelegName.value,
dbId,
);
var httpClient = GetHttpClient(timeout: const Duration(seconds: 20));
await httpClient
.post(saveUrl, headers: headers, body: kantinData)
.then((response) {
if (response.isOk) {
print('Beleg erfolgreich hinzugefügt');
_loadFromNotionKantine();
} else {
print('Fehler beim Hinzufügen des Belegs: ${response.statusCode}');
}
})
.catchError((error) {
print('Fehler: $error');
})
.whenComplete(() {
httpClient.close();
});
newBelegName.value = '?';
newBelegDate.value = '?';
newBelegBetrag.value = '?';
isloadingData(false);
update();
}
void deleteBeleg(stringItem, index) {
isloadingData(true);
print(stringItem);
var baeraToken = box.read('TOKEN');
var delUrl = 'https://api.notion.com/v1/pages/$stringItem/';
var headers = Map<String, String>.from(box.read('HEADERS') ?? {});
headers['Authorization'] = 'Bearer $baeraToken';
var httpClient = GetHttpClient(timeout: const Duration(seconds: 20));
var updateMap = {
'properties': {
'Gelöscht': {'number': 1},
},
};
httpClient
.patch(delUrl, headers: headers, body: updateMap)
.then((response) {
if (response.isOk) {
print('Beleg erfolgreich gelöscht');
} else {
print('Fehler beim Löschen des Belegs: ${response.statusCode}');
}
})
.catchError((error) {
print('Fehler: $error');
})
.whenComplete(() {
httpClient.close();
});
listKantine.removeAt(index);
isloadingData(false);
update();
}
}

View File

@ -1,6 +1,16 @@
import 'package:flutter/material.dart';
import 'dart:io';
void main() {
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import '../../utils/http_overrides.dart';
import '../../pages/home/home_view.dart';
import '../../utils/sample_routes.dart';
void main() async {
await GetStorage.init();
HttpOverrides.global = MyHttpOverrides();
runApp(const MyApp());
}
@ -10,113 +20,32 @@ class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
final boxSettings = GetStorage();
// Eine Map definieren
bool isNoSettings = boxSettings.hasData('BASEURL');
if (isNoSettings == false) {
_preSetDataInLocalStorage(boxSettings);
}
return GetMaterialApp(
debugShowCheckedModeBanner: false, // Debug-Banner deaktivieren
title: 'Kantine Ausgaben',
theme: ThemeData(
// This is the theme of your application.
//
// TRY THIS: Try running your application with "flutter run". You'll see
// the application has a purple toolbar. Then, without quitting the app,
// try changing the seedColor in the colorScheme below to Colors.green
// and then invoke "hot reload" (save your changes or press the "hot
// reload" button in a Flutter-supported IDE, or press "r" if you used
// the command line to start the app).
//
// Notice that the counter didn't reset back to zero; the application
// state is not lost during the reload. To reset the state, use hot
// restart instead.
//
// This works for code too, not just values: Most code changes can be
// tested with just a hot reload.
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
colorScheme: ColorScheme.fromSeed(seedColor: Colors.grey.shade600),
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
initialRoute: HomePage.namedRoute,
getPages: SampleRouts.samplePages,
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
}
@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// TRY THIS: Try changing the color here to a specific color (to
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
// change color while the other colors stay the same.
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also a layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
//
// TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint"
// action in the IDE, or press "p" in the console), to see the
// wireframe for each widget.
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text('You have pushed the button this many times:'),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
void _preSetDataInLocalStorage(GetStorage boxSettings) {
boxSettings.write('BASEURL', 'https://api.notion.com/v1/databases/d036c0bc06304126aedaa8c5ad92b406/query');
boxSettings.write('TOKEN', 'secret_05Q0wxvdUrJuNC1s1CuEXxO2nxdJFxiPAbWfaDKGWKo');
Map<String, String> headers = {
'Notion-Version': '2021-08-16',
'Content-Type': 'application/json',
};
boxSettings.write('HEADERS', headers);
}
}

View File

View File

@ -0,0 +1,9 @@
import 'package:get/get.dart';
import '../../controller/home_controller.dart';
class HomeBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<HomeController>(() => HomeController());
}
}

View File

@ -0,0 +1,104 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../controller/home_controller.dart';
class HomePage extends GetView<HomeController> {
static const String namedRoute = '/home';
const HomePage({super.key});
@override
Widget build(BuildContext context) {
var homeCtrl = controller;
return SafeArea(
child: Scaffold(
appBar: AppBar(
toolbarHeight: 90,
backgroundColor: Colors.grey.shade800,
centerTitle: true,
title: Text(
'Kantine Ausgaben Liste',
style: TextStyle(color: Colors.grey.shade200, fontSize: 35.0),
),
),
body: Obx(
() =>
homeCtrl.isloadingData.value
? Center(child: CircularProgressIndicator())
: Container(
decoration: BoxDecoration(color: Colors.grey.shade600),
child: ListView.separated(
itemCount: homeCtrl.listKantine.length,
separatorBuilder:
(context, index) =>
Divider(color: Colors.grey.shade700),
padding: EdgeInsets.all(10),
physics: BouncingScrollPhysics(),
shrinkWrap: true,
scrollDirection: Axis.vertical,
primary: false,
itemBuilder: (context, index) {
var properties = homeCtrl.listKantine[index];
var dateStart = properties['Verkaufsdatum']['date']['start'];
var betrag = properties['Betrag']['number'].toString();
var belegName = properties['BelegName']['title'][0]['plain_text'];
return Container(
decoration: BoxDecoration(
color: Colors.grey.shade800,
borderRadius: BorderRadius.circular(10),
),
child: Dismissible(
key: Key(properties['id']),
background: Container(
color: Colors.red,
child: Icon(Icons.delete),
),
direction: DismissDirection.endToStart,
onDismissed: (direction) {
homeCtrl.deleteBeleg(properties['id'], index);
},
child: ListTile(
title: Text(
dateStart,
style: TextStyle(
color: Colors.grey.shade200,
fontSize: 20.0,
),
),
subtitle: Text(
belegName,
style: TextStyle(
color: Colors.grey.shade400,
fontSize: 25.0,
),
),
tileColor: Colors.grey.shade800,
textColor: Colors.grey.shade200,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
contentPadding: EdgeInsets.all(10),
leading: Icon(Icons.money),
trailing: Text(
'$betrag',
style: TextStyle(
color: Colors.green.shade200,
fontSize: 30.0,
),
),
),
),
);
},
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
homeCtrl.addBeleg(); // Add your action here
},
backgroundColor: Colors.grey.shade400,
child: Icon(Icons.add),
),
),
);
}
}

View File

@ -0,0 +1,10 @@
import 'dart:io';
class MyHttpOverrides extends HttpOverrides {
@override
HttpClient createHttpClient(SecurityContext? context) {
return super.createHttpClient(context)
..badCertificateCallback =
(X509Certificate cert, String host, int port) => true;
}
}

View File

@ -0,0 +1,13 @@
import 'package:get/get.dart';
import '../controller/home_controller.dart';
class SampleBindings extends Bindings {
@override
void dependencies() {
Get.lazyPut<HomeController>(() => HomeController());
}
}

View File

@ -0,0 +1,16 @@
import 'package:get/get.dart';
import './sample_bindings.dart';
import '../../pages/home/home_view.dart';
class SampleRouts {
static final sampleBindings = SampleBindings();
static final samplePages = [
GetPage(
name: HomePage.namedRoute,
binding: sampleBindings,
page: () => const HomePage(),
transition: Transition.leftToRight,
),
];
}

View File

@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig"

View File

@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig"

View File

@ -5,6 +5,8 @@
import FlutterMacOS
import Foundation
import path_provider_foundation
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
}

42
macos/Podfile Normal file
View File

@ -0,0 +1,42 @@
platform :osx, '10.14'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\""
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_macos_podfile_setup
target 'Runner' do
use_frameworks!
flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
end
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_macos_build_settings(target)
end
end

View File

@ -57,6 +57,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.2"
ffi:
dependency: transitive
description:
name: ffi
sha256: "289279317b4b16eb2bb7e271abccd4bf84ec9bdcbe999e278a94b804f5630418"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
flutter:
dependency: "direct main"
description: flutter
@ -75,6 +83,30 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
get:
dependency: "direct main"
description:
name: get
sha256: c79eeb4339f1f3deffd9ec912f8a923834bec55f7b49c9e882b8fef2c139d425
url: "https://pub.dev"
source: hosted
version: "4.7.2"
get_storage:
dependency: "direct main"
description:
name: get_storage
sha256: "39db1fffe779d0c22b3a744376e86febe4ade43bf65e06eab5af707dc84185a2"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
intl:
dependency: "direct main"
description:
name: intl
sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5"
url: "https://pub.dev"
source: hosted
version: "0.20.2"
leak_tracker:
dependency: transitive
description:
@ -139,6 +171,70 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.9.1"
path_provider:
dependency: transitive
description:
name: path_provider
sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd"
url: "https://pub.dev"
source: hosted
version: "2.1.5"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
sha256: "0ca7359dad67fd7063cb2892ab0c0737b2daafd807cf1acecd62374c8fae6c12"
url: "https://pub.dev"
source: hosted
version: "2.2.16"
path_provider_foundation:
dependency: transitive
description:
name: path_provider_foundation
sha256: "4843174df4d288f5e29185bd6e72a6fbdf5a4a4602717eed565497429f179942"
url: "https://pub.dev"
source: hosted
version: "2.4.1"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279
url: "https://pub.dev"
source: hosted
version: "2.2.1"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7
url: "https://pub.dev"
source: hosted
version: "2.3.0"
platform:
dependency: transitive
description:
name: platform
sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984"
url: "https://pub.dev"
source: hosted
version: "3.1.6"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
url: "https://pub.dev"
source: hosted
version: "2.1.8"
sky_engine:
dependency: transitive
description: flutter
@ -208,6 +304,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "14.3.1"
web:
dependency: transitive
description:
name: web
sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a"
url: "https://pub.dev"
source: hosted
version: "1.1.1"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
sdks:
dart: ">=3.7.2 <4.0.0"
flutter: ">=3.18.0-18.0.pre.54"
flutter: ">=3.27.0"

View File

@ -28,16 +28,14 @@ environment:
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
cupertino_icons: ^1.0.8
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.8
get: ^4.6.6
get_storage: ^2.1.1
intl: ^0.20.1
dev_dependencies:
flutter_test:
sdk: flutter
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
@ -45,10 +43,11 @@ dev_dependencies:
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^5.0.0
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter packages.
flutter:
@ -56,18 +55,14 @@ flutter:
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/to/resolution-aware-images
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/to/asset-from-package
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a