-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(planner-advert): setup presentation layer
- Loading branch information
1 parent
27dbab4
commit 7ddf5cc
Showing
5 changed files
with
71 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
lib/features/planner_advert/widgets/planner_advert_widget.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import "dart:async"; | ||
|
||
import "package:flutter/material.dart"; | ||
import "package:flutter_riverpod/flutter_riverpod.dart"; | ||
|
||
import "../../../config/ui_config.dart"; | ||
import "../../../theme/app_theme.dart"; | ||
import "../../../utils/launch_url_util.dart"; | ||
import "../../../widgets/loading_widgets/simple_previews/horizontal_rectangular_section_loading.dart"; | ||
import "../../../widgets/my_error_widget.dart"; | ||
import "../../../widgets/technical_message.dart"; | ||
import "../repository/planner_advert_repository.dart"; | ||
|
||
class PlannerAdvertBanner extends ConsumerWidget { | ||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final state = ref.watch(plannerAdvertContentRepositoryProvider); | ||
return switch (state) { | ||
AsyncError(:final error) => MyErrorWidget(error), | ||
AsyncValue(:final PlannerAdvertContent value) => | ||
_PlannerAdvertBanner(value), | ||
_ => const HorizontalRectangularSectionLoading() | ||
}; | ||
} | ||
} | ||
|
||
class _PlannerAdvertBanner extends ConsumerWidget { | ||
const _PlannerAdvertBanner( | ||
this.data, | ||
); | ||
|
||
final PlannerAdvertContent data; | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
return data.isEnabled | ||
? Padding( | ||
padding: const EdgeInsets.symmetric( | ||
horizontal: HomeViewConfig.paddingSmall, | ||
), | ||
child: TechnicalMessage( | ||
title: data.title, | ||
message: data.description, | ||
alertType: AlertType.info, | ||
icon: Icon( | ||
Icons.open_in_new_rounded, | ||
color: context.colorTheme.whiteSoap, | ||
), | ||
onTap: () async { | ||
unawaited(ref.launch(data.url)); | ||
}, | ||
), | ||
) | ||
: const SizedBox.shrink(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters