From 4cbae2f613fd2affa181b2c8e5c2e7e64c89a2da Mon Sep 17 00:00:00 2001
From: Naresh Pratista <2141720057@student.polinema.ac.id>
Date: Mon, 2 Dec 2024 13:43:40 +0700
Subject: [PATCH] Added new mediaUrl constant and replaced occurrences of aseUrl
 with mediaUrl in various widgets and screens.

---
 lib/core/services/constants.dart                              | 3 +++
 lib/features/home/widgets/progress_card.dart                  | 2 +-
 .../modules/exercises/widgets/content/exercise_content.dart   | 4 ++--
 .../learning/modules/topics/screens/topics_list_screen.dart   | 2 +-
 lib/features/learning/widgets/section_card.dart               | 2 +-
 .../modules/edit_profile/screens/edit_profile_screen.dart     | 2 +-
 lib/features/settings/screens/settings_screen.dart            | 2 +-
 7 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/lib/core/services/constants.dart b/lib/core/services/constants.dart
index 6a5d6af..ce6fbd5 100644
--- a/lib/core/services/constants.dart
+++ b/lib/core/services/constants.dart
@@ -1,2 +1,5 @@
 const String baseUrl =
     'https://ba47-2001-448a-50a0-14bf-701c-6eb0-9412-6ff4.ngrok-free.app/';
+
+const String mediaUrl =
+    'https://ba47-2001-448a-50a0-14bf-701c-6eb0-9412-6ff4.ngrok-free.app/api/uploads/';
diff --git a/lib/features/home/widgets/progress_card.dart b/lib/features/home/widgets/progress_card.dart
index d528218..6a2e616 100644
--- a/lib/features/home/widgets/progress_card.dart
+++ b/lib/features/home/widgets/progress_card.dart
@@ -16,7 +16,7 @@ class ProgressCard extends StatelessWidget {
   String _getFullImageUrl(String thumbnail) {
     return thumbnail.startsWith('http')
         ? thumbnail
-        : '${baseUrl}api/uploads/section/$thumbnail';
+        : '${mediaUrl}section/$thumbnail';
   }
 
   Future<void> _navigateToTopics(
diff --git a/lib/features/learning/modules/exercises/widgets/content/exercise_content.dart b/lib/features/learning/modules/exercises/widgets/content/exercise_content.dart
index d5b4e3c..d387d01 100644
--- a/lib/features/learning/modules/exercises/widgets/content/exercise_content.dart
+++ b/lib/features/learning/modules/exercises/widgets/content/exercise_content.dart
@@ -168,7 +168,7 @@ class _ExerciseContentState extends State<ExerciseContent>
                       padding: const EdgeInsets.symmetric(vertical: 16.0),
                       child: ImageWidget(
                         imageFileName: widget.exercise.image!,
-                        baseUrl: '${baseUrl}api/uploads/exercise/image/',
+                        baseUrl: '$mediaUrl/exercise/image/',
                       ),
                     ),
                   ),
@@ -180,7 +180,7 @@ class _ExerciseContentState extends State<ExerciseContent>
                       child: AudioPlayerWidget(
                         key: _audioPlayerKey,
                         audioFileName: widget.exercise.audio!,
-                        baseUrl: '${baseUrl}api/uploads/exercise/audio/',
+                        baseUrl: '${mediaUrl}exercise/audio/',
                       ),
                     ),
                   ),
diff --git a/lib/features/learning/modules/topics/screens/topics_list_screen.dart b/lib/features/learning/modules/topics/screens/topics_list_screen.dart
index ae0916c..7d06689 100644
--- a/lib/features/learning/modules/topics/screens/topics_list_screen.dart
+++ b/lib/features/learning/modules/topics/screens/topics_list_screen.dart
@@ -34,7 +34,7 @@ class _TopicsListScreenState extends State<TopicsListScreen> {
     if (thumbnail.startsWith('http')) {
       return thumbnail;
     } else {
-      return '${baseUrl}api/uploads/section/$thumbnail';
+      return '${mediaUrl}section/$thumbnail';
     }
   }
 
diff --git a/lib/features/learning/widgets/section_card.dart b/lib/features/learning/widgets/section_card.dart
index 769f288..395627e 100644
--- a/lib/features/learning/widgets/section_card.dart
+++ b/lib/features/learning/widgets/section_card.dart
@@ -27,7 +27,7 @@ class _SectionCardState extends State<SectionCard>
     if (thumbnail.startsWith('http')) {
       return thumbnail;
     } else {
-      return '${baseUrl}api/uploads/section/$thumbnail';
+      return '${mediaUrl}section/$thumbnail';
     }
   }
 
diff --git a/lib/features/settings/modules/edit_profile/screens/edit_profile_screen.dart b/lib/features/settings/modules/edit_profile/screens/edit_profile_screen.dart
index 826a676..b1a066f 100644
--- a/lib/features/settings/modules/edit_profile/screens/edit_profile_screen.dart
+++ b/lib/features/settings/modules/edit_profile/screens/edit_profile_screen.dart
@@ -133,7 +133,7 @@ class _EditProfileScreenState extends State<EditProfileScreen> {
                   child: UserAvatar(
                     radius: 60,
                     pictureUrl: userProvider.userData?['PICTURE'],
-                    baseUrl: '${baseUrl}api/uploads/avatar/',
+                    baseUrl: '${mediaUrl}avatar/',
                     onImageSelected: (File image) {
                       userProvider.setSelectedImage(image);
                     },
diff --git a/lib/features/settings/screens/settings_screen.dart b/lib/features/settings/screens/settings_screen.dart
index be8db41..0015414 100644
--- a/lib/features/settings/screens/settings_screen.dart
+++ b/lib/features/settings/screens/settings_screen.dart
@@ -64,7 +64,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
                                 UserAvatar(
                                   radius: 60,
                                   pictureUrl: userProvider.userData?['PICTURE'],
-                                  baseUrl: '${baseUrl}api/uploads/avatar/',
+                                  baseUrl: '${mediaUrl}avatar/',
                                   onImageSelected: (File image) {
                                     userProvider.setSelectedImage(image);
                                   },
