Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
org.benoitharrault.scrobbles
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
android
org.benoitharrault.scrobbles
Commits
a58945e9
Commit
a58945e9
authored
Dec 9, 2023
by
Benoît Harrault
Browse files
Options
Downloads
Patches
Plain Diff
Show last discovered artists and tracks
parent
5d22b55c
No related branches found
No related tags found
1 merge request
!50
Resolve "Show last discovered artists and tracks"
Pipeline
#4739
passed
Dec 9, 2023
Stage: update
Stage: build-debug
Changes
23
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/ui/widgets/cards/new_tracks.dart
+65
-0
65 additions, 0 deletions
lib/ui/widgets/cards/new_tracks.dart
lib/ui/widgets/settings_form.dart
+96
-18
96 additions, 18 deletions
lib/ui/widgets/settings_form.dart
pubspec.yaml
+1
-1
1 addition, 1 deletion
pubspec.yaml
with
162 additions
and
19 deletions
lib/ui/widgets/cards/new_tracks.dart
0 → 100644
+
65
−
0
View file @
a58945e9
import
'package:easy_localization/easy_localization.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_bloc/flutter_bloc.dart'
;
import
'package:scrobbles/cubit/data_new_tracks_cubit.dart'
;
import
'package:scrobbles/cubit/settings_cubit.dart'
;
import
'package:scrobbles/models/new_tracks.dart'
;
import
'package:scrobbles/network/scrobbles.dart'
;
import
'package:scrobbles/ui/widgets/card_content.dart'
;
import
'package:scrobbles/ui/widgets/error.dart'
;
class
CardNewTracks
extends
StatelessWidget
{
const
CardNewTracks
({
super
.
key
});
@override
Widget
build
(
BuildContext
context
)
{
SettingsCubit
settings
=
BlocProvider
.
of
<
SettingsCubit
>(
context
);
final
int
count
=
settings
.
getNewTracksCount
();
return
BlocBuilder
<
DataNewTracksCubit
,
DataNewTracksState
>(
builder:
(
BuildContext
context
,
DataNewTracksState
state
)
{
return
CardContent
(
color:
Theme
.
of
(
context
)
.
colorScheme
.
surface
,
title:
'new_tracks_title'
.
tr
(),
loader:
update
(
count
),
content:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
start
,
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
state
.
newTracks
?.
data
.
map
((
newTrack
)
=
>
Text
((
newTrack
.
track
?.
artist
.
name
??
''
)
+
' - '
+
(
newTrack
.
track
?.
name
??
''
)))
.
toList
()
??
[],
),
);
},
);
}
Widget
update
(
int
count
)
{
final
Widget
loading
=
const
Text
(
'⏳'
);
final
Widget
done
=
const
Text
(
''
);
late
Future
<
NewTracksData
>
future
=
ScrobblesApi
.
fetchNewTracks
(
count
);
return
BlocBuilder
<
DataNewTracksCubit
,
DataNewTracksState
>(
builder:
(
BuildContext
context
,
DataNewTracksState
state
)
{
return
FutureBuilder
<
NewTracksData
>(
future:
future
,
builder:
(
context
,
snapshot
)
{
if
(
snapshot
.
hasError
)
{
return
ShowErrorWidget
(
message:
'
${snapshot.error}
'
);
}
BlocProvider
.
of
<
DataNewTracksCubit
>(
context
)
.
update
(
snapshot
.
data
);
return
!
snapshot
.
hasData
?
loading
:
done
;
},
);
},
);
}
}
This diff is collapsed.
Click to expand it.
lib/ui/widgets/settings_form.dart
+
96
−
18
View file @
a58945e9
...
...
@@ -23,12 +23,16 @@ class _SettingsFormState extends State<SettingsForm> {
int
statisticsRecentDaysCount
=
DefaultSettings
.
defaultStatisticsRecentDaysCount
;
int
timelineDaysCount
=
DefaultSettings
.
defaultTimelineDaysCount
;
int
topArtistsDaysCount
=
DefaultSettings
.
defaultTopArtistsDaysCount
;
int
newArtistsCount
=
DefaultSettings
.
defaultNewArtistsCount
;
int
newTracksCount
=
DefaultSettings
.
defaultNewTracksCount
;
List
<
bool
>
_selectedDiscoveriesDaysCount
=
[];
List
<
bool
>
_selectedDistributionDaysCount
=
[];
List
<
bool
>
_selectedStatisticsRecentDaysCount
=
[];
List
<
bool
>
_selectedTimelineDaysCount
=
[];
List
<
bool
>
_selectedTopArtistsDaysCount
=
[];
List
<
bool
>
_selectedNewArtistsCount
=
[];
List
<
bool
>
_selectedNewTracksCount
=
[];
@override
void
didChangeDependencies
()
{
...
...
@@ -42,17 +46,26 @@ class _SettingsFormState extends State<SettingsForm> {
statisticsRecentDaysCount
=
settings
.
getStatisticsRecentDaysCount
();
timelineDaysCount
=
settings
.
getTimelineDaysCount
();
topArtistsDaysCount
=
settings
.
getTopArtistsDaysCount
();
newArtistsCount
=
settings
.
getNewArtistsCount
();
newTracksCount
=
settings
.
getNewTracksCount
();
_selectedDiscoveriesDaysCount
=
DefaultSettings
.
allowedValues
.
map
((
e
)
=
>
(
e
==
discoveriesDaysCount
))
.
toList
();
_selectedDistributionDaysCount
=
DefaultSettings
.
allowedValues
.
map
((
e
)
=
>
(
e
==
distributionDaysCount
))
.
toList
();
_selectedStatisticsRecentDaysCount
=
DefaultSettings
.
allowedValues
.
map
((
e
)
=
>
(
e
==
statisticsRecentDaysCount
))
.
toList
();
_selectedDiscoveriesDaysCount
=
DefaultSettings
.
allowedDaysCountValues
.
map
((
e
)
=
>
(
e
==
discoveriesDaysCount
))
.
toList
();
_selectedDistributionDaysCount
=
DefaultSettings
.
allowedDaysCountValues
.
map
((
e
)
=
>
(
e
==
distributionDaysCount
))
.
toList
();
_selectedStatisticsRecentDaysCount
=
DefaultSettings
.
allowedDaysCountValues
.
map
((
e
)
=
>
(
e
==
statisticsRecentDaysCount
))
.
toList
();
_selectedTimelineDaysCount
=
DefaultSettings
.
allowedValues
.
map
((
e
)
=
>
(
e
==
timelineDaysCount
))
.
toList
();
DefaultSettings
.
allowed
DaysCount
Values
.
map
((
e
)
=
>
(
e
==
timelineDaysCount
))
.
toList
();
_selectedTopArtistsDaysCount
=
DefaultSettings
.
allowedValues
.
map
((
e
)
=
>
(
e
==
topArtistsDaysCount
))
.
toList
();
DefaultSettings
.
allowedDaysCountValues
.
map
((
e
)
=
>
(
e
==
topArtistsDaysCount
))
.
toList
();
_selectedNewArtistsCount
=
DefaultSettings
.
allowedCountValues
.
map
((
e
)
=
>
(
e
==
newArtistsCount
))
.
toList
();
_selectedNewTracksCount
=
DefaultSettings
.
allowedCountValues
.
map
((
e
)
=
>
(
e
==
newTracksCount
))
.
toList
();
super
.
didChangeDependencies
();
}
...
...
@@ -75,6 +88,8 @@ class _SettingsFormState extends State<SettingsForm> {
statisticsRecentDaysCount:
statisticsRecentDaysCount
,
timelineDaysCount:
timelineDaysCount
,
topArtistsDaysCount:
topArtistsDaysCount
,
newArtistsCount:
newArtistsCount
,
newTracksCount:
newTracksCount
,
);
}
...
...
@@ -118,7 +133,7 @@ class _SettingsFormState extends State<SettingsForm> {
ToggleButtons
(
onPressed:
(
int
index
)
{
setState
(()
{
statisticsRecentDaysCount
=
DefaultSettings
.
allowedValues
[
index
];
statisticsRecentDaysCount
=
DefaultSettings
.
allowed
DaysCount
Values
[
index
];
for
(
int
i
=
0
;
i
<
_selectedStatisticsRecentDaysCount
.
length
;
i
++
)
{
_selectedStatisticsRecentDaysCount
[
i
]
=
i
==
index
;
}
...
...
@@ -128,7 +143,9 @@ class _SettingsFormState extends State<SettingsForm> {
borderRadius:
const
BorderRadius
.
all
(
Radius
.
circular
(
8
)),
constraints:
const
BoxConstraints
(
minHeight:
30.0
,
minWidth:
30.0
),
isSelected:
_selectedStatisticsRecentDaysCount
,
children:
DefaultSettings
.
allowedValues
.
map
((
e
)
=
>
Text
(
e
.
toString
()))
.
toList
(),
children:
DefaultSettings
.
allowedDaysCountValues
.
map
((
e
)
=
>
Text
(
e
.
toString
()))
.
toList
(),
),
],
),
...
...
@@ -142,7 +159,7 @@ class _SettingsFormState extends State<SettingsForm> {
ToggleButtons
(
onPressed:
(
int
index
)
{
setState
(()
{
timelineDaysCount
=
DefaultSettings
.
allowedValues
[
index
];
timelineDaysCount
=
DefaultSettings
.
allowed
DaysCount
Values
[
index
];
for
(
int
i
=
0
;
i
<
_selectedTimelineDaysCount
.
length
;
i
++
)
{
_selectedTimelineDaysCount
[
i
]
=
i
==
index
;
}
...
...
@@ -152,7 +169,9 @@ class _SettingsFormState extends State<SettingsForm> {
borderRadius:
const
BorderRadius
.
all
(
Radius
.
circular
(
8
)),
constraints:
const
BoxConstraints
(
minHeight:
30.0
,
minWidth:
30.0
),
isSelected:
_selectedTimelineDaysCount
,
children:
DefaultSettings
.
allowedValues
.
map
((
e
)
=
>
Text
(
e
.
toString
()))
.
toList
(),
children:
DefaultSettings
.
allowedDaysCountValues
.
map
((
e
)
=
>
Text
(
e
.
toString
()))
.
toList
(),
),
],
),
...
...
@@ -166,7 +185,7 @@ class _SettingsFormState extends State<SettingsForm> {
ToggleButtons
(
onPressed:
(
int
index
)
{
setState
(()
{
topArtistsDaysCount
=
DefaultSettings
.
allowedValues
[
index
];
topArtistsDaysCount
=
DefaultSettings
.
allowed
DaysCount
Values
[
index
];
for
(
int
i
=
0
;
i
<
_selectedTopArtistsDaysCount
.
length
;
i
++
)
{
_selectedTopArtistsDaysCount
[
i
]
=
i
==
index
;
}
...
...
@@ -176,7 +195,9 @@ class _SettingsFormState extends State<SettingsForm> {
borderRadius:
const
BorderRadius
.
all
(
Radius
.
circular
(
8
)),
constraints:
const
BoxConstraints
(
minHeight:
30.0
,
minWidth:
30.0
),
isSelected:
_selectedTopArtistsDaysCount
,
children:
DefaultSettings
.
allowedValues
.
map
((
e
)
=
>
Text
(
e
.
toString
()))
.
toList
(),
children:
DefaultSettings
.
allowedDaysCountValues
.
map
((
e
)
=
>
Text
(
e
.
toString
()))
.
toList
(),
),
],
),
...
...
@@ -190,7 +211,7 @@ class _SettingsFormState extends State<SettingsForm> {
ToggleButtons
(
onPressed:
(
int
index
)
{
setState
(()
{
discoveriesDaysCount
=
DefaultSettings
.
allowedValues
[
index
];
discoveriesDaysCount
=
DefaultSettings
.
allowed
DaysCount
Values
[
index
];
for
(
int
i
=
0
;
i
<
_selectedDiscoveriesDaysCount
.
length
;
i
++
)
{
_selectedDiscoveriesDaysCount
[
i
]
=
i
==
index
;
}
...
...
@@ -200,7 +221,9 @@ class _SettingsFormState extends State<SettingsForm> {
borderRadius:
const
BorderRadius
.
all
(
Radius
.
circular
(
8
)),
constraints:
const
BoxConstraints
(
minHeight:
30.0
,
minWidth:
30.0
),
isSelected:
_selectedDiscoveriesDaysCount
,
children:
DefaultSettings
.
allowedValues
.
map
((
e
)
=
>
Text
(
e
.
toString
()))
.
toList
(),
children:
DefaultSettings
.
allowedDaysCountValues
.
map
((
e
)
=
>
Text
(
e
.
toString
()))
.
toList
(),
),
],
),
...
...
@@ -214,7 +237,7 @@ class _SettingsFormState extends State<SettingsForm> {
ToggleButtons
(
onPressed:
(
int
index
)
{
setState
(()
{
distributionDaysCount
=
DefaultSettings
.
allowedValues
[
index
];
distributionDaysCount
=
DefaultSettings
.
allowed
DaysCount
Values
[
index
];
for
(
int
i
=
0
;
i
<
_selectedDistributionDaysCount
.
length
;
i
++
)
{
_selectedDistributionDaysCount
[
i
]
=
i
==
index
;
}
...
...
@@ -224,7 +247,62 @@ class _SettingsFormState extends State<SettingsForm> {
borderRadius:
const
BorderRadius
.
all
(
Radius
.
circular
(
8
)),
constraints:
const
BoxConstraints
(
minHeight:
30.0
,
minWidth:
30.0
),
isSelected:
_selectedDistributionDaysCount
,
children:
DefaultSettings
.
allowedValues
.
map
((
e
)
=
>
Text
(
e
.
toString
()))
.
toList
(),
children:
DefaultSettings
.
allowedDaysCountValues
.
map
((
e
)
=
>
Text
(
e
.
toString
()))
.
toList
(),
),
],
),
SizedBox
(
height:
8
),
AppTitle2
(
text:
tr
(
'settings_title_counts'
)),
// New artists count
Row
(
mainAxisAlignment:
MainAxisAlignment
.
end
,
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
[
Text
(
'settings_label_new_artists_count'
)
.
tr
(),
ToggleButtons
(
onPressed:
(
int
index
)
{
setState
(()
{
newArtistsCount
=
DefaultSettings
.
allowedCountValues
[
index
];
for
(
int
i
=
0
;
i
<
_selectedNewArtistsCount
.
length
;
i
++
)
{
_selectedNewArtistsCount
[
i
]
=
i
==
index
;
}
});
saveSettings
();
},
borderRadius:
const
BorderRadius
.
all
(
Radius
.
circular
(
8
)),
constraints:
const
BoxConstraints
(
minHeight:
30.0
,
minWidth:
30.0
),
isSelected:
_selectedNewArtistsCount
,
children:
DefaultSettings
.
allowedCountValues
.
map
((
e
)
=
>
Text
(
e
.
toString
()))
.
toList
(),
),
],
),
// New tracks count
Row
(
mainAxisAlignment:
MainAxisAlignment
.
end
,
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
[
Text
(
'settings_label_new_tracks_count'
)
.
tr
(),
ToggleButtons
(
onPressed:
(
int
index
)
{
setState
(()
{
newTracksCount
=
DefaultSettings
.
allowedCountValues
[
index
];
for
(
int
i
=
0
;
i
<
_selectedNewTracksCount
.
length
;
i
++
)
{
_selectedNewTracksCount
[
i
]
=
i
==
index
;
}
});
saveSettings
();
},
borderRadius:
const
BorderRadius
.
all
(
Radius
.
circular
(
8
)),
constraints:
const
BoxConstraints
(
minHeight:
30.0
,
minWidth:
30.0
),
isSelected:
_selectedNewTracksCount
,
children:
DefaultSettings
.
allowedCountValues
.
map
((
e
)
=
>
Text
(
e
.
toString
()))
.
toList
(),
),
],
),
...
...
This diff is collapsed.
Click to expand it.
pubspec.yaml
+
1
−
1
View file @
a58945e9
...
...
@@ -3,7 +3,7 @@ description: Display scrobbles data and charts
publish_to
:
'
none'
version
:
0.0.4
8
+4
8
version
:
0.0.4
9
+4
9
environment
:
sdk
:
'
^3.0.0'
...
...
This diff is collapsed.
Click to expand it.
Prev
1
2
Next
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment