mod repository appwrite

This commit is contained in:
2026-01-21 13:51:54 +01:00
parent 0299255cc1
commit 7c509419d6
11 changed files with 167 additions and 78 deletions

107
lib/models/tank_model.dart Normal file
View File

@@ -0,0 +1,107 @@
import 'dart:convert';
class TankModel {
final String documentId;
final String userId;
final String date;
final String odometer;
final String liters;
final String pricePerLiter;
final String location;
final String totalPrice;
TankModel({
required this.documentId,
required this.userId,
required this.date,
required this.odometer,
required this.liters,
required this.pricePerLiter,
required this.location,
required this.totalPrice,
});
TankModel copyWith({
String? documentId,
String? userId,
String? date,
String? odometer,
String? liters,
String? pricePerLiter,
String? location,
String? totalPrice,
}) {
return TankModel(
documentId: documentId ?? this.documentId,
userId: userId ?? this.userId,
date: date ?? this.date,
odometer: odometer ?? this.odometer,
liters: liters ?? this.liters,
pricePerLiter: pricePerLiter ?? this.pricePerLiter,
location: location ?? this.location,
totalPrice: totalPrice ?? this.totalPrice,
);
}
Map<String, dynamic> toMap() {
return <String, dynamic>{
'documentId': documentId,
'userId': userId,
'date': date,
'odometer': odometer,
'liters': liters,
'pricePerLiter': pricePerLiter,
'location': location,
'totalPrice': totalPrice,
};
}
factory TankModel.fromMap(Map<String, dynamic> map) {
return TankModel(
documentId: map['documentId'] as String,
userId: map['userId'] as String,
date: map['date'] as String,
odometer: map['odometer'] as String,
liters: map['liters'] as String,
pricePerLiter: map['pricePerLiter'] as String,
location: map['location'] as String,
totalPrice: map['totalPrice'] as String,
);
}
String toJson() => json.encode(toMap());
factory TankModel.fromJson(String source) => TankModel.fromMap(json.decode(source) as Map<String, dynamic>);
@override
String toString() {
return 'TankModel(documentId: $documentId, userId: $userId, date: $date, odometer: $odometer, liters: $liters, pricePerLiter: $pricePerLiter, location: $location, totalPrice: $totalPrice)';
}
@override
bool operator ==(covariant TankModel other) {
if (identical(this, other)) return true;
return
other.documentId == documentId &&
other.userId == userId &&
other.date == date &&
other.odometer == odometer &&
other.liters == liters &&
other.pricePerLiter == pricePerLiter &&
other.location == location &&
other.totalPrice == totalPrice;
}
@override
int get hashCode {
return documentId.hashCode ^
userId.hashCode ^
date.hashCode ^
odometer.hashCode ^
liters.hashCode ^
pricePerLiter.hashCode ^
location.hashCode ^
totalPrice.hashCode;
}
}

View File

