migração flutter 2.2.1
This commit is contained in:
@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class AtualizarScreen extends StatefulWidget {
|
||||
final String linkLoja;
|
||||
final String? linkLoja;
|
||||
AtualizarScreen({this.linkLoja});
|
||||
@override
|
||||
_AtualizarScreenState createState() => _AtualizarScreenState();
|
||||
@@ -55,7 +55,7 @@ class _AtualizarScreenState extends State<AtualizarScreen> {
|
||||
borderRadius: BorderRadius.circular(10.0)
|
||||
),
|
||||
onPressed: (){
|
||||
launch(widget.linkLoja);
|
||||
launch(widget.linkLoja!);
|
||||
}
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class DefaultResponseApi {
|
||||
int errorCode;
|
||||
String errorMessage;
|
||||
int? errorCode;
|
||||
String? errorMessage;
|
||||
|
||||
DefaultResponseApi({this.errorCode, this.errorMessage});
|
||||
|
||||
@@ -18,11 +18,11 @@ class DefaultResponseApi {
|
||||
}
|
||||
|
||||
class RegistraDeviceRequest {
|
||||
int aPPMOBILECODIGO;
|
||||
int pLATAFORMAMOBILECODIGO;
|
||||
String dEVICETOKEN;
|
||||
String mODELODEVICE;
|
||||
int uSUCOD;
|
||||
int? aPPMOBILECODIGO;
|
||||
int? pLATAFORMAMOBILECODIGO;
|
||||
String? dEVICETOKEN;
|
||||
String? mODELODEVICE;
|
||||
int? uSUCOD;
|
||||
|
||||
RegistraDeviceRequest(
|
||||
{this.aPPMOBILECODIGO,
|
||||
@@ -51,12 +51,12 @@ class RegistraDeviceRequest {
|
||||
}
|
||||
|
||||
class ApiStatusResponse {
|
||||
String sistema;
|
||||
String upload;
|
||||
String download;
|
||||
String pagamento;
|
||||
int errorCode;
|
||||
String errorMessage;
|
||||
String? sistema;
|
||||
String? upload;
|
||||
String? download;
|
||||
String? pagamento;
|
||||
int? errorCode;
|
||||
String? errorMessage;
|
||||
|
||||
ApiStatusResponse(
|
||||
{this.sistema,
|
||||
@@ -77,12 +77,12 @@ class ApiStatusResponse {
|
||||
}
|
||||
|
||||
class VersaoMinimaResponse {
|
||||
int versaoMinima;
|
||||
String linkLoja;
|
||||
String nome;
|
||||
int errorCode;
|
||||
String errorMessage;
|
||||
bool vOk;
|
||||
int? versaoMinima;
|
||||
String? linkLoja;
|
||||
String? nome;
|
||||
int? errorCode;
|
||||
String? errorMessage;
|
||||
bool? vOk;
|
||||
|
||||
VersaoMinimaResponse({this.errorCode, this.errorMessage,this.linkLoja,this.nome,this.versaoMinima,this.vOk});
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'dart:convert';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:device_info/device_info.dart';
|
||||
import 'dart:io';
|
||||
@@ -45,7 +46,7 @@ class FuncoesGerais{
|
||||
return Future<String>.value(tokenPadrao);
|
||||
}
|
||||
|
||||
static Future<void> registraDevice(String token) async{
|
||||
static Future<void> registraDevice(String? token) async{
|
||||
|
||||
if(await FuncoesGerais.checkInternetConnection()){
|
||||
if(token != null && token.isNotEmpty){
|
||||
@@ -78,7 +79,7 @@ class FuncoesGerais{
|
||||
try {
|
||||
var body = json.encode(objPost);
|
||||
//var response = await http.post(url, body: body,headers: heads);
|
||||
await http.post(url, body: body,headers: heads);
|
||||
await http.post(Uri.parse(url), body: body,headers: heads);
|
||||
//var r = await http.post(url, body: body,headers: heads);
|
||||
//print(r);
|
||||
// if (response != null) {
|
||||
@@ -112,8 +113,8 @@ class FuncoesGerais{
|
||||
heads["Content-type"] = "application/json; charset=utf-8";
|
||||
|
||||
try {
|
||||
var response = await http.get(url,headers: heads);
|
||||
if (response != null) {
|
||||
http.Response response = await http.get(Uri.parse(url),headers: heads);
|
||||
if (!GetUtils.isNullOrBlank(response.body)!) {
|
||||
if (response.statusCode == 200) {
|
||||
var data = jsonDecode(response.body);
|
||||
objRetorno = VersaoMinimaResponse.fromJson(data);
|
||||
@@ -121,7 +122,7 @@ class FuncoesGerais{
|
||||
// var v = packageInfo.version.split('.');
|
||||
// int versaoAtual = 0;
|
||||
//if(v.length > 0)versaoAtual = v[0] != null && v[0].isNotEmpty ? int.parse(v[0]) : 0;
|
||||
if(FuncoesGerais.versaoAtual != null && objRetorno.versaoMinima > FuncoesGerais.versaoAtual){
|
||||
if(objRetorno.versaoMinima! > FuncoesGerais.versaoAtual){
|
||||
objRetorno.vOk = false;
|
||||
}
|
||||
}
|
||||
|
||||
+51
-22
@@ -1,5 +1,7 @@
|
||||
import 'package:decpisos/funcoes_gerais.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:line_icons/line_icons.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
@@ -14,25 +16,46 @@ class _HomeScreenState extends State<HomeScreen> with AutomaticKeepAliveClientMi
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return SafeArea(
|
||||
child: this.error ? this._buildError() : WebView(
|
||||
initialUrl: FuncoesGerais.homeURL,
|
||||
javascriptMode: JavascriptMode.unrestricted,
|
||||
onWebResourceError: (err){
|
||||
this.error = true;
|
||||
this.msg = err.description;
|
||||
setState(() {
|
||||
});
|
||||
},
|
||||
navigationDelegate: (navigation){
|
||||
print(navigation.url);
|
||||
if (navigation.url.startsWith(FuncoesGerais.dominioPermitido)) {
|
||||
return NavigationDecision.navigate;
|
||||
}
|
||||
//print('allowing navigation to $request');
|
||||
launch(navigation.url);
|
||||
return NavigationDecision.prevent;
|
||||
},
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(FuncoesGerais.nomeApp),
|
||||
centerTitle: false,
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: (){
|
||||
if(Get.theme.brightness == Brightness.dark){
|
||||
Get.changeThemeMode(ThemeMode.light);
|
||||
}
|
||||
else{
|
||||
Get.changeThemeMode(ThemeMode.dark);
|
||||
}
|
||||
},
|
||||
tooltip: 'Alternar modo dark/light',
|
||||
icon: Icon(LineIcons.palette)
|
||||
)
|
||||
],
|
||||
),
|
||||
body: SafeArea(
|
||||
child: this.error ? this._buildError() : WebView(
|
||||
initialUrl: FuncoesGerais.homeURL,
|
||||
javascriptMode: JavascriptMode.unrestricted,
|
||||
onWebResourceError: (err){
|
||||
this.error = true;
|
||||
this.msg = err.description;
|
||||
setState(() {
|
||||
});
|
||||
},
|
||||
allowsInlineMediaPlayback: true,
|
||||
navigationDelegate: (navigation){
|
||||
print(navigation.url);
|
||||
if (navigation.url.startsWith(FuncoesGerais.dominioPermitido)) {
|
||||
return NavigationDecision.navigate;
|
||||
}
|
||||
//print('allowing navigation to $request');
|
||||
launch(navigation.url);
|
||||
return NavigationDecision.prevent;
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -44,12 +67,18 @@ class _HomeScreenState extends State<HomeScreen> with AutomaticKeepAliveClientMi
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(msg),
|
||||
RaisedButton(onPressed: (){
|
||||
ElevatedButton(onPressed: (){
|
||||
this.error = false;
|
||||
this.msg = '';
|
||||
setState(() {
|
||||
});
|
||||
}, child: Text('Atualizar'),)
|
||||
});
|
||||
}, child: Text('Atualizar'))
|
||||
// RaisedButton(onPressed: (){
|
||||
// this.error = false;
|
||||
// this.msg = '';
|
||||
// setState(() {
|
||||
// });
|
||||
// }, child: Text('Atualizar'),)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -10,19 +10,19 @@ import 'package:line_icons/line_icons.dart';
|
||||
//import 'package:line_icons/line_icons.dart';
|
||||
|
||||
class IndexController extends GetxController with SingleGetTickerProviderMixin {
|
||||
TabController tabController;
|
||||
var tabs = List<TabItem>().obs;
|
||||
var childrenTabs = List<Widget>().obs;
|
||||
TabController? tabController;
|
||||
var tabs = <TabItem>[].obs;
|
||||
var childrenTabs = <Widget>[].obs;
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
this.initTabs();
|
||||
this.tabController.index = 1;
|
||||
this.tabController!.index = 1;
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
this.tabController.dispose();
|
||||
this.tabController!.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
|
||||
@@ -44,12 +44,18 @@ class _InstagramScreenState extends State<InstagramScreen> with AutomaticKeepAli
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(msg),
|
||||
RaisedButton(onPressed: (){
|
||||
ElevatedButton(onPressed: (){
|
||||
this.error = false;
|
||||
this.msg = '';
|
||||
setState(() {
|
||||
});
|
||||
}, child: Text('Atualizar'),)
|
||||
});
|
||||
}, child: Text('Atualizar'))
|
||||
// RaisedButton(onPressed: (){
|
||||
// this.error = false;
|
||||
// this.msg = '';
|
||||
// setState(() {
|
||||
// });
|
||||
// }, child: Text('Atualizar'),)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
+18
-5
@@ -1,11 +1,21 @@
|
||||
import 'package:decpisos/funcoes_gerais.dart';
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
//import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'splash/splash.dart';
|
||||
|
||||
void main() {
|
||||
Future<void> main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await Firebase.initializeApp();
|
||||
// Set the background messaging handler early on, as a named top-level function
|
||||
// FirebaseMessaging.onBackgroundMessage((RemoteMessage message) async {
|
||||
// await Firebase.initializeApp();
|
||||
// print('Handling a background message ${message.messageId}');
|
||||
// });
|
||||
|
||||
runApp(GetMaterialApp(
|
||||
title: FuncoesGerais.nomeApp,
|
||||
localizationsDelegates: [
|
||||
@@ -17,11 +27,14 @@ void main() {
|
||||
supportedLocales: [
|
||||
const Locale('pt'),
|
||||
],
|
||||
theme: ThemeData.light().copyWith(primaryColor: Color(0xFF05578e)),
|
||||
darkTheme: ThemeData.dark().copyWith(primaryColor: Colors.black87),
|
||||
// theme: ThemeData(
|
||||
// //brightness: Brightness.dark,
|
||||
// visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||
// primarySwatch: Colors.blueGrey
|
||||
// ),
|
||||
themeMode: ThemeMode.dark,
|
||||
theme: ThemeData(
|
||||
brightness: Brightness.dark,
|
||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||
),
|
||||
home: SplashScreen()
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:get/get_utils/src/get_utils/get_utils.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '../../default_response_api.dart';
|
||||
@@ -26,9 +27,10 @@ class NotificacoesApi{
|
||||
Map<String, String> heads = Map();
|
||||
heads["Content-type"] = "application/json; charset=utf-8";
|
||||
|
||||
var response = await http.get(url, headers: heads);
|
||||
var response = await http.get(Uri.parse(url), headers: heads);
|
||||
|
||||
if (response != null) {
|
||||
//if (response != null) {
|
||||
if (!GetUtils.isNullOrBlank(response.body)!) {
|
||||
if (response.statusCode == 200) {
|
||||
var data = jsonDecode(response.body);
|
||||
retorno = NotificacoesResponse.fromJson(data);
|
||||
@@ -47,7 +49,7 @@ class NotificacoesApi{
|
||||
return retorno;
|
||||
}
|
||||
|
||||
Future<NotificacaoResponse> getNotificacao(int id) async{
|
||||
Future<NotificacaoResponse> getNotificacao(int? id) async{
|
||||
var retorno = new NotificacaoResponse(
|
||||
errorCode: 0,
|
||||
errorMessage: ""
|
||||
@@ -63,9 +65,9 @@ class NotificacoesApi{
|
||||
Map<String, String> heads = Map();
|
||||
heads["Content-type"] = "application/json; charset=utf-8";
|
||||
|
||||
var response = await http.get(url, headers: heads);
|
||||
var response = await http.get(Uri.parse(url), headers: heads);
|
||||
|
||||
if (response != null) {
|
||||
if (!GetUtils.isNullOrBlank(response.body)!) {
|
||||
if (response.statusCode == 200) {
|
||||
var data = jsonDecode(response.body);
|
||||
retorno = NotificacaoResponse.fromJson(data);
|
||||
@@ -100,9 +102,9 @@ class NotificacoesApi{
|
||||
|
||||
var body = json.encode(post);
|
||||
|
||||
var response = await http.post(url, headers: heads, body: body);
|
||||
var response = await http.post(Uri.parse(url), headers: heads, body: body);
|
||||
|
||||
if (response != null) {
|
||||
if (!GetUtils.isNullOrBlank(response.body)!) {
|
||||
if (response.statusCode == 200) {
|
||||
var data = jsonDecode(response.body);
|
||||
objRetorno = DefaultResponseApi.fromJson(data);
|
||||
@@ -135,10 +137,10 @@ class NotificacoesApi{
|
||||
|
||||
var body = json.encode(post);
|
||||
|
||||
var response = await http.post(url, headers: heads, body: body);
|
||||
var response = await http.post(Uri.parse(url), headers: heads, body: body);
|
||||
|
||||
|
||||
if (response != null) {
|
||||
if (!GetUtils.isNullOrBlank(response.body)!) {
|
||||
if (response.statusCode == 200) {
|
||||
var data = jsonDecode(response.body);
|
||||
objRetorno = DefaultResponseApi.fromJson(data);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class NotificacaoLikeRequest {
|
||||
int iD;
|
||||
String like;
|
||||
int? iD;
|
||||
String? like;
|
||||
|
||||
NotificacaoLikeRequest({this.iD, this.like});
|
||||
|
||||
@@ -18,8 +18,8 @@ class NotificacaoLikeRequest {
|
||||
}
|
||||
|
||||
class NotificacaoLidaRequest {
|
||||
String latitude;
|
||||
String longitude;
|
||||
String? latitude;
|
||||
String? longitude;
|
||||
|
||||
NotificacaoLidaRequest({this.latitude, this.longitude});
|
||||
|
||||
@@ -38,9 +38,9 @@ class NotificacaoLidaRequest {
|
||||
|
||||
|
||||
class NotificacaoResponse {
|
||||
NotificacaoResults result;
|
||||
int errorCode;
|
||||
String errorMessage;
|
||||
NotificacaoResults? result;
|
||||
int? errorCode;
|
||||
String? errorMessage;
|
||||
|
||||
NotificacaoResponse({this.result, this.errorCode, this.errorMessage});
|
||||
|
||||
@@ -54,7 +54,7 @@ class NotificacaoResponse {
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
if (this.result != null) {
|
||||
data['Result'] = this.result.toJson();
|
||||
data['Result'] = this.result!.toJson();
|
||||
}
|
||||
data['ErrorCode'] = this.errorCode;
|
||||
data['ErrorMessage'] = this.errorMessage;
|
||||
@@ -63,18 +63,18 @@ class NotificacaoResponse {
|
||||
}
|
||||
|
||||
class NotificacoesResponse {
|
||||
List<NotificacaoResults> results;
|
||||
int errorCode;
|
||||
String errorMessage;
|
||||
bool loadMore;
|
||||
List<NotificacaoResults>? results;
|
||||
int? errorCode;
|
||||
String? errorMessage;
|
||||
bool? loadMore;
|
||||
|
||||
NotificacoesResponse({this.results, this.errorCode, this.errorMessage,this.loadMore});
|
||||
|
||||
NotificacoesResponse.fromJson(Map<String, dynamic> json) {
|
||||
if (json['Results'] != null) {
|
||||
results = new List<NotificacaoResults>();
|
||||
results = <NotificacaoResults>[];
|
||||
json['Results'].forEach((v) {
|
||||
results.add(new NotificacaoResults.fromJson(v));
|
||||
results!.add(new NotificacaoResults.fromJson(v));
|
||||
});
|
||||
}
|
||||
errorCode = json['ErrorCode'];
|
||||
@@ -84,7 +84,7 @@ class NotificacoesResponse {
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
if (this.results != null) {
|
||||
data['Results'] = this.results.map((v) => v.toJson()).toList();
|
||||
data['Results'] = this.results!.map((v) => v.toJson()).toList();
|
||||
}
|
||||
data['ErrorCode'] = this.errorCode;
|
||||
data['ErrorMessage'] = this.errorMessage;
|
||||
@@ -93,15 +93,15 @@ class NotificacoesResponse {
|
||||
}
|
||||
|
||||
class NotificacaoResults {
|
||||
int iD;
|
||||
String titulo;
|
||||
String texto;
|
||||
String conteudo;
|
||||
String dataNotificacao;
|
||||
String tipoConteudo;
|
||||
bool visualizado;
|
||||
String imageUrl;
|
||||
String like;
|
||||
int? iD;
|
||||
String? titulo;
|
||||
String? texto;
|
||||
String? conteudo;
|
||||
String? dataNotificacao;
|
||||
String? tipoConteudo;
|
||||
bool? visualizado;
|
||||
String? imageUrl;
|
||||
String? like;
|
||||
|
||||
NotificacaoResults(
|
||||
{this.iD,
|
||||
|
||||
@@ -15,17 +15,17 @@ class NotificacaoDetail extends StatelessWidget {
|
||||
//
|
||||
//title: Obx(() => Text(c.notificacaoDetail.value.result.titulo ?? 'Notificação')),
|
||||
),
|
||||
body: Obx(() => c.loadingDetail.value ? Center(child: CircularProgressIndicator(),) : c.notificacaoDetail.value.errorCode != 0 ? Center(child: Text(c.notificacaoDetail.value.errorMessage),) : ListView(
|
||||
body: Obx(() => c.loadingDetail.value ? Center(child: CircularProgressIndicator(),) : c.notificacaoDetail.value.errorCode != 0 ? Center(child: Text(c.notificacaoDetail.value.errorMessage!),) : ListView(
|
||||
children: <Widget>[
|
||||
Visibility(
|
||||
visible: GetUtils.isNullOrBlank(c.notificacaoDetail.value.result.imageUrl) == false,
|
||||
visible: GetUtils.isNullOrBlank(c.notificacaoDetail.value.result!.imageUrl) == false,
|
||||
child: Container(
|
||||
color: Colors.black38,
|
||||
height: 250,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(70.0),
|
||||
child: Image.network(
|
||||
c.notificacaoDetail.value.result.imageUrl ?? '',
|
||||
c.notificacaoDetail.value.result!.imageUrl ?? '',
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
@@ -37,14 +37,17 @@ class NotificacaoDetail extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
c.notificacaoDetail.value.result.titulo,
|
||||
c.notificacaoDetail.value.result!.titulo!,
|
||||
style: TextStyle(fontSize: 30.0,),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Html(
|
||||
data: c.notificacaoDetail.value.result.conteudo,
|
||||
onLinkTap: (url){
|
||||
launch(url);
|
||||
data: c.notificacaoDetail.value.result!.conteudo,
|
||||
// onLinkTap: (url){
|
||||
// launch(url);
|
||||
// },
|
||||
onLinkTap: (url,ctx,mp,element){
|
||||
launch(url!);
|
||||
},
|
||||
// style: Theme.of(context).textTheme.bodyText2.copyWith(
|
||||
// color: Colors.black54,
|
||||
|
||||
@@ -71,7 +71,7 @@ class NotificacoesScreen extends StatelessWidget {
|
||||
// child: this._buildListTile(index)
|
||||
// );
|
||||
} else if (index > 1) {
|
||||
if(c.loadMore == null || c.loadMore){
|
||||
if(c.loadMore){
|
||||
c.getNotificacoesBloc();
|
||||
return Container(
|
||||
height: 40,
|
||||
@@ -113,8 +113,9 @@ class NotificacoesScreen extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(c.errorMessage),
|
||||
RaisedButton(onPressed: c.refresh, child: Text('Atualizar'),)
|
||||
Text(c.errorMessage!),
|
||||
ElevatedButton(onPressed: c.refresh, child: Text('Atualizar'))
|
||||
//RaisedButton(onPressed: c.refresh, child: Text('Atualizar'),)
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -123,12 +124,12 @@ class NotificacoesScreen extends StatelessWidget {
|
||||
Widget _buildListTile(int index) {
|
||||
if(c.notificacoesResults[index].tipoConteudo == 'L'){
|
||||
return this._buildListTileTile(index: index,onTap: (){
|
||||
c.notificacaoLidaBloc(c.notificacoesResults[index].iD).then((value) => launch(c.notificacoesResults[index].conteudo));
|
||||
c.notificacaoLidaBloc(c.notificacoesResults[index].iD).then((value) => launch(c.notificacoesResults[index].conteudo!));
|
||||
});
|
||||
}
|
||||
return OpenContainer<bool>(
|
||||
//openColor: Colors.transparent,
|
||||
closedColor: Colors.black87.withOpacity(0.2),
|
||||
closedColor: Get.theme.primaryColor.withOpacity(0.2),
|
||||
transitionType: ContainerTransitionType.fadeThrough,
|
||||
openBuilder: (BuildContext _, VoidCallback openContainer) {
|
||||
c.notificacoesResults[index].visualizado = true;
|
||||
@@ -136,7 +137,7 @@ class NotificacoesScreen extends StatelessWidget {
|
||||
//return _DetailsPage();
|
||||
return NotificacaoDetail();
|
||||
},
|
||||
onClosed: (bool isMarkedAsDone) {
|
||||
onClosed: (bool? isMarkedAsDone) {
|
||||
c.notificacaoLidaBloc(c.notificacoesResults[index].iD);
|
||||
if (isMarkedAsDone ?? false)
|
||||
Get.rawSnackbar(message: 'Marked as done!');
|
||||
@@ -150,21 +151,21 @@ class NotificacoesScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildListTileTile({Function onTap,@required int index}){
|
||||
Widget _buildListTileTile({Function? onTap,required int index}){
|
||||
return ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundImage: GetUtils.isNullOrBlank(c.notificacoesResults[index].imageUrl) ? AssetImage(
|
||||
backgroundImage: (GetUtils.isNullOrBlank(c.notificacoesResults[index].imageUrl)! ? AssetImage(
|
||||
'assets/images/logo.png',
|
||||
) : NetworkImage(c.notificacoesResults[index].imageUrl),
|
||||
) : NetworkImage(c.notificacoesResults[index].imageUrl!)) as ImageProvider<Object>?,
|
||||
// child: Image.asset(
|
||||
// 'assets/images/logo.png',
|
||||
// width: 40,
|
||||
// ),
|
||||
),
|
||||
onTap: onTap,
|
||||
trailing: c.notificacoesResults[index].visualizado ? Text('') : Text('●',style: TextStyle(color: Colors.blue),),
|
||||
title: Text(c.notificacoesResults[index].titulo),
|
||||
subtitle: Text(c.getDateFormatada(c.notificacoesResults[index].dataNotificacao)),
|
||||
onTap: onTap as void Function()?,
|
||||
trailing: c.notificacoesResults[index].visualizado! ? Text('') : Text('●',style: TextStyle(color: Colors.blue),),
|
||||
title: Text(c.notificacoesResults[index].titulo!),
|
||||
subtitle: Text(c.getDateFormatada(c.notificacoesResults[index].dataNotificacao!)),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -5,13 +5,13 @@ import 'api/notificacoes_api.dart';
|
||||
import 'api/notificacoes_classes.dart';
|
||||
|
||||
class NotificacoesController extends GetxController with SingleGetTickerProviderMixin{
|
||||
var notificacoesResults = List<NotificacaoResults>().obs;
|
||||
var notificacoesResults = <NotificacaoResults>[].obs;
|
||||
bool loadMore = true;
|
||||
NotificacoesApi _api = new NotificacoesApi();
|
||||
var notificacaoDetail = NotificacaoResponse().obs;
|
||||
int page = 1;
|
||||
var errorCode = 0.obs;
|
||||
var errorMessage = '';
|
||||
String? errorMessage = '';
|
||||
var loading = true.obs;
|
||||
var loadingDetail = true.obs;
|
||||
var like = ''.obs;
|
||||
@@ -45,27 +45,27 @@ class NotificacoesController extends GetxController with SingleGetTickerProvider
|
||||
getNotificacoesBloc()async{
|
||||
|
||||
var response = await this._api.getNotificacoes(page);
|
||||
this.loadMore = response.results.length < 1 ? false : true;
|
||||
this.loadMore = response.results!.length < 1 ? false : true;
|
||||
if(response.errorCode != 0){
|
||||
this.errorCode.value = response.errorCode;
|
||||
this.errorCode.value = response.errorCode!;
|
||||
this.errorMessage = response.errorMessage;
|
||||
}
|
||||
else{
|
||||
//if(this.page > 1)this.listKey.currentState.insertItem(2,duration: const Duration(milliseconds: 1500));
|
||||
page++;
|
||||
this.notificacoesResults.addAll(response.results);
|
||||
this.notificacoesResults.addAll(response.results!);
|
||||
}
|
||||
|
||||
if(this.loading.value)this.loading.value = false;
|
||||
|
||||
}
|
||||
|
||||
getNotificacaoDetail(int id) async {
|
||||
getNotificacaoDetail(int? id) async {
|
||||
this.loadingDetail.value = true;
|
||||
this.notificacaoDetail.value.result = new NotificacaoResults();
|
||||
var response = await this._api.getNotificacao(id);
|
||||
this.notificacaoDetail.value = response;
|
||||
this.like.value = response.result.like;
|
||||
this.like.value = response.result!.like!;
|
||||
this.loadingDetail.value = false;
|
||||
}
|
||||
|
||||
@@ -80,10 +80,11 @@ class NotificacoesController extends GetxController with SingleGetTickerProvider
|
||||
|
||||
Future<void> notificacaoLikeBloc(NotificacaoLikeRequest item) async {
|
||||
var response = await this._api.notificacaoLike(item);
|
||||
if(response != null && response.errorCode == 0)
|
||||
//if(response != null && response.errorCode == 0)
|
||||
if(response.errorCode != null && response.errorCode == 0)
|
||||
{
|
||||
this.notificacaoDetail.value.result.like = item.like;
|
||||
this.like.value = item.like;
|
||||
this.notificacaoDetail.value.result!.like = item.like;
|
||||
this.like.value = item.like!;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +97,7 @@ class NotificacoesController extends GetxController with SingleGetTickerProvider
|
||||
return r;
|
||||
}
|
||||
|
||||
Future<void> notificacaoLidaBloc(int notificacaoID) async {
|
||||
Future<void> notificacaoLidaBloc(int? notificacaoID) async {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:advance_pdf_viewer/advance_pdf_viewer.dart';
|
||||
//import 'package:advance_pdf_viewer/advance_pdf_viewer.dart';
|
||||
import 'package:decpisos/pdfviewer/pdfviewer_controller.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_pdfview/flutter_pdfview.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class PDFViewerScreen extends StatelessWidget {
|
||||
@@ -18,14 +19,23 @@ class PDFViewerScreen extends StatelessWidget {
|
||||
Obx(() => c.visibleRefresh.value ? IconButton(icon: Icon(Icons.refresh), onPressed: c.refreshPDF) : Container())
|
||||
],
|
||||
),
|
||||
// body: Obx(() => c.loading.value
|
||||
// ? Center(
|
||||
// child: CircularProgressIndicator(),
|
||||
// )
|
||||
// : c.error.value ? c.buildError() : PDFViewer(
|
||||
// lazyLoad: false,
|
||||
// document: c.doc,
|
||||
// )),
|
||||
body: Obx(() => c.loading.value
|
||||
? Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: c.error.value ? c.buildError() : PDFViewer(
|
||||
lazyLoad: false,
|
||||
document: c.doc,
|
||||
)),
|
||||
: c.error.value ? c.buildError() : PDFView(
|
||||
filePath: c.filePDF!.path,
|
||||
//nightMode: true,
|
||||
fitPolicy: FitPolicy.BOTH,
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'dart:io' as io;
|
||||
|
||||
import 'package:advance_pdf_viewer/advance_pdf_viewer.dart';
|
||||
//import 'package:advance_pdf_viewer/advance_pdf_viewer.dart';
|
||||
import 'package:decpisos/funcoes_gerais.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
@@ -13,8 +13,8 @@ class PDFViewerScreenController extends GetxController{
|
||||
var loadPDF = false.obs;
|
||||
var visibleRefresh = false.obs;
|
||||
var error = false.obs;
|
||||
PDFDocument doc;
|
||||
File _filePDF;
|
||||
//PDFDocument doc = PDFDocument();
|
||||
io.File? filePDF;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@@ -24,27 +24,33 @@ class PDFViewerScreenController extends GetxController{
|
||||
|
||||
Future<void> _loadPDF() async {
|
||||
var file = await this._createFileOfPdfUrl();
|
||||
if(file != null && await file.exists()){
|
||||
this.doc = await PDFDocument.fromFile(file);
|
||||
//this.visibleRefresh.value = true;
|
||||
}
|
||||
else{
|
||||
if(await FuncoesGerais.checkInternetConnection() == false){
|
||||
this.error.value = true;
|
||||
}
|
||||
else{
|
||||
this.doc = await PDFDocument.fromURL(FuncoesGerais.urlPDF);
|
||||
}
|
||||
// if(file != null && await file.exists()){
|
||||
// //io.File fpdf = new io.File('${file.path}');
|
||||
// this.doc = await PDFDocument.fromFile(file);
|
||||
// //this.doc = await PDFDocument.fromFile(file);
|
||||
// //this.visibleRefresh.value = true;
|
||||
// }
|
||||
// else{
|
||||
// if(await FuncoesGerais.checkInternetConnection() == false){
|
||||
// this.error.value = true;
|
||||
// }
|
||||
// else{
|
||||
// this.doc = await PDFDocument.fromURL(FuncoesGerais.urlPDF);
|
||||
// }
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
if(file == null || await file.exists() == false){
|
||||
this.error.value = true;
|
||||
}
|
||||
|
||||
this.loading.value = false;
|
||||
}
|
||||
|
||||
Future<void> refreshPDF() async {
|
||||
this.loading.value = true;
|
||||
try {
|
||||
await this._filePDF.delete();
|
||||
await this.filePDF!.delete();
|
||||
this._loadPDF();
|
||||
} catch (e) {
|
||||
Get.rawSnackbar(message: 'Não possível atualizar o PDF. Tente novamente');
|
||||
@@ -57,7 +63,7 @@ class PDFViewerScreenController extends GetxController{
|
||||
this.loadPDF.value = true;
|
||||
var file = await this._createFileOfPdfUrl();
|
||||
try {
|
||||
Share.shareFiles([file.path], text: 'DecCard').then((value) => this.loadPDF.value = false);
|
||||
Share.shareFiles([file!.path], text: 'DecCard').then((value) => this.loadPDF.value = false);
|
||||
} catch (e) {
|
||||
this.loadPDF.value = false;
|
||||
Get.rawSnackbar(message: 'Não foi possível compartilhar o PDF');
|
||||
@@ -65,16 +71,16 @@ class PDFViewerScreenController extends GetxController{
|
||||
|
||||
}
|
||||
|
||||
Future<File> _createFileOfPdfUrl() async {
|
||||
Future<io.File?> _createFileOfPdfUrl() async {
|
||||
final url = FuncoesGerais.urlPDF;
|
||||
File file;
|
||||
|
||||
io.File? file;
|
||||
//f.File file2;
|
||||
final filename = url.substring(url.lastIndexOf("/") + 1);
|
||||
String dir = (await getApplicationDocumentsDirectory()).path;
|
||||
file = new File('$dir/$filename');
|
||||
file = io.File('$dir/$filename');
|
||||
if(!await file.exists()){
|
||||
if(await FuncoesGerais.checkInternetConnection()){
|
||||
var request = await HttpClient().getUrl(Uri.parse(url));
|
||||
var request = await io.HttpClient().getUrl(Uri.parse(url));
|
||||
var response = await request.close();
|
||||
var bytes = await consolidateHttpClientResponseBytes(response);
|
||||
await file.writeAsBytes(bytes);
|
||||
@@ -83,8 +89,8 @@ class PDFViewerScreenController extends GetxController{
|
||||
file = null;
|
||||
}
|
||||
}
|
||||
this._filePDF = file;
|
||||
if(this._filePDF != null) this.visibleRefresh.value = await this._filePDF.exists();
|
||||
this.filePDF = file;
|
||||
if(this.filePDF != null) this.visibleRefresh.value = await this.filePDF!.exists();
|
||||
|
||||
return file;
|
||||
}
|
||||
@@ -98,7 +104,8 @@ class PDFViewerScreenController extends GetxController{
|
||||
children: [
|
||||
Text('Não foi possível carregar o PDF'),
|
||||
SizedBox(height: 10.0,),
|
||||
RaisedButton(onPressed: this.refreshPDF,child: Text('Atualizar'),)
|
||||
ElevatedButton(onPressed: this.refreshPDF,child: Text('Atualizar'))
|
||||
//RaisedButton(onPressed: this.refreshPDF,child: Text('Atualizar'),)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -35,7 +35,7 @@ class SplashScreen extends StatelessWidget {
|
||||
backgroundColor: Colors.blueGrey.shade800,
|
||||
screenFunction: ()async{
|
||||
await c.firebaseCloudMessagingListeners();
|
||||
await c.verTutorial();
|
||||
//await c.verTutorial();
|
||||
var screen = await c.verUsuLogado();
|
||||
return screen;
|
||||
},
|
||||
|
||||
@@ -13,8 +13,9 @@ import '../funcoes_gerais.dart';
|
||||
|
||||
class SplashController extends GetxController {
|
||||
|
||||
bool _tutorialOk = false;
|
||||
FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
|
||||
//bool _tutorialOk = false;
|
||||
//FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
|
||||
//FirebaseMessaging _firebaseMessaging = FirebaseMessaging.instance;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@@ -26,14 +27,14 @@ class SplashController extends GetxController {
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
Future<void> verTutorial()async{
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
this._tutorialOk = prefs.getBool('tutorial') ?? false;
|
||||
}
|
||||
// Future<void> verTutorial()async{
|
||||
// SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
// this._tutorialOk = prefs.getBool('tutorial') ?? false;
|
||||
// }
|
||||
|
||||
Future<Widget> verUsuLogado()async{
|
||||
var resp = await FuncoesGerais.checkVersaoMinimaOk();
|
||||
if(resp.vOk){
|
||||
if(resp.vOk!){
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
var token = prefs.getString('token_notif');
|
||||
await FuncoesGerais.registraDevice(token);
|
||||
@@ -48,28 +49,46 @@ class SplashController extends GetxController {
|
||||
Future<void> firebaseCloudMessagingListeners() async{
|
||||
try {
|
||||
|
||||
if (_firebaseMessaging == null) return;
|
||||
//if (_firebaseMessaging == null) return;
|
||||
|
||||
if (Platform.isIOS) iOSPermission();
|
||||
|
||||
_firebaseMessaging.getToken().then((token) async {
|
||||
// _firebaseMessaging.getToken().then((token) async {
|
||||
// print(token);
|
||||
// SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
// await prefs.setString('token_notif', token);
|
||||
// });
|
||||
FirebaseMessaging.instance.getToken().then((token) async{
|
||||
print(token);
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString('token_notif', token);
|
||||
await prefs.setString('token_notif', token!);
|
||||
});
|
||||
|
||||
_firebaseMessaging.configure(
|
||||
onLaunch: this._onNotification,
|
||||
onMessage: this._onNotification,
|
||||
//onBackgroundMessage: this._onNotification,
|
||||
onResume: this._onNotification
|
||||
);
|
||||
// _firebaseMessaging.configure(
|
||||
// onLaunch: this._onNotification,
|
||||
// onMessage: this._onNotification,
|
||||
// //onBackgroundMessage: this._onNotification,
|
||||
// onResume: this._onNotification
|
||||
// );
|
||||
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
||||
print('Push onMessage');
|
||||
Get.snackbar(message.notification!.title ?? 'Notificação', message.notification!.body ?? 'Nova notificação',
|
||||
mainButton: TextButton(onPressed: () => this._onNotification(message), child: Text('Ver')),
|
||||
backgroundColor: Colors.black.withOpacity(0.7),
|
||||
colorText: Colors.white
|
||||
);
|
||||
//this._onNotification(message);
|
||||
});
|
||||
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
|
||||
print('A new onMessageOpenedApp event was published!');
|
||||
print(message);
|
||||
//Get.snackbar(message.notification!.title ?? 'Notificação', message.notification!.body ?? 'Nova notificação',mainButton: TextButton(onPressed: () => this._onNotification(message), child: Text('Ver')));
|
||||
});
|
||||
} on PlatformException catch (e) {
|
||||
print(e.message);
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> _onNotification(Map<String, dynamic> message) async{
|
||||
void _onNotification(RemoteMessage message){
|
||||
Get.to(() => NotificacoesScreen());
|
||||
//print(message);
|
||||
//print(message['aps']['alert']['title']);
|
||||
@@ -77,12 +96,13 @@ class SplashController extends GetxController {
|
||||
}
|
||||
|
||||
void iOSPermission() {
|
||||
_firebaseMessaging.requestNotificationPermissions(
|
||||
IosNotificationSettings(sound: true, badge: true, alert: true));
|
||||
_firebaseMessaging.onIosSettingsRegistered
|
||||
.listen((IosNotificationSettings settings) {
|
||||
print("Settings registered: $settings");
|
||||
});
|
||||
FirebaseMessaging.instance.requestPermission();
|
||||
// _firebaseMessaging.requestNotificationPermissions(
|
||||
// IosNotificationSettings(sound: true, badge: true, alert: true));
|
||||
// _firebaseMessaging.onIosSettingsRegistered
|
||||
// .listen((IosNotificationSettings settings) {
|
||||
// print("Settings registered: $settings");
|
||||
// });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'youtube_classes.dart';
|
||||
|
||||
class YouTubeApi{
|
||||
|
||||
Future<YouTubeSearchResponse> getChannelVideos({String nextPageToken = ''}) async {
|
||||
Future<YouTubeSearchResponse> getChannelVideos({String? nextPageToken = ''}) async {
|
||||
var retorno = new YouTubeSearchResponse(
|
||||
errorCode: 0,
|
||||
errorMessage: '',
|
||||
@@ -25,12 +25,13 @@ class YouTubeApi{
|
||||
|
||||
String url = "https://www.googleapis.com/youtube/v3/search?key=${FuncoesGerais.youtubeApiKey}&channelId=${FuncoesGerais.channelId}&part=snippet,id&order=date&maxResults=10";
|
||||
|
||||
if(nextPageToken.isNotEmpty) url += "&pageToken=$nextPageToken";
|
||||
if(nextPageToken!.isNotEmpty) url += "&pageToken=$nextPageToken";
|
||||
|
||||
try{
|
||||
var response = await http.get(url);
|
||||
var response = await http.get(Uri.parse(url));
|
||||
|
||||
if (response != null) {
|
||||
//if (response != null) {
|
||||
if (response.body.isNotEmpty) {
|
||||
if (response.statusCode == 200) {
|
||||
var data = jsonDecode(response.body);
|
||||
retorno = YouTubeSearchResponse.fromJson(data);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
class YouTubeSearchResponse {
|
||||
String kind;
|
||||
String etag;
|
||||
String nextPageToken;
|
||||
String regionCode;
|
||||
PageInfo pageInfo;
|
||||
List<YouTubeItems> items;
|
||||
int errorCode;
|
||||
String errorMessage;
|
||||
String? kind;
|
||||
String? etag;
|
||||
String? nextPageToken;
|
||||
String? regionCode;
|
||||
PageInfo? pageInfo;
|
||||
List<YouTubeItems>? items;
|
||||
int? errorCode;
|
||||
String? errorMessage;
|
||||
|
||||
YouTubeSearchResponse({this.kind, this.etag, this.nextPageToken, this.regionCode, this.pageInfo, this.items,this.errorCode = 0, this.errorMessage = ''});
|
||||
|
||||
@@ -17,8 +17,8 @@ class YouTubeSearchResponse {
|
||||
regionCode = json['regionCode'] ?? '';
|
||||
pageInfo = json['pageInfo'] != null ? new PageInfo.fromJson(json['pageInfo']) : null;
|
||||
if (json['items'] != null) {
|
||||
items = new List<YouTubeItems>();
|
||||
json['items'].forEach((v) { items.add(new YouTubeItems.fromJson(v)); });
|
||||
items = <YouTubeItems>[];
|
||||
json['items'].forEach((v) { items!.add(new YouTubeItems.fromJson(v)); });
|
||||
}
|
||||
errorCode = 0;
|
||||
errorMessage = '';
|
||||
@@ -26,8 +26,8 @@ class YouTubeSearchResponse {
|
||||
}
|
||||
|
||||
class PageInfo {
|
||||
int totalResults;
|
||||
int resultsPerPage;
|
||||
int? totalResults;
|
||||
int? resultsPerPage;
|
||||
|
||||
PageInfo({this.totalResults, this.resultsPerPage});
|
||||
|
||||
@@ -45,10 +45,10 @@ class PageInfo {
|
||||
}
|
||||
|
||||
class YouTubeItems {
|
||||
String kind;
|
||||
String etag;
|
||||
Id id;
|
||||
Snippet snippet;
|
||||
String? kind;
|
||||
String? etag;
|
||||
Id? id;
|
||||
Snippet? snippet;
|
||||
|
||||
YouTubeItems({this.kind, this.etag, this.id, this.snippet});
|
||||
|
||||
@@ -64,18 +64,18 @@ class YouTubeItems {
|
||||
data['kind'] = this.kind;
|
||||
data['etag'] = this.etag;
|
||||
if (this.id != null) {
|
||||
data['id'] = this.id.toJson();
|
||||
data['id'] = this.id!.toJson();
|
||||
}
|
||||
if (this.snippet != null) {
|
||||
data['snippet'] = this.snippet.toJson();
|
||||
data['snippet'] = this.snippet!.toJson();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Id {
|
||||
String kind;
|
||||
String videoId;
|
||||
String? kind;
|
||||
String? videoId;
|
||||
|
||||
Id({this.kind, this.videoId});
|
||||
|
||||
@@ -93,14 +93,14 @@ class Id {
|
||||
}
|
||||
|
||||
class Snippet {
|
||||
String publishedAt;
|
||||
String channelId;
|
||||
String title;
|
||||
String description;
|
||||
Thumbnails thumbnails;
|
||||
String channelTitle;
|
||||
String liveBroadcastContent;
|
||||
String publishTime;
|
||||
String? publishedAt;
|
||||
String? channelId;
|
||||
String? title;
|
||||
String? description;
|
||||
Thumbnails? thumbnails;
|
||||
String? channelTitle;
|
||||
String? liveBroadcastContent;
|
||||
String? publishTime;
|
||||
|
||||
Snippet({this.publishedAt, this.channelId, this.title, this.description, this.thumbnails, this.channelTitle, this.liveBroadcastContent, this.publishTime});
|
||||
|
||||
@@ -122,7 +122,7 @@ class Snippet {
|
||||
data['title'] = this.title;
|
||||
data['description'] = this.description;
|
||||
if (this.thumbnails != null) {
|
||||
data['thumbnails'] = this.thumbnails.toJson();
|
||||
data['thumbnails'] = this.thumbnails!.toJson();
|
||||
}
|
||||
data['channelTitle'] = this.channelTitle;
|
||||
data['liveBroadcastContent'] = this.liveBroadcastContent;
|
||||
@@ -132,9 +132,9 @@ class Snippet {
|
||||
}
|
||||
|
||||
class Thumbnails {
|
||||
ThumbDefault thumbDefault;
|
||||
ThumbDefault medium;
|
||||
ThumbDefault high;
|
||||
ThumbDefault? thumbDefault;
|
||||
ThumbDefault? medium;
|
||||
ThumbDefault? high;
|
||||
|
||||
Thumbnails({this.thumbDefault, this.medium, this.high});
|
||||
|
||||
@@ -147,22 +147,22 @@ class Thumbnails {
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
if (this.thumbDefault != null) {
|
||||
data['default'] = this.thumbDefault.toJson();
|
||||
data['default'] = this.thumbDefault!.toJson();
|
||||
}
|
||||
if (this.medium != null) {
|
||||
data['medium'] = this.medium.toJson();
|
||||
data['medium'] = this.medium!.toJson();
|
||||
}
|
||||
if (this.high != null) {
|
||||
data['high'] = this.high.toJson();
|
||||
data['high'] = this.high!.toJson();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class ThumbDefault {
|
||||
String url;
|
||||
int width;
|
||||
int height;
|
||||
String? url;
|
||||
int? width;
|
||||
int? height;
|
||||
|
||||
ThumbDefault({this.url, this.width, this.height});
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class YouTubeController extends GetxController {
|
||||
var itens = <YouTubeItems>[].obs;
|
||||
bool atualizar = false;
|
||||
var errorCode = 0.obs;
|
||||
var errorMessage = '';
|
||||
String? errorMessage = '';
|
||||
var loading = true.obs;
|
||||
final f = DateFormat('dd/MM/yyyy HH:mm:ss');
|
||||
|
||||
@@ -41,23 +41,23 @@ class YouTubeController extends GetxController {
|
||||
|
||||
Future<void> getChannelVideosBloc({String textoBusca = '-'}) async {
|
||||
//this.loading.value = true;
|
||||
if (results == 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();
|
||||
this.itens.addAll(results.value.items);
|
||||
this.errorCode.value = results.value.errorCode;
|
||||
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.atualizar = false;
|
||||
} else if (results.value.nextPageToken != null && results.value.nextPageToken.isNotEmpty) {
|
||||
} 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;
|
||||
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);
|
||||
this.itens.addAll(more.items!);
|
||||
results.value.nextPageToken = more.nextPageToken ?? '';
|
||||
results.value.items += more.items;
|
||||
results.value.items!.addAll(more.items!);
|
||||
}
|
||||
if(this.errorCode.value == -5){
|
||||
this._ic.tabsWithoutVideos();
|
||||
|
||||
@@ -5,19 +5,19 @@ import 'api/youtube_classes.dart';
|
||||
|
||||
class YouTubeVideoPlayerScreen extends StatefulWidget {
|
||||
final YouTubeItems ytVideo;
|
||||
YouTubeVideoPlayerScreen({@required this.ytVideo});
|
||||
YouTubeVideoPlayerScreen({required this.ytVideo});
|
||||
@override
|
||||
_YouTubeVideoPlayerScreenState createState() => _YouTubeVideoPlayerScreenState();
|
||||
}
|
||||
|
||||
class _YouTubeVideoPlayerScreenState extends State<YouTubeVideoPlayerScreen> {
|
||||
|
||||
YoutubePlayerController _controller;
|
||||
late YoutubePlayerController _controller;
|
||||
bool _fullScreen = false;
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = new YoutubePlayerController(initialVideoId: widget.ytVideo.id.videoId);
|
||||
_controller = new YoutubePlayerController(initialVideoId: widget.ytVideo.id!.videoId!);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -58,9 +58,9 @@ class _YouTubeVideoPlayerScreenState extends State<YouTubeVideoPlayerScreen> {
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(widget.ytVideo.snippet.title),
|
||||
Text(widget.ytVideo.snippet!.title!),
|
||||
SizedBox(height: 10.0,),
|
||||
Text(widget.ytVideo.snippet.description),
|
||||
Text(widget.ytVideo.snippet!.description!),
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
@@ -219,7 +219,7 @@ class _YouTubeVideosScreenState extends State<YouTubeVideosScreen> with Automati
|
||||
// child: this._buildListTile(index)
|
||||
// );
|
||||
} else if (index > 1) {
|
||||
if (!GetUtils.isNullOrBlank(c.results.value.nextPageToken)) {
|
||||
if (!GetUtils.isNullOrBlank(c.results.value.nextPageToken)!) {
|
||||
c.getChannelVideosBloc();
|
||||
return Center(child: CircularProgressIndicator(),);
|
||||
} else {
|
||||
@@ -248,7 +248,7 @@ class _YouTubeVideosScreenState extends State<YouTubeVideosScreen> with Automati
|
||||
Widget listItem(YouTubeItems item) {
|
||||
return InkWell(
|
||||
onTap: (){
|
||||
if(GetUtils.isNullOrBlank(item.id.videoId)){
|
||||
if(GetUtils.isNullOrBlank(item.id!.videoId)!){
|
||||
Get.rawSnackbar(message: 'Não foi possível reproduzir o vídeo');
|
||||
}
|
||||
else{
|
||||
@@ -281,21 +281,21 @@ class _YouTubeVideosScreenState extends State<YouTubeVideosScreen> with Automati
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
item.snippet.title,
|
||||
item.snippet!.title!,
|
||||
softWrap: true,
|
||||
maxLines: 2,
|
||||
style: TextStyle(fontSize: 13.0,fontWeight: FontWeight.bold),
|
||||
),
|
||||
Padding(padding: EdgeInsets.only(bottom: 1.5)),
|
||||
Text(
|
||||
item.snippet.description,
|
||||
item.snippet!.description!,
|
||||
softWrap: true,
|
||||
maxLines: 3,
|
||||
style: TextStyle(fontSize: 11.0,fontWeight: FontWeight.w400),
|
||||
),
|
||||
Padding(padding: EdgeInsets.only(bottom: 3.0)),
|
||||
Text(
|
||||
c.getDateFormatada(item.snippet.publishedAt),
|
||||
c.getDateFormatada(item.snippet!.publishedAt!),
|
||||
softWrap: true,
|
||||
maxLines: 1,
|
||||
style: TextStyle(fontSize: 9.0,fontWeight: FontWeight.w300),
|
||||
@@ -315,8 +315,9 @@ class _YouTubeVideosScreenState extends State<YouTubeVideosScreen> with Automati
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(c.errorMessage),
|
||||
RaisedButton(onPressed: c.refresh, child: Text('Atualizar'),)
|
||||
Text(c.errorMessage!),
|
||||
ElevatedButton(onPressed: c.refresh, child: Text('Atualizar'))
|
||||
//RaisedButton(onPressed: c.refresh, child: Text('Atualizar'),)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user