Protótipo Vilacorp
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import 'package:decpisos/index/index_controller.dart';
|
||||
import 'package:decpisos/videos/api/youtube_api.dart';
|
||||
import 'package:decpisos/videos/api/youtube_classes.dart';
|
||||
import 'package:vilacorp/index/index_controller.dart';
|
||||
import 'package:vilacorp/videos/api/youtube_api.dart';
|
||||
import 'package:vilacorp/videos/api/youtube_classes.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intl/intl.dart' show DateFormat;
|
||||
|
||||
@@ -16,50 +16,61 @@ class YouTubeController extends GetxController {
|
||||
bool atualizar = false;
|
||||
var errorCode = 0.obs;
|
||||
String? errorMessage = '';
|
||||
var loading = true.obs;
|
||||
var loading = true.obs;
|
||||
final f = DateFormat('dd/MM/yyyy HH:mm:ss');
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
|
||||
// _controller = AnimationController(
|
||||
// duration: const Duration(milliseconds: 650),
|
||||
// vsync: this,
|
||||
// )..forward();
|
||||
// animation = Tween<Offset>(
|
||||
// begin: const Offset(-0.5, 0.0),
|
||||
// end: const Offset(0.0, 0.0),
|
||||
// ).animate(CurvedAnimation(
|
||||
// parent: _controller,
|
||||
// curve: Curves.easeInCubic,
|
||||
// ));
|
||||
|
||||
// _controller = AnimationController(
|
||||
// duration: const Duration(milliseconds: 650),
|
||||
// vsync: this,
|
||||
// )..forward();
|
||||
// animation = Tween<Offset>(
|
||||
// begin: const Offset(-0.5, 0.0),
|
||||
// end: const Offset(0.0, 0.0),
|
||||
// ).animate(CurvedAnimation(
|
||||
// parent: _controller,
|
||||
// curve: Curves.easeInCubic,
|
||||
// ));
|
||||
this.atualizar = true;
|
||||
this.itens = new RxList<YouTubeItems>();
|
||||
this.getChannelVideosBloc();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getChannelVideosBloc({String textoBusca = '-'}) async {
|
||||
//this.loading.value = true;
|
||||
if (results.value.errorCode == null || atualizar || results.value.errorCode != 0) {
|
||||
if (results.value.errorCode == null ||
|
||||
atualizar ||
|
||||
results.value.errorCode != 0) {
|
||||
results.value = new YouTubeSearchResponse();
|
||||
this.itens = new RxList<YouTubeItems>();
|
||||
results.value = await this._api.getChannelVideos();
|
||||
results.value.items = results.value.items!.where((element) => GetUtils.isNullOrBlank(element.id!.videoId) == false).toList();
|
||||
results.value.items = results.value.items!
|
||||
.where(
|
||||
(element) => GetUtils.isNullOrBlank(element.id!.videoId) == false)
|
||||
.toList();
|
||||
this.itens.addAll(results.value.items!);
|
||||
this.errorCode.value = results.value.errorCode!;
|
||||
this.errorMessage = results.value.errorMessage;
|
||||
this.errorCode.value = results.value.errorCode!;
|
||||
this.errorMessage = results.value.errorMessage;
|
||||
this.atualizar = false;
|
||||
} else if (results.value.nextPageToken != null && results.value.nextPageToken!.isNotEmpty) {
|
||||
var more = await this._api.getChannelVideos(nextPageToken: results.value.nextPageToken);
|
||||
more.items = more.items!.where((element) => GetUtils.isNullOrBlank(element.id!.videoId) == false).toList();
|
||||
this.errorCode.value = more.errorCode!;
|
||||
this.errorMessage = more.errorMessage;
|
||||
this.itens.addAll(more.items!);
|
||||
} else if (results.value.nextPageToken != null &&
|
||||
results.value.nextPageToken!.isNotEmpty) {
|
||||
var more = await this
|
||||
._api
|
||||
.getChannelVideos(nextPageToken: results.value.nextPageToken);
|
||||
more.items = more.items!
|
||||
.where(
|
||||
(element) => GetUtils.isNullOrBlank(element.id!.videoId) == false)
|
||||
.toList();
|
||||
this.errorCode.value = more.errorCode!;
|
||||
this.errorMessage = more.errorMessage;
|
||||
this.itens.addAll(more.items!);
|
||||
results.value.nextPageToken = more.nextPageToken ?? '';
|
||||
results.value.items!.addAll(more.items!);
|
||||
}
|
||||
if(this.errorCode.value == -5){
|
||||
if (this.errorCode.value == -5) {
|
||||
this._ic.tabsWithoutVideos();
|
||||
}
|
||||
this.loading.value = false;
|
||||
@@ -76,12 +87,11 @@ class YouTubeController extends GetxController {
|
||||
this.getChannelVideosBloc();
|
||||
}
|
||||
|
||||
String getDateFormatada(String dt){
|
||||
String getDateFormatada(String dt) {
|
||||
String r = '';
|
||||
try {
|
||||
r = this.f.format(DateTime.parse(dt));
|
||||
} catch (e) {
|
||||
}
|
||||
} catch (e) {}
|
||||
return r;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user