diff --git a/wien_talks/wien_talks_flutter/assets/funny_images/falco.jpg b/wien_talks/wien_talks_flutter/assets/funny_images/falco.jpg new file mode 100644 index 0000000..e0d214f Binary files /dev/null and b/wien_talks/wien_talks_flutter/assets/funny_images/falco.jpg differ diff --git a/wien_talks/wien_talks_flutter/assets/funny_images/fiaker.jpg b/wien_talks/wien_talks_flutter/assets/funny_images/fiaker.jpg new file mode 100644 index 0000000..e06813e Binary files /dev/null and b/wien_talks/wien_talks_flutter/assets/funny_images/fiaker.jpg differ diff --git a/wien_talks/wien_talks_flutter/assets/funny_images/houses.jpg b/wien_talks/wien_talks_flutter/assets/funny_images/houses.jpg new file mode 100644 index 0000000..ab89968 Binary files /dev/null and b/wien_talks/wien_talks_flutter/assets/funny_images/houses.jpg differ diff --git a/wien_talks/wien_talks_flutter/assets/funny_images/kangaroos.jpg b/wien_talks/wien_talks_flutter/assets/funny_images/kangaroos.jpg new file mode 100644 index 0000000..9418789 Binary files /dev/null and b/wien_talks/wien_talks_flutter/assets/funny_images/kangaroos.jpg differ diff --git a/wien_talks/wien_talks_flutter/assets/funny_images/sightseeing.jpg b/wien_talks/wien_talks_flutter/assets/funny_images/sightseeing.jpg new file mode 100644 index 0000000..ff94183 Binary files /dev/null and b/wien_talks/wien_talks_flutter/assets/funny_images/sightseeing.jpg differ diff --git a/wien_talks/wien_talks_flutter/assets/funny_images/tram.jpg b/wien_talks/wien_talks_flutter/assets/funny_images/tram.jpg new file mode 100644 index 0000000..e9c4d3c Binary files /dev/null and b/wien_talks/wien_talks_flutter/assets/funny_images/tram.jpg differ diff --git a/wien_talks/wien_talks_flutter/assets/funny_images/wastebin.jpg b/wien_talks/wien_talks_flutter/assets/funny_images/wastebin.jpg new file mode 100644 index 0000000..96cdc27 Binary files /dev/null and b/wien_talks/wien_talks_flutter/assets/funny_images/wastebin.jpg differ diff --git a/wien_talks/wien_talks_flutter/lib/carousel_widget.dart b/wien_talks/wien_talks_flutter/lib/carousel_widget.dart new file mode 100644 index 0000000..087b75d --- /dev/null +++ b/wien_talks/wien_talks_flutter/lib/carousel_widget.dart @@ -0,0 +1,26 @@ +import 'package:carousel_slider/carousel_slider.dart'; +import 'package:flutter/material.dart'; + +class CarouselWidget extends StatelessWidget { + const CarouselWidget({super.key}); + + @override + Widget build(BuildContext context) { + return IgnorePointer( + child: CarouselSlider( + options: CarouselOptions(height: 300.0, autoPlay: true), + items: ["houses.jpg", "kangaroos.jpg", "sightseeing.jpg", "tram.jpg", "fiaker.jpg", "falco.jpg", "wastebin.jpg"].map((i) { + return Builder( + builder: (BuildContext context) { + return Container( + width: MediaQuery.of(context).size.width, + margin: EdgeInsets.symmetric(horizontal: 5.0), + //decoration: BoxDecoration(color: Colors.amber), + child: Image(image: AssetImage("assets/funny_images/$i"))); + }, + ); + }).toList(), + ), + ); + } +} diff --git a/wien_talks/wien_talks_flutter/lib/create_event_screen.dart b/wien_talks/wien_talks_flutter/lib/create_event_screen.dart index b08093c..8aa88ab 100644 --- a/wien_talks/wien_talks_flutter/lib/create_event_screen.dart +++ b/wien_talks/wien_talks_flutter/lib/create_event_screen.dart @@ -1,6 +1,8 @@ import 'package:flutter/cupertino.dart'; import 'package:location/location.dart'; +import 'package:wien_talks_client/wien_talks_client.dart'; import 'package:wien_talks_flutter/get_location_widget.dart'; +import 'package:wien_talks_flutter/helper/funmap_mgr.dart'; import 'package:wien_talks_flutter/mapfile_widget.dart'; import 'package:wien_talks_flutter/news_input_form.dart'; import 'package:wien_talks_flutter/widgets/screen_widget.dart'; @@ -15,8 +17,14 @@ class CreateEventScreen extends StatelessWidget { return ScreenWidget( child: Column( children: [ - NewsInputForm(), - StreamBuilder(stream: LocationMgr().stream, builder: (BuildContext context, AsyncSnapshot snapshot) => Text(snapshot.data.toString())), + NewsInputForm( + onSubmit: (CreateQuoteRequest request) async { + await FunmapMgr().client.quote.createQuote(request); + }, + ), + StreamBuilder( + stream: LocationMgr().stream, + builder: (BuildContext context, AsyncSnapshot snapshot) => snapshot.data != null ? Text(snapshot.data.toString()) : SizedBox()), Expanded( child: GetLocationWidget( child: MapfileWidget(), diff --git a/wien_talks/wien_talks_flutter/lib/helper/go_router.dart b/wien_talks/wien_talks_flutter/lib/helper/go_router.dart index 40fb9e9..bdc24c1 100644 --- a/wien_talks/wien_talks_flutter/lib/helper/go_router.dart +++ b/wien_talks/wien_talks_flutter/lib/helper/go_router.dart @@ -1,12 +1,12 @@ import 'package:go_router/go_router.dart'; import 'package:wien_talks_flutter/create_event_screen.dart'; -import 'package:wien_talks_flutter/news_screen.dart'; +import 'package:wien_talks_flutter/home_screen.dart'; final router = GoRouter( routes: [ GoRoute( path: '/', - builder: (context, state) => NewsScreen(), + builder: (context, state) => HomeScreen(), ), GoRoute(path: '/create_event', name: 'create_event', builder: (context, state) => CreateEventScreen()), ], diff --git a/wien_talks/wien_talks_flutter/lib/news_screen.dart b/wien_talks/wien_talks_flutter/lib/home_screen.dart similarity index 56% rename from wien_talks/wien_talks_flutter/lib/news_screen.dart rename to wien_talks/wien_talks_flutter/lib/home_screen.dart index 75f1dc9..888e927 100644 --- a/wien_talks/wien_talks_flutter/lib/news_screen.dart +++ b/wien_talks/wien_talks_flutter/lib/home_screen.dart @@ -4,8 +4,10 @@ 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'; -class NewsScreen extends StatelessWidget { - const NewsScreen({ +import 'carousel_widget.dart'; + +class HomeScreen extends StatelessWidget { + const HomeScreen({ super.key, }); @@ -21,11 +23,21 @@ class NewsScreen extends StatelessWidget { SizedBox( height: 30, ), - ElevatedButton( - onPressed: () { - context.pushNamed("create_event"); - }, - child: Text("Submit your own event")), + Row( + children: [ + Expanded( + child: ElevatedButton( + onPressed: () { + context.pushNamed("create_event"); + }, + child: Text("Submit your own event")), + ), + ], + ), + SizedBox( + height: 30, + ), + CarouselWidget(), ], ), ), diff --git a/wien_talks/wien_talks_flutter/lib/main.dart b/wien_talks/wien_talks_flutter/lib/main.dart index 9e7d98f..e0494e0 100644 --- a/wien_talks/wien_talks_flutter/lib/main.dart +++ b/wien_talks/wien_talks_flutter/lib/main.dart @@ -14,7 +14,7 @@ class MyApp extends StatelessWidget { Widget build(BuildContext context) { return MaterialApp.router( title: 'Wien Talks FunMap', - theme: ThemeData(primarySwatch: Colors.blue), + theme: ThemeData(primarySwatch: Colors.green), routerConfig: router, ); } 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 50d6dd9..21abde7 100644 --- a/wien_talks/wien_talks_flutter/lib/news_input_form.dart +++ b/wien_talks/wien_talks_flutter/lib/news_input_form.dart @@ -2,12 +2,15 @@ import 'package:flutter/material.dart'; import 'package:loader_overlay/loader_overlay.dart'; import 'package:location/location.dart'; import 'package:wien_talks_client/wien_talks_client.dart'; -import 'package:wien_talks_flutter/helper/funmap_mgr.dart'; import 'package:wien_talks_flutter/location_mgr.dart'; import 'package:wien_talks_flutter/widgets/error_snackbar.dart'; +typedef OnSubmit = Future Function(CreateQuoteRequest request); + class NewsInputForm extends StatefulWidget { - const NewsInputForm({super.key}); + final OnSubmit onSubmit; + + const NewsInputForm({super.key, required this.onSubmit}); @override _NewsInputFormState createState() => _NewsInputFormState(); @@ -30,17 +33,16 @@ class _NewsInputFormState extends State { return; } if (_formKey.currentState!.validate()) { + final newsData = CreateQuoteRequest( + text: _newsController.text.trim(), + lat: LocationMgr().lastLocation!.latitude!, + lng: LocationMgr().lastLocation!.longitude!, + ); var handler = context.loaderOverlay..show(); try { - final newsData = CreateQuoteRequest( - text: _newsController.text.trim(), - lat: LocationMgr().lastLocation!.latitude!, - lng: LocationMgr().lastLocation!.longitude!, - ); - await FunmapMgr().client.quote.createQuote(newsData); - _newsController.clear(); + await widget.onSubmit(newsData); } catch (error) { - if (mounted) { + if (context.mounted) { ErrorSnackbar().show(context, error.toString()); } } finally { diff --git a/wien_talks/wien_talks_flutter/pubspec.yaml b/wien_talks/wien_talks_flutter/pubspec.yaml index 2f75789..3d8952c 100644 --- a/wien_talks/wien_talks_flutter/pubspec.yaml +++ b/wien_talks/wien_talks_flutter/pubspec.yaml @@ -25,6 +25,8 @@ dependencies: flutter: sdk: flutter + carousel_slider: ^5.1.1 + flutter_spinkit: ^5.2.2 google_fonts: ^6.3.0 @@ -69,6 +71,7 @@ flutter: # To add assets to your application, add an assets section, like this: assets: + - assets/funny_images/ - assets/render_themes/ - packages/mapsforge_flutter/assets/patterns/dark_farmland.svg - packages/mapsforge_flutter/assets/patterns/dark_military.png