Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Global-Banner message #424

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class PoisFeatureTile extends StatelessWidget {

@override
Widget build(BuildContext context) {
final isLanguageEn = Localizations.localeOf(context).languageCode == 'en';
final subCategoryData = HBLayerData.subCategoriesList[element.category3];
return Container(
margin: const EdgeInsets.symmetric(vertical: 10),
Expand All @@ -39,7 +40,10 @@ class PoisFeatureTile extends StatelessWidget {
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Text(
element.name ?? '',
element.name ??
(isLanguageEn
? (subCategoryData?.en ?? "")
: (subCategoryData?.de ?? "")),
style: const TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
Expand Down
8 changes: 5 additions & 3 deletions lib/base/custom_layers/pbf_layer/pois/poi_marker_modal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class PoiMarkerModal extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final languageCode = Localizations.localeOf(context).languageCode;
final isLanguageEn = Localizations.localeOf(context).languageCode == 'en';
final localizationST = StadtnaviBaseLocalization.of(context);

final subCategoryData = HBLayerData.subCategoriesList[element.category3];
Expand Down Expand Up @@ -67,7 +67,9 @@ class PoiMarkerModal extends StatelessWidget {
),
Expanded(
child: Text(
subCategoryData?.en ?? subCategoryData?.en ?? "",
(isLanguageEn
? (subCategoryData?.en ?? "")
: (subCategoryData?.de ?? "")),
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
Expand Down Expand Up @@ -198,7 +200,7 @@ class PoiMarkerModal extends StatelessWidget {
if (openingHours != null) ...[
const Divider(),
Padding(
padding: const EdgeInsets.symmetric( horizontal: 10),
padding: const EdgeInsets.symmetric(horizontal: 10),
child: OpeningTimeTable(
openingHours: openingHours,
isOpenParking: openingHours.isOpenNow(),
Expand Down
207 changes: 101 additions & 106 deletions lib/base/pages/home/banner_alerts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class _BannerAlertsState extends State<BannerAlerts> {
final getFilteredAlerts = globalAlertsState.getFilteredAlerts;
return getFilteredAlerts.isNotEmpty
? Container(
height:
isExpandable ? MediaQuery.of(context).size.height * 0.4 : 95,
color: ThemeCubit.isDarkMode(theme)
? theme.appBarTheme.backgroundColor
: theme.colorScheme.primary,
Expand All @@ -38,10 +40,7 @@ class _BannerAlertsState extends State<BannerAlerts> {
),
child: Column(
children: [
SizedBox(
height: isExpandable
? MediaQuery.of(context).size.height * 0.3
: 72,
Expanded(
child: PageView.builder(
controller: _pageController,
itemCount: getFilteredAlerts.length,
Expand All @@ -52,113 +51,111 @@ class _BannerAlertsState extends State<BannerAlerts> {
},
itemBuilder: (context, index) {
final alert = getFilteredAlerts[index];
return Expanded(
child: Stack(
children: [
Positioned(
left: 0,
right: 0,
top: 0,
bottom: 0,
child: SingleChildScrollView(
physics: const ClampingScrollPhysics(),
child: Container(
padding: const EdgeInsets.only(
left: 50,
top: 12,
right: 50,
bottom: 0,
),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
alert.alertHeaderText ?? "",
return Stack(
fit: StackFit.expand,
children: [
Positioned(
left: 0,
right: 0,
top: 0,
bottom: 0,
child: SingleChildScrollView(
physics: const ClampingScrollPhysics(),
child: Container(
padding: const EdgeInsets.only(
left: 50,
top: 12,
right: 50,
bottom: 0,
),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
alert.alertHeaderText ?? "",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 13,
height: 1,
overflow: isExpandable
? null
: TextOverflow.ellipsis,
),
maxLines: isExpandable ? null : 2,
),
const SizedBox(height: 8),
RichText(
maxLines: isExpandable ? null : 2,
text: TextSpan(
text: alert.alertDescriptionText,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 13,
height: 1,
fontSize: 13,
overflow: isExpandable
? null
: TextOverflow.ellipsis,
color: Colors.black,
),
maxLines: isExpandable ? null : 2,
),
const SizedBox(height: 8),
RichText(
maxLines: isExpandable ? null : 2,
text: TextSpan(
text: alert.alertDescriptionText,
style: TextStyle(
height: 1,
fontSize: 13,
overflow: isExpandable
? null
: TextOverflow.ellipsis,
color: Colors.black,
),
children: [
if (alert.alertUrl != null)
TextSpan(
text: localization
.commonMoreInfo,
style: const TextStyle(
fontSize: 13,
fontWeight: FontWeight.bold,
height: 1,
decoration: TextDecoration
.underline,
),
recognizer:
TapGestureRecognizer()
..onTap = () async {
Uri uri = Uri.parse(
alert.alertUrl ??
'');
if (await canLaunchUrl(
uri)) {
await launchUrl(
uri);
}
},
children: [
if (alert.alertUrl != null)
TextSpan(
text:
localization.commonMoreInfo,
style: const TextStyle(
fontSize: 13,
fontWeight: FontWeight.bold,
height: 1,
decoration:
TextDecoration.underline,
),
],
),
recognizer:
TapGestureRecognizer()
..onTap = () async {
Uri uri = Uri.parse(
alert.alertUrl ??
'');
if (await canLaunchUrl(
uri)) {
await launchUrl(uri);
}
},
),
],
),
],
),
),
],
),
),
),
Positioned(
left: 12,
top: 12,
child: SizedBox(
height: 24,
width: 24,
child: FittedBox(
child: cautionSvg(
color: Colors.white,
backColor: const Color(0xFFDC0451)),
),
),
Positioned(
left: 12,
top: 12,
child: SizedBox(
height: 24,
width: 24,
child: FittedBox(
child: cautionSvg(
color: Colors.white,
backColor: const Color(0xFFDC0451)),
),
),
Positioned(
right: 0,
top: 0,
child: IconButton(
icon: const Icon(
Icons.close,
color: Color(0xFFDC0451),
),
onPressed: () {
globalAlertsCubit.deleteAlert(alert);
},
),
Positioned(
right: 0,
top: 0,
child: IconButton(
icon: const Icon(
Icons.close,
color: Color(0xFFDC0451),
),
onPressed: () {
globalAlertsCubit.deleteAlert(alert);
},
),
],
),
),
],
);
},
),
Expand Down Expand Up @@ -192,10 +189,9 @@ class _BannerAlertsState extends State<BannerAlerts> {
constraints: const BoxConstraints(),
icon: Icon(
Icons.arrow_back_ios,
color:
_currentIndex != 0
? const Color(0xFFDC0451)
: Colors.grey,
color: _currentIndex != 0
? const Color(0xFFDC0451)
: Colors.grey,
size: 18,
),
),
Expand Down Expand Up @@ -237,7 +233,7 @@ class _BannerAlertsState extends State<BannerAlerts> {
),
IconButton(
onPressed: _currentIndex <
getFilteredAlerts.length-1
getFilteredAlerts.length - 1
? () {
_pageController.nextPage(
duration:
Expand All @@ -248,11 +244,10 @@ class _BannerAlertsState extends State<BannerAlerts> {
: null,
icon: Icon(
Icons.arrow_forward_ios,
color:
_currentIndex <
getFilteredAlerts.length-1
? const Color(0xFFDC0451)
: Colors.grey,
color: _currentIndex <
getFilteredAlerts.length - 1
? const Color(0xFFDC0451)
: Colors.grey,
size: 20,
),
padding: EdgeInsets.zero,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class GlobalAlertsCubit extends Cubit<GlobalAlertsState> {
tempAlerts.remove(alert);
final newState = state.copyWith(
alerts: tempAlerts,
removedAlertIds: [...state.removedAlertIds, alert.id],
removedAlertIds: [...state.removedAlertIds, alert.getServiceAlertId],
);
await updateGlobalAlertsState(newState);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class GlobalAlertsState extends Equatable {
}

List<GlobalAlertEntity> get getFilteredAlerts =>
alerts.where((e) => !removedAlertIds.contains(e.id)).toList();
alerts.where((e) => !removedAlertIds.contains(e.getServiceAlertId)).toList();

Map<String, dynamic> toJson() {
return {
Expand Down
7 changes: 6 additions & 1 deletion lib/base/pages/home/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,12 @@ class _HomePageState extends State<HomePage>
),
body: Column(
children: [
const BannerAlerts(),
Column(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(child: const BannerAlerts()),
],
),
HomeAppBar(
onSaveFrom: (TrufiLocation fromPlace) =>
mapRouteCubit.setFromPlace(fromPlace).then(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'package:equatable/equatable.dart';
import 'package:crypto/crypto.dart';
import 'dart:convert';
import 'package:stadtnavi_core/base/custom_layers/services/models_otp/enums/alert_cause_type.dart';
import 'package:stadtnavi_core/base/custom_layers/services/models_otp/enums/alert_effect_type.dart';
import 'package:stadtnavi_core/base/custom_layers/services/models_otp/enums/alert_severity_level_type.dart';
Expand Down Expand Up @@ -59,20 +61,30 @@ class GlobalAlertEntity extends Equatable {

Map<String, dynamic> toJson() {
return {
'alertCause': alertCause,
'alertCause': alertCause?.name,
'alertDescriptionText': alertDescriptionText,
'alertEffect': alertEffect,
'alertEffect': alertEffect?.name,
'alertHash': alertHash,
'alertHeaderText': alertHeaderText,
'alertSeverityLevel': alertSeverityLevel,
'alertSeverityLevel': alertSeverityLevel?.name,
'alertUrl': alertUrl,
'effectiveEndDate': effectiveEndDate,
'effectiveStartDate': effectiveStartDate,
'effectiveEndDate': effectiveEndDate != null
? effectiveEndDate!.millisecondsSinceEpoch ~/ 1000
: null,
'effectiveStartDate': effectiveStartDate != null
? effectiveStartDate!.millisecondsSinceEpoch ~/ 1000
: null,
'feed': feed,
'id': id,
};
}

String get getServiceAlertId {
final combinedString =
'$alertDescriptionText$alertHeaderText$alertSeverityLevel$effectiveEndDate$effectiveStartDate$feed';
return sha256.convert(utf8.encode(combinedString)).toString();
}

@override
List<Object?> get props => [alertHash];
}
Loading