Skip to content
Merged
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
19 changes: 13 additions & 6 deletions lib/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ final routesProvider = Provider<GoRouter>(
onAddPlacePressed: () => context.go('/places/add'),
onPlacePressed: (placeSubscriptionId) =>
context.go('/places/$placeSubscriptionId'),
onAlertPressed: (String alertId) => context.go('/alerts/$alertId'),
onAlertPressed: (String alertId, String subscriptionId) =>
context.go('/alerts/$alertId/$subscriptionId'),
onAlertUpdateThreadPressed: () => context.go('/alerts/update'),
onSettingsPressed: () => context.go('/settings'),
onAboutPressed: () => context.go('/about'),
Expand Down Expand Up @@ -105,8 +106,8 @@ final routesProvider = Provider<GoRouter>(
String placeSubscriptionId = state.pathParameters["id"]!;
return MyPlaceDetailScreen(
placeSubscriptionId: placeSubscriptionId,
onAlertPressed: (String alertId) =>
context.push('/alerts/$alertId'),
onAlertPressed: (String alertId, String subscriptionId) =>
context.push('/alerts/$alertId/$subscriptionId'),
onAlertUpdateThreadPressed: () =>
context.push('/alerts/update/'),
);
Expand All @@ -119,16 +120,22 @@ final routesProvider = Provider<GoRouter>(
redirect: (context, state) => null,
routes: [
GoRoute(
path: ':id',
path: ':id/:subscriptionId',
builder: (context, state) {
String id = state.pathParameters["id"]!;
return DetailScreen(warningIdentifier: id);
String subscriptionId =
state.pathParameters["subscriptionId"]!;
return DetailScreen(
warningIdentifier: id,
subscriptionId: subscriptionId,
);
},
),
GoRoute(
path: 'update',
builder: (context, state) => AlertUpdateThreadView(
onAlertPressed: (alertId) => context.go('/alerts/$alertId'),
onAlertPressed: (alertId, subscriptionId) =>
context.go('/alerts/$alertId/$subscriptionId'),
onAlertUpdateThreadPressed: () =>
context.go('/alerts/update'),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/views/alert_update_thread_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class AlertUpdateThreadView extends ConsumerStatefulWidget {
super.key,
});

final void Function(String alertId) onAlertPressed;
final void Function(String alertId, String subscriptionId) onAlertPressed;
final void Function() onAlertUpdateThreadPressed;

@override
Expand Down
2 changes: 1 addition & 1 deletion lib/views/home/home_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class HomeView extends ConsumerStatefulWidget {

final VoidCallback onAddPlacePressed;
final void Function(String placeSubscriptionId) onPlacePressed;
final void Function(String alertId) onAlertPressed;
final void Function(String alertId, String subcriptionId) onAlertPressed;
final VoidCallback onAlertUpdateThreadPressed;
final VoidCallback onSettingsPressed;
final VoidCallback onAboutPressed;
Expand Down
2 changes: 1 addition & 1 deletion lib/views/my_place_detail_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class MyPlaceDetailScreen extends ConsumerWidget {
});

final String placeSubscriptionId;
final void Function(String alertId) onAlertPressed;
final void Function(String alertId, String subscriptionId) onAlertPressed;
final void Function() onAlertUpdateThreadPressed;

@override
Expand Down
6 changes: 5 additions & 1 deletion lib/views/warning_detail_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,11 @@ List<Widget> _generateAssets(String text, {required BuildContext context}) {

class DetailScreen extends ConsumerStatefulWidget {
final String warningIdentifier;
final String subscriptionId;

const DetailScreen({
required this.warningIdentifier,
required this.subscriptionId,
super.key,
});

Expand All @@ -235,7 +237,9 @@ class _DetailScreenState extends ConsumerState<DetailScreen> {

WidgetsBinding.instance.addPostFrameCallback((_) async {
var warning = ref.read(alertsProvider).firstWhere(
(alert) => alert.identifier == widget.warningIdentifier,
(alert) =>
alert.identifier == widget.warningIdentifier &&
alert.placeSubscriptionId == widget.subscriptionId,
);

// update the read state of the alert
Expand Down
2 changes: 1 addition & 1 deletion lib/views/warnings_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class WarningsView extends ConsumerWidget {
super.key,
});

final void Function(String alertId) onAlertPressed;
final void Function(String alertId, String subscriptionId) onAlertPressed;
final VoidCallback onAlertUpdateThreadPressed;

@override
Expand Down
12 changes: 9 additions & 3 deletions lib/widgets/warning_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class WarningWidget extends ConsumerWidget {
_updateThread = updateThread,
_isMyPlaceWarning = isMyPlaceWarning;

final void Function(String id) onAlertPressed;
final void Function(String id, String subscriptionId) onAlertPressed;
final void Function() onAlertUpdateThreadPressed;
final List<WarnMessage>? _updateThread;
final WarnMessage _warnMessage;
Expand Down Expand Up @@ -87,7 +87,10 @@ class WarningWidget extends ConsumerWidget {

return Card(
child: InkWell(
onTap: () => onAlertPressed(_warnMessage.identifier),
onTap: () => onAlertPressed(
_warnMessage.identifier,
_warnMessage.placeSubscriptionId,
),
child: Padding(
padding: const EdgeInsets.all(12),
child: Row(
Expand Down Expand Up @@ -188,7 +191,10 @@ class WarningWidget extends ConsumerWidget {
Column(
children: [
IconButton(
onPressed: () => onAlertPressed(_warnMessage.identifier),
onPressed: () => onAlertPressed(
_warnMessage.identifier,
_warnMessage.placeSubscriptionId,
),
icon: const Icon(Icons.read_more),
),
(_updateThread != null && _updateThread.length > 1)
Expand Down