migrated Marianum Message module to the Marianum-Connect API and implemented push notification deep linking
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import '../../../state/app/modules/marianum_message/bloc/marianum_message_state.dart';
|
||||
|
||||
/// Demo fixtures for the info messages — a single friendly welcome entry so the
|
||||
@@ -6,16 +8,16 @@ class DemoMarianumMessage {
|
||||
const DemoMarianumMessage._();
|
||||
|
||||
static MarianumMessageList list() {
|
||||
final today = DateTime.now();
|
||||
final date =
|
||||
'${today.day.toString().padLeft(2, '0')}.${today.month.toString().padLeft(2, '0')}.${today.year}';
|
||||
final date = DateFormat.yMMMM('de').format(DateTime.now());
|
||||
|
||||
return MarianumMessageList(
|
||||
base: 'https://marianum-fulda.de',
|
||||
messages: [
|
||||
MarianumMessage(
|
||||
id: 'demo',
|
||||
name: 'Willkommen in der Marianum-App',
|
||||
date: date,
|
||||
description: 'Eine kurze Begrüßung zum Ausprobieren.',
|
||||
url: 'https://marianum-fulda.de',
|
||||
),
|
||||
],
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import '../../errors/marianumconnect_error.dart';
|
||||
import '../../marianumconnect_api.dart';
|
||||
import '../../marianumconnect_endpoint.dart';
|
||||
|
||||
/// Downloads the raw PDF bytes of a Marianum Message from
|
||||
/// `GET /api/mobile/v1/newsletter/{id}/file`.
|
||||
///
|
||||
/// Goes through the shared MC dio so the bearer token is attached automatically;
|
||||
/// the bytes are handed to `SfPdfViewer.memory` so no auth header has to be
|
||||
/// plumbed into the viewer itself.
|
||||
class GetNewsletterFile {
|
||||
final String id;
|
||||
final Dio _dio;
|
||||
|
||||
GetNewsletterFile(this.id, {Dio? dio}) : _dio = dio ?? MarianumConnectApi.dio();
|
||||
|
||||
Future<Uint8List> run() async {
|
||||
try {
|
||||
final response = await _dio.get<List<int>>(
|
||||
MarianumConnectEndpoint.resolve(
|
||||
'newsletter/${Uri.encodeComponent(id)}/file',
|
||||
),
|
||||
options: Options(responseType: ResponseType.bytes),
|
||||
);
|
||||
return Uint8List.fromList(response.data!);
|
||||
} on DioException catch (e) {
|
||||
throw mapMarianumConnectError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user