[videos] archive videos
This commit is contained in:
parent
8ca1864351
commit
c693d5ce94
|
|
@ -35,7 +35,10 @@ class Home extends StatelessWidget {
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: BlocConsumer<VideosCubit, VideosState>(
|
||||||
|
listener: (context, state) {},
|
||||||
|
builder: (context, state) {
|
||||||
|
return Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
SizedBox(height: 10),
|
SizedBox(height: 10),
|
||||||
Text('home_intro').tr(),
|
Text('home_intro').tr(),
|
||||||
|
|
@ -43,21 +46,11 @@ class Home extends StatelessWidget {
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||||
child: DlForm()),
|
child: DlForm()),
|
||||||
Flexible(
|
state.status == 'loading'
|
||||||
child: BlocConsumer<VideosCubit, VideosState>(
|
? Center(child: CircularProgressIndicator())
|
||||||
listener: (context, state) {},
|
: Flexible(
|
||||||
builder: (context, state) {
|
flex: 5,
|
||||||
var returnWidget = <Widget>[];
|
child: ListView.builder(
|
||||||
switch (state.status) {
|
|
||||||
case 'loading':
|
|
||||||
returnWidget.add(Center(
|
|
||||||
child: CircularProgressIndicator()));
|
|
||||||
case 'error':
|
|
||||||
returnWidget.add(Center(
|
|
||||||
child: Text('home_dl_error').tr(),
|
|
||||||
));
|
|
||||||
default:
|
|
||||||
returnWidget.add(ListView.builder(
|
|
||||||
itemCount: state.videoList.length,
|
itemCount: state.videoList.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
var currentVideo =
|
var currentVideo =
|
||||||
|
|
@ -75,9 +68,11 @@ class Home extends StatelessWidget {
|
||||||
'${currentVideo.status} - ${currentVideo.format.format}'),
|
'${currentVideo.status} - ${currentVideo.format.format}'),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
));
|
)),
|
||||||
}
|
state.archiveList.length > 0
|
||||||
returnWidget.add(ListView.builder(
|
? Flexible(
|
||||||
|
flex: 1,
|
||||||
|
child: ListView.builder(
|
||||||
itemCount: state.archiveList.length,
|
itemCount: state.archiveList.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
var currentVideo =
|
var currentVideo =
|
||||||
|
|
@ -95,13 +90,11 @@ class Home extends StatelessWidget {
|
||||||
'${currentVideo.status} - ${currentVideo.format.format}'),
|
'${currentVideo.status} - ${currentVideo.format.format}'),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
));
|
))
|
||||||
return Stack(
|
: SizedBox(),
|
||||||
children: returnWidget,
|
|
||||||
);
|
|
||||||
})),
|
|
||||||
],
|
],
|
||||||
),
|
);
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: CircularProgressIndicator();
|
: CircularProgressIndicator();
|
||||||
|
|
|
||||||
|
|
@ -8,5 +8,6 @@
|
||||||
"en_US": "English",
|
"en_US": "English",
|
||||||
"fr_FR": "French",
|
"fr_FR": "French",
|
||||||
"Ok": "OK",
|
"Ok": "OK",
|
||||||
"home_dl_error": "Error while downloading the video"
|
"home_dl_error": "Error while downloading the video",
|
||||||
|
"home_archive": "Archive"
|
||||||
}
|
}
|
||||||
|
|
@ -8,5 +8,6 @@
|
||||||
"en_US": "Anglais",
|
"en_US": "Anglais",
|
||||||
"fr_FR": "Français",
|
"fr_FR": "Français",
|
||||||
"Ok": "OK",
|
"Ok": "OK",
|
||||||
"home_dl_error": "Erreur lors du téléchargement de la vidéo"
|
"home_dl_error": "Erreur lors du téléchargement de la vidéo",
|
||||||
|
"home_archive": "Archive"
|
||||||
}
|
}
|
||||||
|
|
@ -59,10 +59,14 @@ class VideosCubit extends Cubit<VideosState> {
|
||||||
emit(VideosState(videoList: nVideoList));
|
emit(VideosState(videoList: nVideoList));
|
||||||
}
|
}
|
||||||
|
|
||||||
void archiveVideo(Video video) {
|
Future<void> archiveVideo(Video video) async {
|
||||||
debugPrint('Archiving video: ${video.title} ${video.format.format}');
|
debugPrint('Archiving video: ${video.title} ${video.format.format}');
|
||||||
var nVideoList = state.videoList.where((v) => v.id != video.id).toList();
|
var nVideoList = state.videoList.where((v) => v.id != video.id).toList();
|
||||||
emit(VideosState(videoList: nVideoList, archiveList: [video]));
|
var archivedVideos = state.archiveList.toList();
|
||||||
|
debugPrint('Archived videos before: ${archivedVideos.length}');
|
||||||
|
archivedVideos.add(video);
|
||||||
|
debugPrint('Archived videos after: $archivedVideos');
|
||||||
|
emit(state.copyWith(videoList: nVideoList, archiveList: archivedVideos));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> startConverter() async {
|
Future<void> startConverter() async {
|
||||||
|
|
@ -145,7 +149,7 @@ class VideosCubit extends Cubit<VideosState> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await changeStatus(video, 'done');
|
await changeStatus(video, 'done');
|
||||||
archiveVideo(video.copyWith(status: 'done'));
|
await archiveVideo(video.copyWith(status: 'done'));
|
||||||
debugPrint('File moved to ${newFile.path}');
|
debugPrint('File moved to ${newFile.path}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,5 +10,14 @@ final class VideosState {
|
||||||
this.videoList = const [],
|
this.videoList = const [],
|
||||||
this.archiveList = const []});
|
this.archiveList = const []});
|
||||||
|
|
||||||
|
VideosState copyWith(
|
||||||
|
{String? status, List<Video>? videoList, List<Video>? archiveList}) {
|
||||||
|
return VideosState(
|
||||||
|
status: status ?? this.status,
|
||||||
|
videoList: videoList ?? this.videoList,
|
||||||
|
archiveList: archiveList ?? this.archiveList,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
List<Object> get props => [videoList, status, archiveList];
|
List<Object> get props => [videoList, status, archiveList];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ description: noTube
|
||||||
|
|
||||||
publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
||||||
|
|
||||||
version: 0.0.18
|
version: 0.0.20
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=3.0.0 <4.0.0"
|
sdk: ">=3.0.0 <4.0.0"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue