feat : New listing + MainView
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:bahla_front/ui/views/startup/startup_view.dart';
|
||||
import 'package:stacked/stacked_annotations.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
import 'package:bahla_front/ui/views/main/main_view.dart';
|
||||
import 'package:bahla_front/ui/views/home/home_view.dart';
|
||||
// @stacked-import
|
||||
|
||||
@StackedApp(
|
||||
@@ -12,6 +13,7 @@ import 'package:bahla_front/ui/views/main/main_view.dart';
|
||||
MaterialRoute(page: HomeView),
|
||||
MaterialRoute(page: StartupView),
|
||||
MaterialRoute(page: MainView),
|
||||
MaterialRoute(page: HomeView),
|
||||
// @stacked-route
|
||||
],
|
||||
dependencies: [
|
||||
|
||||
@@ -14,12 +14,13 @@ import 'package:stacked/stacked.dart' as _i1;
|
||||
import 'package:stacked_services/stacked_services.dart' as _i6;
|
||||
|
||||
class Routes {
|
||||
static const homeView = '/home-view';
|
||||
|
||||
static const startupView = '/startup-view';
|
||||
|
||||
static const mainView = '/main-view';
|
||||
|
||||
static const homeView = '/home-view';
|
||||
|
||||
static const all = <String>{
|
||||
homeView,
|
||||
startupView,
|
||||
@@ -41,6 +42,10 @@ class StackedRouter extends _i1.RouterBase {
|
||||
Routes.mainView,
|
||||
page: _i4.MainView,
|
||||
),
|
||||
_i1.RouteDef(
|
||||
Routes.homeView,
|
||||
page: _i2.HomeView,
|
||||
),
|
||||
];
|
||||
|
||||
final _pagesMap = <Type, _i1.StackedRouteFactory>{
|
||||
@@ -79,7 +84,7 @@ extension NavigatorStateExtension on _i6.NavigationService {
|
||||
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
|
||||
transition,
|
||||
]) async {
|
||||
return navigateTo<dynamic>(Routes.mainView, // Replace home view to main view
|
||||
return navigateTo<dynamic>(Routes.homeView,
|
||||
id: routerId,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
@@ -121,7 +126,7 @@ extension NavigatorStateExtension on _i6.NavigationService {
|
||||
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
|
||||
transition,
|
||||
]) async {
|
||||
return replaceWith<dynamic>(Routes.mainView, // Replace home view to main view
|
||||
return replaceWith<dynamic>(Routes.homeView,
|
||||
id: routerId,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
|
||||
122
lib/main.dart
122
lib/main.dart
@@ -5,6 +5,7 @@ import 'package:bahla_front/app/app.locator.dart';
|
||||
import 'package:bahla_front/app/app.router.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
@@ -27,79 +28,56 @@ class MainApp extends StatelessWidget {
|
||||
StackedService.routeObserver,
|
||||
],
|
||||
theme: ThemeData(
|
||||
useMaterial3: true,
|
||||
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
seedColor: Colors.blueAccent,
|
||||
brightness: Brightness.dark,
|
||||
primary: const Color.fromARGB(255, 64, 175, 255),
|
||||
secondary: const Color.fromARGB(255, 255, 139, 6),
|
||||
background: const Color.fromARGB(255, 15, 14, 23),
|
||||
),
|
||||
|
||||
textTheme: TextTheme(
|
||||
displayLarge: GoogleFonts.firaSans(
|
||||
fontSize: 96,
|
||||
fontWeight: FontWeight.normal
|
||||
useMaterial3: true,
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
seedColor: Colors.blueAccent,
|
||||
brightness: Brightness.dark,
|
||||
primary: const Color.fromARGB(255, 64, 175, 255),
|
||||
secondary: const Color.fromARGB(255, 255, 139, 6),
|
||||
background: const Color.fromARGB(255, 15, 14, 23),
|
||||
),
|
||||
displayMedium: GoogleFonts.firaSans(
|
||||
fontSize: 60,
|
||||
fontWeight: FontWeight.normal
|
||||
),
|
||||
displaySmall: GoogleFonts.firaSans(
|
||||
fontSize: 48,
|
||||
fontWeight: FontWeight.normal
|
||||
),
|
||||
headlineLarge: GoogleFonts.firaSans(
|
||||
fontSize: 40,
|
||||
fontWeight: FontWeight.normal
|
||||
),
|
||||
headlineMedium: GoogleFonts.firaSans(
|
||||
fontSize: 34,
|
||||
fontWeight: FontWeight.normal
|
||||
),
|
||||
headlineSmall: GoogleFonts.firaSans(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.normal
|
||||
),
|
||||
titleLarge: GoogleFonts.firaSans(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.normal
|
||||
),
|
||||
titleMedium: GoogleFonts.firaSans(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.normal
|
||||
),
|
||||
titleSmall: GoogleFonts.firaSans(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.normal
|
||||
),
|
||||
bodyLarge: GoogleFonts.firaSans(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.normal
|
||||
),
|
||||
bodyMedium: GoogleFonts.firaSans(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.normal
|
||||
),
|
||||
bodySmall: GoogleFonts.firaSans(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.normal
|
||||
),
|
||||
labelLarge: GoogleFonts.firaSans(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.normal
|
||||
),
|
||||
labelMedium: GoogleFonts.firaSans(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.normal
|
||||
),
|
||||
labelSmall: GoogleFonts.firaSans(
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.normal
|
||||
),
|
||||
)
|
||||
),
|
||||
textTheme: TextTheme(
|
||||
displayLarge: GoogleFonts.firaSans(
|
||||
fontSize: 96, fontWeight: FontWeight.normal),
|
||||
displayMedium: GoogleFonts.firaSans(
|
||||
fontSize: 60, fontWeight: FontWeight.normal),
|
||||
displaySmall: GoogleFonts.firaSans(
|
||||
fontSize: 48, fontWeight: FontWeight.normal),
|
||||
headlineLarge: GoogleFonts.firaSans(
|
||||
fontSize: 40, fontWeight: FontWeight.normal),
|
||||
headlineMedium: GoogleFonts.firaSans(
|
||||
fontSize: 34, fontWeight: FontWeight.normal),
|
||||
headlineSmall: GoogleFonts.firaSans(
|
||||
fontSize: 24, fontWeight: FontWeight.normal),
|
||||
titleLarge: GoogleFonts.firaSans(
|
||||
fontSize: 20, fontWeight: FontWeight.normal),
|
||||
titleMedium: GoogleFonts.firaSans(
|
||||
fontSize: 16, fontWeight: FontWeight.normal),
|
||||
titleSmall: GoogleFonts.firaSans(
|
||||
fontSize: 14, fontWeight: FontWeight.normal),
|
||||
bodyLarge: GoogleFonts.firaSans(
|
||||
fontSize: 20, fontWeight: FontWeight.normal),
|
||||
bodyMedium: GoogleFonts.firaSans(
|
||||
fontSize: 16, fontWeight: FontWeight.normal),
|
||||
bodySmall: GoogleFonts.firaSans(
|
||||
fontSize: 14, fontWeight: FontWeight.normal),
|
||||
labelLarge: GoogleFonts.firaSans(
|
||||
fontSize: 14, fontWeight: FontWeight.normal),
|
||||
labelMedium: GoogleFonts.firaSans(
|
||||
fontSize: 12, fontWeight: FontWeight.normal),
|
||||
labelSmall: GoogleFonts.firaSans(
|
||||
fontSize: 10, fontWeight: FontWeight.normal),
|
||||
)),
|
||||
localizationsDelegates: const [
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: const [
|
||||
Locale('en'),
|
||||
Locale('fr'),
|
||||
Locale('ch'),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@ class Images {
|
||||
|
||||
static const String logoSvg = 'assets/images/logo.svg';
|
||||
static const String ExempleAffiche = 'assets/images/Affiche.jpg';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import 'package:bahla_front/ui/common/images.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:bahla_front/ui/common/app_colors.dart';
|
||||
import 'package:bahla_front/ui/common/ui_helpers.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'home_viewmodel.dart';
|
||||
|
||||
class HomeView extends StackedView<HomeViewModel> {
|
||||
const HomeView({Key? key}) : super(key: key);
|
||||
|
||||
|
||||
@override
|
||||
Widget builder(
|
||||
@@ -16,42 +15,113 @@ class HomeView extends StackedView<HomeViewModel> {
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 25.0),
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Image(
|
||||
image: AssetImage(Images.ExempleAffiche),
|
||||
height: 200,
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
Container(
|
||||
child: Text(
|
||||
"Disc'Octonelle 2",
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
backgroundColor: Theme.of(context).colorScheme.background,
|
||||
body: ListView.builder(
|
||||
itemCount: viewModel.events.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child:
|
||||
IntrinsicHeight(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(right: 16),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(8),
|
||||
bottomLeft: Radius.circular(8),
|
||||
),
|
||||
image: DecorationImage(
|
||||
image: AssetImage(viewModel.events[index].picture),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child:
|
||||
Container(
|
||||
margin: const EdgeInsets.all(8),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
viewModel.events[index].date != null
|
||||
? DateFormat.yMMMMd(Localizations.localeOf(context).toString())
|
||||
.format(viewModel.events[index].date!)
|
||||
: 'No date',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
Text(
|
||||
viewModel.events[index].name,
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.favorite_border),
|
||||
onPressed: () {
|
||||
// Handle more options
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
viewModel.events[index].organizer,
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
),
|
||||
Text(
|
||||
viewModel.events[index].place ?? 'No place',
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.place),
|
||||
onPressed: () {
|
||||
// Handle favorite action
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -1,36 +1,51 @@
|
||||
import 'package:bahla_front/app/app.bottomsheets.dart';
|
||||
import 'package:bahla_front/app/app.dialogs.dart';
|
||||
import 'package:bahla_front/app/app.locator.dart';
|
||||
import 'package:bahla_front/ui/common/app_strings.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
|
||||
class HomeViewModel extends BaseViewModel {
|
||||
final _dialogService = locator<DialogService>();
|
||||
final _bottomSheetService = locator<BottomSheetService>();
|
||||
|
||||
String get counterLabel => 'Counter is: $_counter';
|
||||
List<String> items = List<String>.generate(100, (i) => 'Item $i');
|
||||
|
||||
int _counter = 0;
|
||||
List<Event> events = [
|
||||
Event(
|
||||
name: 'Event 1',
|
||||
picture: 'images/Affiche.jpg',
|
||||
date: DateTime.now().add(Duration(days: 1)),
|
||||
organizer: 'Organizer 1',
|
||||
place: 'Place 1',
|
||||
),
|
||||
Event(
|
||||
name: 'Event 2',
|
||||
picture: 'images/Affiche.jpg',
|
||||
date: DateTime.now().add(Duration(days: 1)),
|
||||
organizer: 'Organizer 2',
|
||||
),
|
||||
Event(
|
||||
name: 'Event 3',
|
||||
picture: 'images/Affiche.jpg',
|
||||
date: DateTime.now().add(Duration(days: 1)),
|
||||
organizer: 'Organizer 3',
|
||||
place: 'Place 3',
|
||||
),
|
||||
];
|
||||
|
||||
void incrementCounter() {
|
||||
_counter++;
|
||||
rebuildUi();
|
||||
}
|
||||
|
||||
void showDialog() {
|
||||
_dialogService.showCustomDialog(
|
||||
variant: DialogType.infoAlert,
|
||||
title: 'Stacked Rocks!',
|
||||
description: 'Give stacked $_counter stars on Github',
|
||||
);
|
||||
}
|
||||
|
||||
void showBottomSheet() {
|
||||
_bottomSheetService.showCustomSheet(
|
||||
variant: BottomSheetType.notice,
|
||||
title: ksHomeBottomSheetTitle,
|
||||
description: ksHomeBottomSheetDescription,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Event {
|
||||
String name;
|
||||
String picture;
|
||||
String organizer = 'Organizer';
|
||||
String? place;
|
||||
DateTime? date;
|
||||
|
||||
Event({
|
||||
required this.name,
|
||||
required this.picture,
|
||||
required this.organizer,
|
||||
this.date,
|
||||
this.place,
|
||||
});
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Event{name: $name, picture: $picture}';
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,6 @@ class MainView extends StackedView<MainViewModel> {
|
||||
width: 0.2,
|
||||
),
|
||||
),
|
||||
|
||||
),
|
||||
backgroundColor: Theme.of(context).colorScheme.background,
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
@@ -52,7 +51,6 @@ class MainView extends StackedView<MainViewModel> {
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.home),
|
||||
label: 'Home',
|
||||
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.search),
|
||||
|
||||
@@ -13,6 +13,7 @@ class StartupViewModel extends BaseViewModel {
|
||||
// This is where you can make decisions on where your app should navigate when
|
||||
// you have custom startup logic
|
||||
|
||||
_navigationService.replaceWithHomeView();
|
||||
//_navigationService.replaceWithHomeView();
|
||||
_navigationService.replaceWithMainView();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user