Skip to content
Closed
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
2 changes: 2 additions & 0 deletions lib/core/data/models/track_dto.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class TrackDto {
isFeatured: data['is_featured'] as bool? ?? false,
isPublic: data['is_public'] as bool? ?? true,
isHidden: data['is_hidden'] as bool? ?? false,
isGeoBlocked: data['is_geo_blocked'] as bool? ?? false,
geoRestrictionType: data['geo_restriction_type'] as String?,
geoRegions:
(data['geo_regions'] as List<dynamic>?)
Expand Down Expand Up @@ -139,6 +140,7 @@ class TrackDto {
'is_featured': track.isFeatured,
'is_public': track.isPublic,
'is_hidden': track.isHidden,
'is_geo_blocked': track.isGeoBlocked,
'geo_restriction_type': track.geoRestrictionType,
'geo_regions': track.geoRegions,
'status': track.status,
Expand Down
4 changes: 4 additions & 0 deletions lib/core/domain/entities/track.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Track {
final bool isFeatured;
final bool isPublic;
final bool isHidden;
final bool isGeoBlocked;
final String? geoRestrictionType;
final List<String> geoRegions;
final DateTime createdAt;
Expand Down Expand Up @@ -76,6 +77,7 @@ class Track {
this.isFeatured = false,
this.isPublic = true,
this.isHidden = false,
this.isGeoBlocked = false,
this.geoRestrictionType,
this.geoRegions = const [],
this.updatedAt,
Expand Down Expand Up @@ -118,6 +120,7 @@ class Track {
bool? isFeatured,
bool? isPublic,
bool? isHidden,
bool? isGeoBlocked,
String? geoRestrictionType,
List<String>? geoRegions,
DateTime? createdAt,
Expand Down Expand Up @@ -157,6 +160,7 @@ class Track {
isFeatured: isFeatured ?? this.isFeatured,
isPublic: isPublic ?? this.isPublic,
isHidden: isHidden ?? this.isHidden,
isGeoBlocked: isGeoBlocked ?? this.isGeoBlocked,
geoRestrictionType: geoRestrictionType ?? this.geoRestrictionType,
geoRegions: geoRegions ?? this.geoRegions,
createdAt: createdAt ?? this.createdAt,
Expand Down
2 changes: 2 additions & 0 deletions lib/core/network/api_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class ApiClient {
RequestOptions options,
RequestInterceptorHandler handler,
) async {
options.headers['X-Country-Code'] = 'EG';

final skipAuth = options.extra['skipAuth'] == true;
if (!skipAuth) {
final token = await getToken();
Expand Down
140 changes: 77 additions & 63 deletions lib/features/feed/presentation/widgets/home_top_track_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,73 +30,87 @@ class HomeTopTrackCard extends ConsumerWidget {
final isThisTrackLoaded = currentPlayingId == track.id;

return InkWell(
onTap: () {
if (onTap != null) {
onTap!();
return;
}
if (isThisTrackLoaded) {
ref.read(playerStateProvider.notifier).togglePlayPause();
} else {
final tracksToPlay = allTracks ?? [track];
final initialIndex = index ?? 0;
onTap: track.isGeoBlocked
? null
: () {
if (onTap != null) {
onTap!();
return;
}
if (isThisTrackLoaded) {
ref.read(playerStateProvider.notifier).togglePlayPause();
} else {
final tracksToPlay = allTracks ?? [track];
final initialIndex = index ?? 0;

ref
.read(queueStateProvider.notifier)
.playQueue(
tracks: tracksToPlay,
initialIndex: initialIndex,
context: const QueueContext(type: QueueSource.listeningHistory),
);
}
},
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 5.0),
decoration: BoxDecoration(
color: Colors.grey.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(8),
),
child: Row(
children: [
// Artwork
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.0),
border: Border.all(color: Colors.grey.shade700, width: 0.7),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(7.3),
child: _buildArtwork(track.artworkUrl),
ref
.read(queueStateProvider.notifier)
.playQueue(
tracks: tracksToPlay,
initialIndex: initialIndex,
context: const QueueContext(
type: QueueSource.listeningHistory,
),
);
}
},
child: Opacity(
opacity: track.isGeoBlocked ? 0.5 : 1.0,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 5.0),
decoration: BoxDecoration(
color: Colors.grey.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(8),
),
child: Row(
children: [
// Artwork
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.0),
border: Border.all(color: Colors.grey.shade700, width: 0.7),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(7.3),
child: _buildArtwork(track.artworkUrl),
),
),
),
const SizedBox(width: 8),
// Info
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
track.title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: Colors.white,
fontSize: 14,
fontWeight: FontWeight.w600,
const SizedBox(width: 8),
// Info
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
track.title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: Colors.white,
fontSize: 14,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 2),
Text(
track.isGeoBlocked
? 'Not available in your country'
: track.artist,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: track.isGeoBlocked
? Colors.redAccent.withValues(alpha: 0.8)
: Colors.grey[400],
fontSize: 12,
),
),
),
const SizedBox(height: 2),
Text(
track.artist,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: Colors.grey[400], fontSize: 12),
),
],
],
),
),
),
],
],
),
),
),
);
Expand Down
Loading
Loading