carousel implemented

This commit is contained in:
mikes222 2025-08-16 17:55:23 +02:00
parent 642dddaaa3
commit 1ef6e06329
14 changed files with 73 additions and 22 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View file

@ -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(),
),
);
}
}

View file

@ -1,6 +1,8 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:location/location.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/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/mapfile_widget.dart';
import 'package:wien_talks_flutter/news_input_form.dart'; import 'package:wien_talks_flutter/news_input_form.dart';
import 'package:wien_talks_flutter/widgets/screen_widget.dart'; import 'package:wien_talks_flutter/widgets/screen_widget.dart';
@ -15,8 +17,14 @@ class CreateEventScreen extends StatelessWidget {
return ScreenWidget( return ScreenWidget(
child: Column( child: Column(
children: [ children: [
NewsInputForm(), NewsInputForm(
StreamBuilder(stream: LocationMgr().stream, builder: (BuildContext context, AsyncSnapshot<LocationData> snapshot) => Text(snapshot.data.toString())), onSubmit: (CreateQuoteRequest request) async {
await FunmapMgr().client.quote.createQuote(request);
},
),
StreamBuilder(
stream: LocationMgr().stream,
builder: (BuildContext context, AsyncSnapshot<LocationData> snapshot) => snapshot.data != null ? Text(snapshot.data.toString()) : SizedBox()),
Expanded( Expanded(
child: GetLocationWidget( child: GetLocationWidget(
child: MapfileWidget(), child: MapfileWidget(),

View file

@ -1,12 +1,12 @@
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:wien_talks_flutter/create_event_screen.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( final router = GoRouter(
routes: [ routes: [
GoRoute( GoRoute(
path: '/', path: '/',
builder: (context, state) => NewsScreen(), builder: (context, state) => HomeScreen(),
), ),
GoRoute(path: '/create_event', name: 'create_event', builder: (context, state) => CreateEventScreen()), GoRoute(path: '/create_event', name: 'create_event', builder: (context, state) => CreateEventScreen()),
], ],

View file

@ -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/intro_text_widget.dart';
import 'package:wien_talks_flutter/widgets/screen_widget.dart'; import 'package:wien_talks_flutter/widgets/screen_widget.dart';
class NewsScreen extends StatelessWidget { import 'carousel_widget.dart';
const NewsScreen({
class HomeScreen extends StatelessWidget {
const HomeScreen({
super.key, super.key,
}); });
@ -21,11 +23,21 @@ class NewsScreen extends StatelessWidget {
SizedBox( SizedBox(
height: 30, height: 30,
), ),
ElevatedButton( Row(
onPressed: () { children: [
context.pushNamed("create_event"); Expanded(
}, child: ElevatedButton(
child: Text("Submit your own event")), onPressed: () {
context.pushNamed("create_event");
},
child: Text("Submit your own event")),
),
],
),
SizedBox(
height: 30,
),
CarouselWidget(),
], ],
), ),
), ),

View file

@ -14,7 +14,7 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp.router( return MaterialApp.router(
title: 'Wien Talks FunMap', title: 'Wien Talks FunMap',
theme: ThemeData(primarySwatch: Colors.blue), theme: ThemeData(primarySwatch: Colors.green),
routerConfig: router, routerConfig: router,
); );
} }

View file

@ -2,12 +2,15 @@ import 'package:flutter/material.dart';
import 'package:loader_overlay/loader_overlay.dart'; import 'package:loader_overlay/loader_overlay.dart';
import 'package:location/location.dart'; import 'package:location/location.dart';
import 'package:wien_talks_client/wien_talks_client.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/location_mgr.dart';
import 'package:wien_talks_flutter/widgets/error_snackbar.dart'; import 'package:wien_talks_flutter/widgets/error_snackbar.dart';
typedef OnSubmit = Future<void> Function(CreateQuoteRequest request);
class NewsInputForm extends StatefulWidget { class NewsInputForm extends StatefulWidget {
const NewsInputForm({super.key}); final OnSubmit onSubmit;
const NewsInputForm({super.key, required this.onSubmit});
@override @override
_NewsInputFormState createState() => _NewsInputFormState(); _NewsInputFormState createState() => _NewsInputFormState();
@ -30,17 +33,16 @@ class _NewsInputFormState extends State<NewsInputForm> {
return; return;
} }
if (_formKey.currentState!.validate()) { if (_formKey.currentState!.validate()) {
final newsData = CreateQuoteRequest(
text: _newsController.text.trim(),
lat: LocationMgr().lastLocation!.latitude!,
lng: LocationMgr().lastLocation!.longitude!,
);
var handler = context.loaderOverlay..show(); var handler = context.loaderOverlay..show();
try { try {
final newsData = CreateQuoteRequest( await widget.onSubmit(newsData);
text: _newsController.text.trim(),
lat: LocationMgr().lastLocation!.latitude!,
lng: LocationMgr().lastLocation!.longitude!,
);
await FunmapMgr().client.quote.createQuote(newsData);
_newsController.clear();
} catch (error) { } catch (error) {
if (mounted) { if (context.mounted) {
ErrorSnackbar().show(context, error.toString()); ErrorSnackbar().show(context, error.toString());
} }
} finally { } finally {

View file

@ -25,6 +25,8 @@ dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
carousel_slider: ^5.1.1
flutter_spinkit: ^5.2.2 flutter_spinkit: ^5.2.2
google_fonts: ^6.3.0 google_fonts: ^6.3.0
@ -69,6 +71,7 @@ flutter:
# To add assets to your application, add an assets section, like this: # To add assets to your application, add an assets section, like this:
assets: assets:
- assets/funny_images/
- assets/render_themes/ - assets/render_themes/
- packages/mapsforge_flutter/assets/patterns/dark_farmland.svg - packages/mapsforge_flutter/assets/patterns/dark_farmland.svg
- packages/mapsforge_flutter/assets/patterns/dark_military.png - packages/mapsforge_flutter/assets/patterns/dark_military.png