@@ -29,6 +29,7 @@ class AppWriteProvider {
} }
Future<models.Session> login(Map map) async { Future<models.Session> login(Map map) async {
await logout();
final response = await account!.createEmailPasswordSession( final response = await account!.createEmailPasswordSession(
email: map['email'], email: map['email'],
password: map['password'], password: map['password'],
@@ -89,52 +90,52 @@ class AppWriteProvider {
// Tank Stop CRUD operations // Tank Stop CRUD operations
// Create, Update, Get, List Tank Stops // Create, Update, Get, List Tank Stops
// Future<models.Document> createTankStop(Map map) async { Future<models.Document> createTankStop(Map map) async {
// final response = await database!.createDocument( final response = await database!.createDocument(
// databaseId: kAppWriteDatabaseID, databaseId: szDatabaseID,
// collectionId: kAppWriteCollectionID, collectionId: szCollectionID,
// documentId: ID.unique(), documentId: ID.unique(),
// data: map, data: map,
// ); );
// return response; return response;
// } }
// Future<models.Document> updateTankStop(String documentId, Map map) async { Future<models.Document> updateTankStop(String documentId, Map map) async {
// final response = await database!.updateDocument( final response = await database!.updateDocument(
// databaseId: kAppWriteDatabaseID, databaseId: szDatabaseID,
// collectionId: kAppWriteCollectionID, collectionId: szCollectionID,
// documentId: documentId, documentId: documentId,
// data: map, data: map,
// ); );
// return response; return response;
// } }
// Future<models.Document> getTankStopById(String documentId) async { Future<models.Document> getTankStopById(String documentId) async {
// final response = await database!.getDocument( final response = await database!.getDocument(
// databaseId: kAppWriteDatabaseID, databaseId: szDatabaseID,
// collectionId: kAppWriteCollectionID, collectionId: szCollectionID,
// documentId: documentId, documentId: documentId,
// ); );
// return response; return response;
// } }
// Future<models.DocumentList> listTankStops(String userId) async { Future<models.DocumentList> listTankStops(String userId) async {
// final response = await database!.listDocuments( final response = await database!.listDocuments(
// databaseId: kAppWriteDatabaseID, databaseId: szDatabaseID,
// collectionId: kAppWriteCollectionID, collectionId: szCollectionID,
// queries: [Query.equal('userId', userId)], queries: [Query.equal('userId', userId)],
// ); );
// return response; return response;
// } }
// Future<models.Document> deleteTankStop(String documentId) async { Future<models.Document> deleteTankStop(String documentId) async {
// final response = await database!.deleteDocument( final response = await database!.deleteDocument(
// databaseId: kAppWriteDatabaseID, databaseId: szDatabaseID,
// collectionId: kAppWriteCollectionID, collectionId: szCollectionID,
// documentId: documentId, documentId: documentId,
// ); );
// return response; return response;
// } }
// Future<models.Document> createTrackPoint(map) async { // Future<models.Document> createTrackPoint(map) async {
// final response = await database!.createDocument( // final response = await database!.createDocument(

View File

@@ -6,14 +6,10 @@
#include "generated_plugin_registrant.h" #include "generated_plugin_registrant.h"
#include <desktop_webview_window/desktop_webview_window_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h> #include <url_launcher_linux/url_launcher_plugin.h>
#include <window_to_front/window_to_front_plugin.h> #include <window_to_front/window_to_front_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) { void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) desktop_webview_window_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "DesktopWebviewWindowPlugin");
desktop_webview_window_plugin_register_with_registrar(desktop_webview_window_registrar);
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);

View File

@@ -3,7 +3,6 @@
# #
list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_PLUGIN_LIST
desktop_webview_window
url_launcher_linux url_launcher_linux
window_to_front window_to_front
) )

View File

@@ -5,7 +5,6 @@
import FlutterMacOS import FlutterMacOS
import Foundation import Foundation
import desktop_webview_window
import device_info_plus import device_info_plus
import flutter_web_auth_2 import flutter_web_auth_2
import package_info_plus import package_info_plus
@@ -14,7 +13,6 @@ import url_launcher_macos
import window_to_front import window_to_front
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
DesktopWebviewWindowPlugin.register(with: registry.registrar(forPlugin: "DesktopWebviewWindowPlugin"))
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
FlutterWebAuth2Plugin.register(with: registry.registrar(forPlugin: "FlutterWebAuth2Plugin")) FlutterWebAuth2Plugin.register(with: registry.registrar(forPlugin: "FlutterWebAuth2Plugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))

View File

@@ -5,10 +5,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: appwrite name: appwrite
sha256: "2214b9f5f8227fd16b8e25539cee70a3df618be5b4a4c5602bcb1e5cde0f53e4" sha256: "0d354ab7c42f25b38ed6c54225a997573c0ecc70e83cfabbdd1161fd6dbea752"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "20.2.2" version: "16.1.0"
async: async:
dependency: transitive dependency: transitive
description: description:
@@ -73,22 +73,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.0.8" version: "1.0.8"
desktop_webview_window:
dependency: transitive
description:
name: desktop_webview_window
sha256: "57cf20d81689d5cbb1adfd0017e96b669398a669d927906073b0e42fc64111c0"
url: "https://pub.dev"
source: hosted
version: "0.2.3"
device_info_plus: device_info_plus:
dependency: transitive dependency: transitive
description: description:
name: device_info_plus name: device_info_plus
sha256: dd0e8e02186b2196c7848c9d394a5fd6e5b57a43a546082c5820b1ec72317e33 sha256: a7fd703482b391a87d60b6061d04dfdeab07826b96f9abd8f5ed98068acc0074
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "12.2.0" version: "10.1.2"
device_info_plus_platform_interface: device_info_plus_platform_interface:
dependency: transitive dependency: transitive
description: description:
@@ -151,18 +143,18 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: flutter_web_auth_2 name: flutter_web_auth_2
sha256: "3c14babeaa066c371f3a743f204dd0d348b7d42ffa6fae7a9847a521aff33696" sha256: "4d3d2fd3d26bf1a26b3beafd4b4b899c0ffe10dc99af25abc58ffe24e991133c"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.1.0" version: "3.1.2"
flutter_web_auth_2_platform_interface: flutter_web_auth_2_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: flutter_web_auth_2_platform_interface name: flutter_web_auth_2_platform_interface
sha256: c63a472c8070998e4e422f6b34a17070e60782ac442107c70000dd1bed645f4d sha256: e8669e262005a8354389ba2971f0fc1c36188481234ff50d013aaf993f30f739
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.1.0" version: "3.1.0"
flutter_web_plugins: flutter_web_plugins:
dependency: transitive dependency: transitive
description: flutter description: flutter
@@ -244,18 +236,18 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.16.0" version: "1.17.0"
package_info_plus: package_info_plus:
dependency: transitive dependency: transitive
description: description:
name: package_info_plus name: package_info_plus
sha256: f69da0d3189a4b4ceaeb1a3defb0f329b3b352517f52bed4290f83d4f06bc08d sha256: "16eee997588c60225bda0488b6dcfac69280a6b7a3cf02c741895dd370a02968"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "9.0.0" version: "8.3.1"
package_info_plus_platform_interface: package_info_plus_platform_interface:
dependency: transitive dependency: transitive
description: description:
@@ -385,10 +377,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00" sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.7.6" version: "0.7.7"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
@@ -521,10 +513,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: win32_registry name: win32_registry
sha256: "6f1b564492d0147b330dd794fee8f512cec4977957f310f9951b5f9d83618dae" sha256: "21ec76dfc731550fd3e2ce7a33a9ea90b828fdf19a5c3bcf556fa992cfa99852"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.0" version: "1.1.5"
window_to_front: window_to_front:
dependency: transitive dependency: transitive
description: description:

View File

@@ -9,7 +9,7 @@ environment:
sdk: ^3.9.2 sdk: ^3.9.2
dependencies: dependencies:
appwrite: ^20.2.2 appwrite: ^16.0.0
cupertino_icons: ^1.0.8 cupertino_icons: ^1.0.8
flutter: flutter:
sdk: flutter sdk: flutter

View File

@@ -6,13 +6,10 @@
#include "generated_plugin_registrant.h" #include "generated_plugin_registrant.h"
#include <desktop_webview_window/desktop_webview_window_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h> #include <url_launcher_windows/url_launcher_windows.h>
#include <window_to_front/window_to_front_plugin.h> #include <window_to_front/window_to_front_plugin.h>
void RegisterPlugins(flutter::PluginRegistry* registry) { void RegisterPlugins(flutter::PluginRegistry* registry) {
DesktopWebviewWindowPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("DesktopWebviewWindowPlugin"));
UrlLauncherWindowsRegisterWithRegistrar( UrlLauncherWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherWindows")); registry->GetRegistrarForPlugin("UrlLauncherWindows"));
WindowToFrontPluginRegisterWithRegistrar( WindowToFrontPluginRegisterWithRegistrar(

View File

@@ -3,7 +3,6 @@
# #
list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_PLUGIN_LIST
desktop_webview_window
url_launcher_windows url_launcher_windows
window_to_front window_to_front
) )