Protótipo Vilacorp
This commit is contained in:
+57
-52
@@ -1,5 +1,5 @@
|
||||
import 'package:decpisos/charts/radial_gauge.dart';
|
||||
import 'package:decpisos/funcoes_gerais.dart';
|
||||
import 'package:vilacorp/charts/radial_gauge.dart';
|
||||
import 'package:vilacorp/funcoes_gerais.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:line_icons/line_icons.dart';
|
||||
@@ -7,13 +7,13 @@ import 'package:syncfusion_flutter_gauges/gauges.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
|
||||
class HomeScreen extends StatefulWidget {
|
||||
@override
|
||||
_HomeScreenState createState() => _HomeScreenState();
|
||||
}
|
||||
|
||||
class _HomeScreenState extends State<HomeScreen> with AutomaticKeepAliveClientMixin<HomeScreen> {
|
||||
class _HomeScreenState extends State<HomeScreen>
|
||||
with AutomaticKeepAliveClientMixin<HomeScreen> {
|
||||
bool error = false;
|
||||
String msg = '';
|
||||
@override
|
||||
@@ -25,66 +25,71 @@ class _HomeScreenState extends State<HomeScreen> with AutomaticKeepAliveClientMi
|
||||
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)
|
||||
),
|
||||
IconButton(onPressed: (){
|
||||
Get.bottomSheet(BottomSheet(onClosing: ()=>null, builder: (_){
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: RadialEaseExample(),
|
||||
);
|
||||
}));
|
||||
//Get.to(() => Scaffold(appBar: AppBar(),body: RadialEaseExample()));
|
||||
}, icon: Icon(Icons.monetization_on_outlined))
|
||||
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)),
|
||||
// IconButton(
|
||||
// onPressed: () {
|
||||
// Get.bottomSheet(BottomSheet(
|
||||
// onClosing: () => null,
|
||||
// builder: (_) {
|
||||
// return Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: RadialEaseExample(),
|
||||
// );
|
||||
// }));
|
||||
// //Get.to(() => Scaffold(appBar: AppBar(),body: RadialEaseExample()));
|
||||
// },
|
||||
// icon: Icon(Icons.monetization_on_outlined))
|
||||
],
|
||||
),
|
||||
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;
|
||||
},
|
||||
),
|
||||
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;
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildError(){
|
||||
Widget _buildError() {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(msg),
|
||||
ElevatedButton(onPressed: (){
|
||||
this.error = false;
|
||||
this.msg = '';
|
||||
setState(() {
|
||||
});
|
||||
}, child: Text('Atualizar'))
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
this.error = false;
|
||||
this.msg = '';
|
||||
setState(() {});
|
||||
},
|
||||
child: Text('Atualizar'))
|
||||
// RaisedButton(onPressed: (){
|
||||
// this.error = false;
|
||||
// this.msg = '';
|
||||
@@ -98,4 +103,4 @@ class _HomeScreenState extends State<HomeScreen> with AutomaticKeepAliveClientMi
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user