fix: add authorization header and web image fetch method for activity suggestion cards (#3839)
* add authorization header and web image fetch method for all activity images * formatting --------- Co-authored-by: ggurdin <ggurdin@gmail.com> Co-authored-by: ggurdin <46800240+ggurdin@users.noreply.github.com>
This commit is contained in:
parent
ad78f3fedd
commit
58e6aa3298
5 changed files with 69 additions and 20 deletions
|
|
@ -1,6 +1,9 @@
|
|||
// ignore_for_file: depend_on_referenced_packages
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:cached_network_image_platform_interface/cached_network_image_platform_interface.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:material_symbols_icons/symbols.dart';
|
||||
|
||||
|
|
@ -13,6 +16,7 @@ import 'package:fluffychat/pangea/learning_settings/enums/language_level_type_en
|
|||
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
|
||||
import 'package:fluffychat/widgets/avatar.dart';
|
||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:fluffychat/widgets/mxc_image.dart';
|
||||
|
||||
class ActivityPlanCard extends StatelessWidget {
|
||||
|
|
@ -95,6 +99,12 @@ class ActivityPlanCard extends StatelessWidget {
|
|||
? CachedNetworkImage(
|
||||
fit: BoxFit.cover,
|
||||
imageUrl: controller.imageURL!,
|
||||
imageRenderMethodForWeb:
|
||||
ImageRenderMethodForWeb.HttpGet,
|
||||
httpHeaders: {
|
||||
'Authorization':
|
||||
'Bearer ${MatrixState.pangeaController.userController.accessToken}',
|
||||
},
|
||||
placeholder: (context, url) {
|
||||
return const Center(
|
||||
child:
|
||||
|
|
@ -186,8 +196,15 @@ class ActivityPlanCard extends StatelessWidget {
|
|||
fit: BoxFit.cover,
|
||||
)
|
||||
: CachedNetworkImage(
|
||||
imageRenderMethodForWeb:
|
||||
ImageRenderMethodForWeb
|
||||
.HttpGet,
|
||||
imageUrl: controller
|
||||
.updatedActivity.imageURL!,
|
||||
httpHeaders: {
|
||||
'Authorization':
|
||||
'Bearer ${MatrixState.pangeaController.userController.accessToken}',
|
||||
},
|
||||
fit: BoxFit.cover,
|
||||
width: 24.0,
|
||||
height: 24.0,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
// ignore_for_file: depend_on_referenced_packages
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:cached_network_image_platform_interface/cached_network_image_platform_interface.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/activity_planner/activity_plan_model.dart';
|
||||
import 'package:fluffychat/pangea/activity_planner/activity_planner_builder.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:fluffychat/widgets/mxc_image.dart';
|
||||
|
||||
class ActivitySuggestionCard extends StatelessWidget {
|
||||
|
|
@ -63,6 +67,12 @@ class ActivitySuggestionCard extends StatelessWidget {
|
|||
)
|
||||
: CachedNetworkImage(
|
||||
imageUrl: activity.imageURL!,
|
||||
imageRenderMethodForWeb:
|
||||
ImageRenderMethodForWeb.HttpGet,
|
||||
httpHeaders: {
|
||||
'Authorization':
|
||||
'Bearer ${MatrixState.pangeaController.userController.accessToken}',
|
||||
},
|
||||
placeholder: (context, url) => const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
// ignore_for_file: depend_on_referenced_packages
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:cached_network_image_platform_interface/cached_network_image_platform_interface.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:material_symbols_icons/symbols.dart';
|
||||
|
||||
|
|
@ -12,6 +15,7 @@ import 'package:fluffychat/pangea/chat_settings/widgets/language_level_dropdown.
|
|||
import 'package:fluffychat/pangea/learning_settings/enums/language_level_type_enum.dart';
|
||||
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
|
||||
import 'package:fluffychat/widgets/avatar.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:fluffychat/widgets/mxc_image.dart';
|
||||
|
||||
class ActivitySuggestionDialogContent extends StatelessWidget {
|
||||
|
|
@ -68,6 +72,12 @@ class _ActivitySuggestionDialogImage extends StatelessWidget {
|
|||
fit: BoxFit.cover,
|
||||
)
|
||||
: CachedNetworkImage(
|
||||
imageRenderMethodForWeb:
|
||||
ImageRenderMethodForWeb.HttpGet,
|
||||
httpHeaders: {
|
||||
'Authorization':
|
||||
'Bearer ${MatrixState.pangeaController.userController.accessToken}',
|
||||
},
|
||||
imageUrl: activityController.updatedActivity.imageURL!,
|
||||
fit: BoxFit.cover,
|
||||
placeholder: (
|
||||
|
|
@ -628,6 +638,12 @@ class _ActivitySuggestionLaunchContent extends StatelessWidget {
|
|||
fit: BoxFit.cover,
|
||||
)
|
||||
: CachedNetworkImage(
|
||||
imageRenderMethodForWeb:
|
||||
ImageRenderMethodForWeb.HttpGet,
|
||||
httpHeaders: {
|
||||
'Authorization':
|
||||
'Bearer ${MatrixState.pangeaController.userController.accessToken}',
|
||||
},
|
||||
imageUrl: activityController.updatedActivity.imageURL!,
|
||||
fit: BoxFit.cover,
|
||||
width: 24.0,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import 'package:get_storage/get_storage.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/common/config/environment.dart';
|
||||
import 'package:fluffychat/pangea/course_plans/course_plan_model.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/enums/language_level_type_enum.dart';
|
||||
|
|
@ -10,7 +12,6 @@ import 'package:fluffychat/pangea/payload_client/models/course_plan/cms_course_p
|
|||
import 'package:fluffychat/pangea/payload_client/models/course_plan/cms_course_plan_topic_location.dart';
|
||||
import 'package:fluffychat/pangea/payload_client/payload_client.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
|
||||
class CourseFilter {
|
||||
final LanguageModel? targetLanguage;
|
||||
|
|
@ -195,25 +196,19 @@ class CoursePlansRepo {
|
|||
static Future<CoursePlanModel> _fromCmsCoursePlan(
|
||||
CmsCoursePlan cmsCoursePlan,
|
||||
) async {
|
||||
try {
|
||||
final medias = await _getMedia(cmsCoursePlan);
|
||||
final topics = await _getTopics(cmsCoursePlan);
|
||||
final locations = await _getTopicLocations(topics ?? []);
|
||||
final activities = await _getTopicActivities(topics ?? []);
|
||||
final activityMedias = await _getActivityMedia(activities ?? []);
|
||||
return CoursePlanModel.fromCmsDocs(
|
||||
cmsCoursePlan,
|
||||
medias,
|
||||
topics,
|
||||
locations,
|
||||
activities,
|
||||
activityMedias,
|
||||
);
|
||||
} catch (e, stack) {
|
||||
print(e);
|
||||
print(stack);
|
||||
rethrow;
|
||||
}
|
||||
final medias = await _getMedia(cmsCoursePlan);
|
||||
final topics = await _getTopics(cmsCoursePlan);
|
||||
final locations = await _getTopicLocations(topics ?? []);
|
||||
final activities = await _getTopicActivities(topics ?? []);
|
||||
final activityMedias = await _getActivityMedia(activities ?? []);
|
||||
return CoursePlanModel.fromCmsDocs(
|
||||
cmsCoursePlan,
|
||||
medias,
|
||||
topics,
|
||||
locations,
|
||||
activities,
|
||||
activityMedias,
|
||||
);
|
||||
}
|
||||
|
||||
static Future<List<CmsCoursePlanMedia>?> _getMedia(
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
// ignore_for_file: depend_on_referenced_packages
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:cached_network_image_platform_interface/cached_network_image_platform_interface.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
|
|
@ -15,6 +18,7 @@ import 'package:fluffychat/pangea/course_plans/course_plan_builder.dart';
|
|||
import 'package:fluffychat/pangea/course_plans/course_plan_room_extension.dart';
|
||||
import 'package:fluffychat/pangea/course_settings/pin_clipper.dart';
|
||||
import 'package:fluffychat/pangea/course_settings/topic_participant_list.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
|
||||
class CourseSettings extends StatelessWidget {
|
||||
final Room room;
|
||||
|
|
@ -89,6 +93,13 @@ class CourseSettings extends StatelessWidget {
|
|||
clipper: PinClipper(),
|
||||
child: topic.imageUrl != null
|
||||
? CachedNetworkImage(
|
||||
imageRenderMethodForWeb:
|
||||
ImageRenderMethodForWeb
|
||||
.HttpGet,
|
||||
httpHeaders: {
|
||||
'Authorization':
|
||||
'Bearer ${MatrixState.pangeaController.userController.accessToken}',
|
||||
},
|
||||
width: 54.0,
|
||||
height: 54.0,
|
||||
fit: BoxFit.cover,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue