feat : EventDetails : Back button + read more option

This commit is contained in:
Yaël Perret
2025-08-30 15:24:43 +02:00
parent 1332fddeeb
commit 264171b42a
8 changed files with 296 additions and 234 deletions

View File

@@ -445,6 +445,12 @@
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "readmore",
"rootUri": "file:///C:/Users/Yael/AppData/Local/Pub/Cache/hosted/pub.dev/readmore-3.0.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "recase",
"rootUri": "file:///C:/Users/Yael/AppData/Local/Pub/Cache/hosted/pub.dev/recase-4.1.0",

View File

@@ -278,6 +278,10 @@ pubspec_parse
3.0
file:///C:/Users/Yael/AppData/Local/Pub/Cache/hosted/pub.dev/pubspec_parse-1.3.0/
file:///C:/Users/Yael/AppData/Local/Pub/Cache/hosted/pub.dev/pubspec_parse-1.3.0/lib/
readmore
3.0
file:///C:/Users/Yael/AppData/Local/Pub/Cache/hosted/pub.dev/readmore-3.0.0/
file:///C:/Users/Yael/AppData/Local/Pub/Cache/hosted/pub.dev/readmore-3.0.0/lib/
recase
2.12
file:///C:/Users/Yael/AppData/Local/Pub/Cache/hosted/pub.dev/recase-4.1.0/

View File

@@ -6686,6 +6686,7 @@ the License, but only in their entirety and only with respect to the Combined
Software.
--------------------------------------------------------------------------------
get
readmore
MIT License

View File

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:readmore/readmore.dart';
class PostCardWidget extends StatefulWidget {
final String title;
@@ -105,9 +106,14 @@ class _PostCardWidgetState extends State<PostCardWidget> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Contenu
Text(
ReadMoreText(
widget.content,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
trimMode: TrimMode.Line,
trimLines: 2,
colorClickableText: Theme.of(context).colorScheme.primary,
trimCollapsedText: 'Voir plus',
trimExpandedText: 'Voir moins',
moreStyle: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Colors.white,
height: 1.4,
),

View File

@@ -14,7 +14,14 @@ class EventDetailsView extends StackedView<EventDetailsViewModel> {
EventDetailsViewModel viewModel,
Widget? child,
) {
return DefaultTabController(
return PopScope(
canPop: true,
onPopInvokedWithResult: (bool didPop, Object? result) {
viewModel.onBackPressed();
},
child: Stack(
children: [
DefaultTabController(
length: 2,
child: Scaffold(
backgroundColor: Colors.white,
@@ -258,6 +265,24 @@ class EventDetailsView extends StackedView<EventDetailsViewModel> {
),
),
),
),
Positioned(
top: 20,
left: 20,
child: Container(
//padding: const EdgeInsets.all(8.0),
decoration: BoxDecoration(
color: Colors.black.withOpacity(0.6),
borderRadius: BorderRadius.circular(20),
),
child: IconButton(
onPressed: viewModel.onBackPressed,
icon: const Icon(Icons.arrow_back, size: 20),
)
),
),
],
),
);
}

View File

@@ -1,6 +1,10 @@
import 'package:bahla_front/app/app.locator.dart';
import 'package:stacked/stacked.dart';
import 'package:stacked_services/stacked_services.dart';
class EventDetailsViewModel extends BaseViewModel {
final _navigationService = locator<NavigationService>();
int _selectedTabIndex = 0;
int get selectedTabIndex => _selectedTabIndex;
@@ -9,6 +13,13 @@ class EventDetailsViewModel extends BaseViewModel {
_selectedTabIndex = index;
notifyListeners();
}
void onBackPressed() {
// Handle back button press logic here
print('Back button pressed');
_navigationService.back();
}
}
class Post {

View File

@@ -581,6 +581,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.0"
readmore:
dependency: "direct main"
description:
name: readmore
sha256: e8fca2bd397b86342483b409e2ec26f06560a5963aceaa39b27f30722b506187
url: "https://pub.dev"
source: hosted
version: "3.0.0"
recase:
dependency: transitive
description:

View File

@@ -15,6 +15,7 @@ dependencies:
google_fonts: ^6.2.1
http: ^1.2.2
intl: any
readmore: ^3.0.0
stacked: ^3.4.0
stacked_services: ^1.1.0