diff --git a/wien_talks/wien_talks_flutter/README.md b/wien_talks/wien_talks_flutter/README.md index 0a3aefb..4d25881 100644 --- a/wien_talks/wien_talks_flutter/README.md +++ b/wien_talks/wien_talks_flutter/README.md @@ -13,3 +13,15 @@ A great starting point for learning Serverpod is our documentation site at: To run the project, first make sure that the server is running, then do: flutter run + +## Flutter start: + +add environment variable in the Additional arguments field in Android Studio: + +--dart-define=SERVER_URL=http://localhost:5432/ + +Note: Host MUST end with a slash + +## docker start: + +wien_talks_server>docker compose -f docker-compose.local.yaml up -d \ No newline at end of file diff --git a/wien_talks/wien_talks_flutter/lib/helper/funmap_mgr.dart b/wien_talks/wien_talks_flutter/lib/helper/funmap_mgr.dart index 9ed543c..e213c4e 100644 --- a/wien_talks/wien_talks_flutter/lib/helper/funmap_mgr.dart +++ b/wien_talks/wien_talks_flutter/lib/helper/funmap_mgr.dart @@ -10,6 +10,8 @@ class FunmapMgr { late Client client; + late final serverUrl; + factory FunmapMgr() { if (_instance != null) return _instance!; _instance = FunmapMgr._(); @@ -24,11 +26,9 @@ class FunmapMgr { // E.g. `flutter run --dart-define=SERVER_URL=https://api.example.com/` const serverUrlFromEnv = String.fromEnvironment('SERVER_URL'); - final serverUrl = - serverUrlFromEnv.isEmpty ? 'http://$localhost:8080/' : serverUrlFromEnv; + serverUrl = serverUrlFromEnv.isEmpty ? 'http://$localhost:8080/' : serverUrlFromEnv; - client = Client(serverUrl, connectionTimeout: const Duration(seconds: 5)) - ..connectivityMonitor = FlutterConnectivityMonitor(); + client = Client(serverUrl, connectionTimeout: const Duration(seconds: 5))..connectivityMonitor = FlutterConnectivityMonitor(); client.openStreamingConnection(); } diff --git a/wien_talks/wien_talks_flutter/lib/home_screen.dart b/wien_talks/wien_talks_flutter/lib/home_screen.dart index 888e927..ac051f4 100644 --- a/wien_talks/wien_talks_flutter/lib/home_screen.dart +++ b/wien_talks/wien_talks_flutter/lib/home_screen.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; +import 'package:wien_talks_flutter/helper/funmap_mgr.dart'; import 'package:wien_talks_flutter/show_latest_news_widget.dart'; import 'package:wien_talks_flutter/widgets/intro_text_widget.dart'; import 'package:wien_talks_flutter/widgets/screen_widget.dart'; @@ -19,7 +20,7 @@ class HomeScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ IntroTextWidget(), - ShowLatestNewsWidget(), + SizedBox(height: 200, child: ShowLatestNewsWidget()), SizedBox( height: 30, ), @@ -27,6 +28,9 @@ class HomeScreen extends StatelessWidget { children: [ Expanded( child: ElevatedButton( + style: ButtonStyle( + backgroundColor: WidgetStateProperty.all(Theme.of(context).primaryColor), + foregroundColor: WidgetStateProperty.all(Theme.of(context).colorScheme.onPrimary)), onPressed: () { context.pushNamed("create_event"); }, @@ -38,6 +42,12 @@ class HomeScreen extends StatelessWidget { height: 30, ), CarouselWidget(), + Row( + children: [ + Spacer(), + Text(FunmapMgr().serverUrl, style: Theme.of(context).textTheme.bodySmall), + ], + ) ], ), ), diff --git a/wien_talks/wien_talks_flutter/lib/location_mgr.dart b/wien_talks/wien_talks_flutter/lib/location_mgr.dart index 21d3289..451870c 100644 --- a/wien_talks/wien_talks_flutter/lib/location_mgr.dart +++ b/wien_talks/wien_talks_flutter/lib/location_mgr.dart @@ -26,29 +26,24 @@ class LocationMgr { ViewModel? viewModel; - late MapModel mapModel; + MapModel? mapModel; IconMarker? iconMarker; - final DisplayModel displayModel = DisplayModel(maxZoomLevel: 20); + final DisplayModel displayModel = DisplayModel(maxZoomLevel: 18); final SymbolCache symbolCache = FileSymbolCache(); final JobRenderer jobRenderer = MapOnlineRenderer(); + final MarkerByItemDataStore markerDataStore = MarkerByItemDataStore(); + factory LocationMgr() { _instance ??= LocationMgr._(); return _instance!; } - LocationMgr._() { - mapModel = MapModel( - displayModel: displayModel, - renderer: jobRenderer, - symbolCache: symbolCache, - tileBitmapCache: bitmapCache, - ); - } + LocationMgr._() {} Future startup() async { serviceEnabled = await location.serviceEnabled(); @@ -66,6 +61,13 @@ class LocationMgr { return "No permissions granted"; } } + mapModel = MapModel( + displayModel: displayModel, + renderer: jobRenderer, + symbolCache: symbolCache, + tileBitmapCache: bitmapCache, + ); + mapModel?.markerDataStores.add(markerDataStore); viewModel = ViewModel(displayModel: displayModel); _subscription = location.onLocationChanged.listen((LocationData currentLocation) { _lastLocationData = currentLocation; @@ -78,7 +80,7 @@ class LocationMgr { color: Colors.red, center: LatLong(currentLocation.latitude!, currentLocation.longitude!), displayModel: displayModel); - mapModel.markerDataStores.add(MarkerDataStore()..addMarker(iconMarker!)); + mapModel?.markerDataStores.add(MarkerDataStore()..addMarker(iconMarker!)); } } _subject.add(currentLocation); @@ -89,7 +91,8 @@ class LocationMgr { void shutdown() { _subscription?.cancel(); _subscription = null; - mapModel.markerDataStores.clear(); + mapModel?.dispose(); + mapModel = null; iconMarker = null; viewModel?.dispose(); viewModel = null; diff --git a/wien_talks/wien_talks_flutter/lib/main.dart b/wien_talks/wien_talks_flutter/lib/main.dart index 0ced7fe..0842ce8 100644 --- a/wien_talks/wien_talks_flutter/lib/main.dart +++ b/wien_talks/wien_talks_flutter/lib/main.dart @@ -1,9 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:wien_talks_flutter/helper/funmap_mgr.dart'; import 'package:wien_talks_flutter/helper/go_router.dart'; void main() { - FunmapMgr().configure(); runApp(const MyApp()); } diff --git a/wien_talks/wien_talks_flutter/lib/mapfile_widget.dart b/wien_talks/wien_talks_flutter/lib/mapfile_widget.dart index 8134338..477e2a5 100644 --- a/wien_talks/wien_talks_flutter/lib/mapfile_widget.dart +++ b/wien_talks/wien_talks_flutter/lib/mapfile_widget.dart @@ -17,7 +17,7 @@ class _MapfileWidgetState extends State { return MapviewWidget( displayModel: LocationMgr().displayModel, createMapModel: () async { - return LocationMgr().mapModel; + return LocationMgr().mapModel!; }, createViewModel: () async { return LocationMgr().viewModel!; diff --git a/wien_talks/wien_talks_flutter/lib/news_input_form.dart b/wien_talks/wien_talks_flutter/lib/news_input_form.dart index 21abde7..3e63217 100644 --- a/wien_talks/wien_talks_flutter/lib/news_input_form.dart +++ b/wien_talks/wien_talks_flutter/lib/news_input_form.dart @@ -78,6 +78,9 @@ class _NewsInputFormState extends State { ), const SizedBox(height: 16.0), ElevatedButton( + style: ButtonStyle( + backgroundColor: WidgetStateProperty.all(Theme.of(context).primaryColor), + foregroundColor: WidgetStateProperty.all(Theme.of(context).colorScheme.onPrimary)), onPressed: _submitForm, child: const Text('Submit News'), ), diff --git a/wien_talks/wien_talks_flutter/lib/widgets/error_snackbar.dart b/wien_talks/wien_talks_flutter/lib/widgets/error_snackbar.dart index 3529899..d527a95 100644 --- a/wien_talks/wien_talks_flutter/lib/widgets/error_snackbar.dart +++ b/wien_talks/wien_talks_flutter/lib/widgets/error_snackbar.dart @@ -3,7 +3,11 @@ import 'package:flutter/material.dart'; class ErrorSnackbar { void show(BuildContext context, String message) { ScaffoldMessenger.of(context).showSnackBar(SnackBar( - content: Text(message, style: TextStyle(color: Theme.of(context).colorScheme.onError)), + content: Text( + message, + style: TextStyle(color: Theme.of(context).colorScheme.onError), + maxLines: 3, + ), showCloseIcon: true, duration: Duration(seconds: 30), backgroundColor: Theme.of(context).colorScheme.error, diff --git a/wien_talks/wien_talks_flutter/lib/widgets/intro_text_widget.dart b/wien_talks/wien_talks_flutter/lib/widgets/intro_text_widget.dart index 5a6bcd6..4ed73d1 100644 --- a/wien_talks/wien_talks_flutter/lib/widgets/intro_text_widget.dart +++ b/wien_talks/wien_talks_flutter/lib/widgets/intro_text_widget.dart @@ -6,9 +6,9 @@ class IntroTextWidget extends StatelessWidget { @override Widget build(BuildContext context) { - return Padding( - padding: const EdgeInsets.all(8.0), - child: Card( + return Card( + child: Padding( + padding: const EdgeInsets.all(8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -23,7 +23,7 @@ class IntroTextWidget extends StatelessWidget { const SizedBox(height: 20), Text( "Ever experienced something funny, weird, or just too good not to share? " - "With FunMap, you can pin your funniest moments and strange encounters right on the map! ๐Ÿ—บ๏ธ๐Ÿ˜‚", + "With FunMap, you can pin your funniest moments and strange encounters right on the map! ๐Ÿ˜‚", style: GoogleFonts.roboto(fontSize: 16, height: 1.5), ), const SizedBox(height: 16), @@ -38,16 +38,16 @@ class IntroTextWidget extends StatelessWidget { "๐Ÿ‘‰ Add your event, mark the spot, and let the community enjoy the laughter with you.", style: GoogleFonts.roboto( fontSize: 16, - fontWeight: FontWeight.w600, + fontStyle: FontStyle.italic, height: 1.5, ), ), const SizedBox(height: 16), Text( - "Because the worldโ€™s a lot more fun when we laugh together. ๐ŸŒโœจ", + "Because the worldโ€™s a lot more fun when we laugh together.", style: GoogleFonts.roboto( fontSize: 16, - fontStyle: FontStyle.italic, + fontWeight: FontWeight.w600, height: 1.5, ), ),