Protótipo Vilacorp
This commit is contained in:
+21
-7
@@ -1,10 +1,11 @@
|
||||
import 'package:decpisos/funcoes_gerais.dart';
|
||||
import 'package:vilacorp/funcoes_gerais.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:animated_splash_screen/animated_splash_screen.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:page_transition/page_transition.dart';
|
||||
|
||||
import 'splash_controller.dart';
|
||||
|
||||
class SplashScreen extends StatelessWidget {
|
||||
final SplashController c = Get.put(SplashController());
|
||||
@override
|
||||
@@ -19,11 +20,24 @@ class SplashScreen extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
child: Container(width: 120.0,height: 120.0,child: Image.asset('assets/images/logo.png',fit: BoxFit.contain,))
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
child: Container(
|
||||
width: 120.0,
|
||||
height: 120.0,
|
||||
child: Image.asset(
|
||||
'assets/images/logo.png',
|
||||
fit: BoxFit.contain,
|
||||
))),
|
||||
SizedBox(
|
||||
height: 10.0,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Text(
|
||||
FuncoesGerais.nomeApp,
|
||||
style: TextStyle(color: Colors.white, fontSize: 22.0),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10.0,),
|
||||
Text(FuncoesGerais.nomeApp,style: TextStyle(color: Colors.green.shade600,fontSize: 22.0),),
|
||||
LinearProgressIndicator()
|
||||
],
|
||||
),
|
||||
@@ -33,7 +47,7 @@ class SplashScreen extends StatelessWidget {
|
||||
splashTransition: SplashTransition.slideTransition,
|
||||
pageTransitionType: PageTransitionType.fade,
|
||||
backgroundColor: Colors.blueGrey.shade800,
|
||||
screenFunction: ()async{
|
||||
screenFunction: () async {
|
||||
await c.firebaseCloudMessagingListeners();
|
||||
//await c.verTutorial();
|
||||
var screen = await c.verUsuLogado();
|
||||
@@ -42,4 +56,4 @@ class SplashScreen extends StatelessWidget {
|
||||
//backgroundColor: Colors.blue
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:decpisos/atualizarapp/atualizarapp.dart';
|
||||
import 'package:decpisos/index/index.dart';
|
||||
import 'package:decpisos/notificacoes/notificacoes.dart';
|
||||
import 'package:vilacorp/atualizarapp/atualizarapp.dart';
|
||||
import 'package:vilacorp/index/index.dart';
|
||||
import 'package:vilacorp/notificacoes/notificacoes.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -12,11 +12,10 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../funcoes_gerais.dart';
|
||||
|
||||
class SplashController extends GetxController {
|
||||
|
||||
//bool _tutorialOk = false;
|
||||
//FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
|
||||
//FirebaseMessaging _firebaseMessaging = FirebaseMessaging.instance;
|
||||
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
@@ -29,26 +28,23 @@ class SplashController extends GetxController {
|
||||
|
||||
// Future<void> verTutorial()async{
|
||||
// SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
// this._tutorialOk = prefs.getBool('tutorial') ?? false;
|
||||
// this._tutorialOk = prefs.getBool('tutorial') ?? false;
|
||||
// }
|
||||
|
||||
Future<Widget> verUsuLogado()async{
|
||||
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);
|
||||
return IndexScreen();
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
return AtualizarScreen(linkLoja: resp.linkLoja);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> firebaseCloudMessagingListeners() async{
|
||||
Future<void> firebaseCloudMessagingListeners() async {
|
||||
try {
|
||||
|
||||
//if (_firebaseMessaging == null) return;
|
||||
|
||||
if (Platform.isIOS) iOSPermission();
|
||||
@@ -58,7 +54,7 @@ class SplashController extends GetxController {
|
||||
// SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
// await prefs.setString('token_notif', token);
|
||||
// });
|
||||
FirebaseMessaging.instance.getToken().then((token) async{
|
||||
FirebaseMessaging.instance.getToken().then((token) async {
|
||||
print(token);
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString('token_notif', token!);
|
||||
@@ -69,26 +65,28 @@ class SplashController extends GetxController {
|
||||
// //onBackgroundMessage: this._onNotification,
|
||||
// onResume: this._onNotification
|
||||
// );
|
||||
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
||||
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
|
||||
);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void _onNotification(RemoteMessage message){
|
||||
void _onNotification(RemoteMessage message) {
|
||||
Get.to(() => NotificacoesScreen());
|
||||
//print(message);
|
||||
//print(message['aps']['alert']['title']);
|
||||
@@ -103,7 +101,5 @@ class SplashController extends GetxController {
|
||||
// .listen((IosNotificationSettings settings) {
|
||||
// print("Settings registered: $settings");
|
||||
// });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user