diff --git a/lib/main.dart b/lib/main.dart index 2eec633..5898a73 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:global_configuration/global_configuration.dart'; import 'package:multimedia/widgets/tabsScreen.dart'; @@ -15,7 +15,35 @@ final theme = ThemeData( void main() async { WidgetsFlutterBinding.ensureInitialized(); - await GlobalConfiguration().loadFromPath('assets/cfg/config.json'); + SharedPreferences prefs = await SharedPreferences.getInstance(); + + String? dbProtocol = prefs.getString('dbProtocol'); + String? dbHost = prefs.getString('dbHost'); + String? dbPath = prefs.getString('dbPath'); + String? dbUser = prefs.getString('dbUser'); + String? dbPassword = prefs.getString('dbPassword'); + + // if (dbProtocol == null) { + // prefs.setString('dbProtocol', 'http'); + // } + // if (dbHost == null) { + // prefs.setString('dbHost', '192.168.0.70'); + // } + if (dbProtocol == null) { + prefs.setString('dbProtocol', 'https'); + } + if (dbHost == null) { + prefs.setString('dbHost', 'api.windesign.at'); + } + if (dbPath == null) { + prefs.setString('dbPath', '/multimedia.php'); + } + if (dbUser == null) { + prefs.setString('dbUser', ''); + } + if (dbPassword == null) { + prefs.setString('dbPassword', ''); + } runApp(const MyApp()); } @@ -25,7 +53,6 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - return MaterialApp( theme: theme, title: 'Multimedia', diff --git a/lib/widgets/moviesScreen.dart b/lib/widgets/moviesScreen.dart index 193ca71..1e44609 100644 --- a/lib/widgets/moviesScreen.dart +++ b/lib/widgets/moviesScreen.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'package:shared_preferences/shared_preferences.dart'; import 'package:intl/intl.dart'; import 'package:flutter/material.dart'; @@ -7,8 +8,6 @@ import 'package:http/http.dart' as http; import 'package:syncfusion_flutter_datagrid/datagrid.dart'; import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:global_configuration/global_configuration.dart'; - import 'package:multimedia/data/movies.dart'; Color _kColorInit = const Color.fromARGB(255, 192, 192, 192); @@ -30,10 +29,16 @@ class _MoviesScreenState extends State { List _columns = []; Future> generateMovieList() async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + + String? dbProtocol = prefs.getString('dbProtocol'); + String? dbHost = prefs.getString('dbHost'); + String? dbPath = prefs.getString('dbPath'); + Uri url = Uri( - scheme: GlobalConfiguration().getValue('dbProtocol'), - host: GlobalConfiguration().getValue('dbHost'), - path: GlobalConfiguration().getValue('dbPath'), + scheme: dbProtocol, + host: dbHost, + path: dbPath, queryParameters: { 'module': 'movie', 'function': 'getList', diff --git a/lib/widgets/tvshowsScreen.dart b/lib/widgets/tvshowsScreen.dart index 510028c..1a969c5 100644 --- a/lib/widgets/tvshowsScreen.dart +++ b/lib/widgets/tvshowsScreen.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'package:shared_preferences/shared_preferences.dart'; import 'package:intl/intl.dart'; import 'package:flutter/material.dart'; @@ -7,8 +8,6 @@ import 'package:http/http.dart' as http; import 'package:syncfusion_flutter_datagrid/datagrid.dart'; import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:global_configuration/global_configuration.dart'; - import 'package:multimedia/data/tvshows.dart'; Color _kColorInit = const Color.fromARGB(255, 192, 192, 192); @@ -30,10 +29,18 @@ class _TVShowsScreenState extends State { List _columns = []; Future> generateTVShowList() async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + + String? dbProtocol = prefs.getString('dbProtocol'); + String? dbHost = prefs.getString('dbHost'); + String? dbPath = prefs.getString('dbPath'); + + print(dbHost); + Uri url = Uri( - scheme: GlobalConfiguration().getValue('dbProtocol'), - host: GlobalConfiguration().getValue('dbHost'), - path: GlobalConfiguration().getValue('dbPath'), + scheme: dbProtocol, + host: dbHost, + path: dbPath, queryParameters: { 'module': 'tvshow', 'function': 'getList', @@ -110,6 +117,13 @@ class _TVShowsScreenState extends State { padding: const EdgeInsets.all(8.0), alignment: Alignment.centerLeft, child: const Text('Resolution'))), + GridColumn( + columnName: 'season1', + columnWidthMode: ColumnWidthMode.auto, + label: Container( + padding: const EdgeInsets.all(8.0), + alignment: Alignment.centerLeft, + child: const Text('Season 1'))), ]; } @@ -173,6 +187,7 @@ class TVShowDataSource extends DataGridSource { value: DateFormat('yyyy-MM-dd').format(e.firstAired)), DataGridCell( columnName: 'resolution', value: e.resolution), + DataGridCell(columnName: 'season1', value: ''), ])) .toList(); } @@ -216,6 +231,13 @@ class TVShowDataSource extends DataGridSource { } } + // if (e.columnName.startsWith('season')) { + // return Container( + // alignment: Alignment.center, + // padding: EdgeInsets.symmetric(horizontal: 16), + // child: Icon(Icons.location_on), + // ); + // } return Container( alignment: Alignment.centerLeft, padding: const EdgeInsets.all(8.0), diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index e777c67..b8e2b22 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -6,7 +6,9 @@ import FlutterMacOS import Foundation import path_provider_foundation +import shared_preferences_foundation func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) + SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index 3de4050..dda450e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -73,6 +73,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.2" + file: + dependency: transitive + description: + name: file + sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" + url: "https://pub.dev" + source: hosted + version: "7.0.0" flutter: dependency: "direct main" description: flutter @@ -91,14 +99,11 @@ packages: description: flutter source: sdk version: "0.0.0" - global_configuration: - dependency: "direct main" - description: - name: global_configuration - sha256: "432cfe858cfad7263b5cd51b1d342865a3983c400185f3839cc63b4b20702f66" - url: "https://pub.dev" - source: hosted - version: "2.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" google_fonts: dependency: "direct main" description: @@ -259,6 +264,62 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.8" + shared_preferences: + dependency: "direct main" + description: + name: shared_preferences + sha256: "81429e4481e1ccfb51ede496e916348668fd0921627779233bd24cc3ff6abd02" + url: "https://pub.dev" + source: hosted + version: "2.2.2" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + sha256: "8568a389334b6e83415b6aae55378e158fbc2314e074983362d20c562780fb06" + url: "https://pub.dev" + source: hosted + version: "2.2.1" + shared_preferences_foundation: + dependency: transitive + description: + name: shared_preferences_foundation + sha256: "7708d83064f38060c7b39db12aefe449cb8cdc031d6062280087bc4cdb988f5c" + url: "https://pub.dev" + source: hosted + version: "2.3.5" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + sha256: "9f2cbcf46d4270ea8be39fa156d86379077c8a5228d9dfdb1164ae0bb93f1faa" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + sha256: "22e2ecac9419b4246d7c22bfbbda589e3acf5c0351137d87dd2939d984d37c3b" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + shared_preferences_web: + dependency: transitive + description: + name: shared_preferences_web + sha256: "9aee1089b36bd2aafe06582b7d7817fd317ef05fc30e6ba14bff247d0933042a" + url: "https://pub.dev" + source: hosted + version: "2.3.0" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + sha256: "841ad54f3c8381c480d0c9b508b89a34036f512482c407e6df7a9c4aa2ef8f59" + url: "https://pub.dev" + source: hosted + version: "2.3.2" sky_engine: dependency: transitive description: flutter @@ -300,18 +361,18 @@ packages: dependency: "direct main" description: name: syncfusion_flutter_core - sha256: d098e3cf5ee0c5a37b083f2efdb7c6bdfaabf871f68758bb491b10b61b3dd0d7 + sha256: "9fae07d8d1f1f66c61ad40cce8f85c02b8a3506ff0c3eae8ace0fd1d504b1ea5" url: "https://pub.dev" source: hosted - version: "25.1.37" + version: "25.1.38" syncfusion_flutter_datagrid: dependency: "direct main" description: name: syncfusion_flutter_datagrid - sha256: "4edf6a41ab6bc398a79a0a29aa67a3fca53dab492d6c844f4c28a94c030f1785" + sha256: "261587a0a673c5a38f46a48b1279ce24755c08645115021efc439483b583a2af" url: "https://pub.dev" source: hosted - version: "25.1.37" + version: "25.1.38" term_glyph: dependency: transitive description: @@ -364,10 +425,10 @@ packages: dependency: transitive description: name: win32 - sha256: "8cb58b45c47dcb42ab3651533626161d6b67a2921917d8d429791f76972b3480" + sha256: "0a989dc7ca2bb51eac91e8fd00851297cfffd641aa7538b165c62637ca0eaa4a" url: "https://pub.dev" source: hosted - version: "5.3.0" + version: "5.4.0" xdg_directories: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index c6d6e5a..11c3935 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -40,8 +40,7 @@ dependencies: intl: ^0.19.0 syncfusion_flutter_core: ^25.1.37 google_fonts: ^6.2.1 - global_configuration: ^2.0.0 - #global_configuration: ^2.0.0 + shared_preferences: ^2.2.2 dev_dependencies: flutter_test: