several changes before restructuring
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pcast/utils/utils.dart';
|
||||
|
||||
class EmailPage extends StatefulWidget {
|
||||
const EmailPage({super.key});
|
||||
|
||||
@override
|
||||
State<EmailPage> createState() => _EmailPageState();
|
||||
}
|
||||
|
||||
class _EmailPageState extends State<EmailPage> {
|
||||
String email = '';
|
||||
String pass = 'initial';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
alignment: Alignment.center,
|
||||
child: SizedBox(
|
||||
width: MediaQuery.of(context).size.width * 0.5,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Visibility(
|
||||
visible: (pass == 'initial'),
|
||||
child: TextField(
|
||||
onSubmitted: (value) {
|
||||
if (Utils.isValidEmail(value)) {
|
||||
setState(() {
|
||||
email = value;
|
||||
pass = 'authenticate';
|
||||
});
|
||||
}
|
||||
},
|
||||
textInputAction: TextInputAction.search,
|
||||
decoration: const InputDecoration(
|
||||
border: UnderlineInputBorder(),
|
||||
labelText: 'Informe seu email e pressione enter',
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Visibility(
|
||||
visible: (pass == 'authenticate'),
|
||||
child: Text(
|
||||
'Foi informado o email $email. Agora vamos pedir a senha ou vamos pedir para completar o cadastro, dependendo da situação do usuário.',
|
||||
style: const TextStyle(fontSize: 20),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_modular/flutter_modular.dart';
|
||||
import 'package:pcast/models/monitor_model.dart';
|
||||
|
||||
class ServerInfoPage extends StatefulWidget {
|
||||
// const ServerInfoComponent({Key? key, required this.info}) : super(key: key);
|
||||
|
||||
// final MonitorModel info;
|
||||
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Column(
|
||||
// children: [
|
||||
// Text(' CPU: ${info.cpu}'),
|
||||
// Text('Memory: ${info.memory}'),
|
||||
// Text(' Disk: ${info.disk}'),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
const ServerInfoPage({super.key});
|
||||
|
||||
@override
|
||||
State<ServerInfoPage> createState() => _ServerInfoPageState();
|
||||
}
|
||||
|
||||
class _ServerInfoPageState extends State<ServerInfoPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
getmemory();
|
||||
}
|
||||
|
||||
Future<MonitorModel> getmemory() async {
|
||||
final dio = Modular.get<Dio>();
|
||||
final response = await dio.get('https://api.pcastlivetv.com/health');
|
||||
return MonitorModel.fromJson(response.data);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder<MonitorModel>(
|
||||
future: getmemory(),
|
||||
builder: (BuildContext context, AsyncSnapshot<MonitorModel> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Center(child: Text('Please wait its loading...'));
|
||||
} else {
|
||||
if (snapshot.hasError) {
|
||||
return Center(child: Text('Error: ${snapshot.error}'));
|
||||
} else {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Home Page')),
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text('Memory: ${snapshot.data?.memory?.toStringAsFixed(2)}%'),
|
||||
Text('CPU: ${snapshot.data?.cpu?.toStringAsFixed(2)}%'),
|
||||
Text('Disk: ${snapshot.data?.disk?.toStringAsFixed(2)}%'),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user