Compare commits

...

5 Commits

19 changed files with 380 additions and 326 deletions

View File

@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited.
version:
revision: "d211f42860350d914a5ad8102f9ec32764dc6d06"
revision: "db7ef5bf9f59442b0e200a90587e8fa5e0c6336a"
channel: "stable"
project_type: app
@ -13,11 +13,26 @@ project_type: app
migration:
platforms:
- platform: root
create_revision: d211f42860350d914a5ad8102f9ec32764dc6d06
base_revision: d211f42860350d914a5ad8102f9ec32764dc6d06
create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
- platform: android
create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
- platform: ios
create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
- platform: linux
create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
- platform: macos
create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
- platform: web
create_revision: d211f42860350d914a5ad8102f9ec32764dc6d06
base_revision: d211f42860350d914a5ad8102f9ec32764dc6d06
create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
- platform: windows
create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
# User provided section

58
lib/app/app_page.dart Normal file
View File

@ -0,0 +1,58 @@
import 'package:flutter/material.dart';
import 'package:pcast/components/nc_base_page.dart';
import 'package:routefly/routefly.dart';
import '../components/nc_button.dart';
Route routeBuilder(BuildContext ctx, RouteSettings settings) {
return PageRouteBuilder(
transitionDuration: const Duration(seconds: 5),
pageBuilder: (_, a1, a2) => const AppPage(),
transitionsBuilder: (_, a1, a2, child) {
return FadeTransition(
opacity: a1,
child: child,
);
},
);
}
class AppPage extends StatelessWidget {
const AppPage({super.key});
@override
Widget build(BuildContext context) {
return NcBasePage(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
NcButton(
width: MediaQuery.of(context).size.width * 0.6,
height: 100,
caption: "Quero testar a plataforma",
backgroundColor: Colors.black,
captionColor: Colors.white,
onPressed: () => {
Routefly.navigate('/test'),
},
),
const SizedBox(
height: 40,
),
NcButton(
width: MediaQuery.of(context).size.width * 0.6,
height: 100,
caption: "Já sou cliente",
backgroundColor: Colors.black,
captionColor: Colors.white,
onPressed: () => {
Routefly.navigate('/login'),
},
),
],
),
),
);
}
}

View File

@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:routefly/routefly.dart';
import '../routes.dart';
class AppWidget extends StatelessWidget {
const AppWidget({super.key});
@ -7,9 +9,9 @@ class AppWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp.router(
title: 'PCast Portal',
theme: ThemeData(primarySwatch: Colors.blue),
routerConfig: Modular.routerConfig,
routerConfig: Routefly.routerConfig(
routes: routes,
),
);
}
}

View File

@ -0,0 +1,63 @@
import 'package:flutter/material.dart';
import 'package:pcast/components/nc_base_page.dart';
import 'package:pcast/components/nc_button.dart';
import 'package:pcast/components/nc_text_field.dart';
import 'package:velocity_x/velocity_x.dart';
Route routeBuilder(BuildContext ctx, RouteSettings settings) {
return PageRouteBuilder(
transitionDuration: const Duration(seconds: 5),
pageBuilder: (_, a1, a2) => const LoginPage(),
transitionsBuilder: (_, a1, a2, child) {
return FadeTransition(
opacity: a1,
child: child,
);
},
);
}
class LoginPage extends StatefulWidget {
const LoginPage({super.key});
@override
State<LoginPage> createState() => _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
TextEditingController controller = TextEditingController();
@override
Widget build(BuildContext context) {
return NcBasePage(
body: Center(
child: SizedBox(
width: MediaQuery.of(context).size.width * 0.6,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
"Informe o seu email".text.white.italic.xl4.make(),
const SizedBox(
height: 40,
),
NCTextField(hintText: "Email", controller: controller),
const SizedBox(
height: 40,
),
NcButton(
width: 250,
height: 80,
caption: "Próximo",
backgroundColor: Colors.black,
captionColor: Colors.red,
onPressed: () => {
print(controller.text),
},
),
],
),
),
),
);
}
}

View File

@ -0,0 +1,44 @@
import 'package:flutter/material.dart';
import 'package:pcast/components/nc_base_page.dart';
Route routeBuilder(BuildContext ctx, RouteSettings settings) {
return PageRouteBuilder(
transitionDuration: const Duration(seconds: 5),
pageBuilder: (_, a1, a2) => const TestPage(),
transitionsBuilder: (_, a1, a2, child) {
return FadeTransition(
opacity: a1,
child: child,
);
},
);
}
class TestPage extends StatefulWidget {
const TestPage({super.key});
@override
State<TestPage> createState() => _TestPageState();
}
class _TestPageState extends State<TestPage> {
@override
Widget build(BuildContext context) {
return const NcBasePage(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Test Page",
style: TextStyle(
color: Colors.white,
fontSize: 40,
),
),
],
),
),
);
}
}

View File

@ -1,18 +0,0 @@
import 'package:dio/dio.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'pages/email_page.dart';
import 'pages/server_info_page.dart';
class AppModule extends Module {
@override
void binds(i) {
i.add(() => Dio());
}
@override
void routes(r) {
r.child('/', child: (context) => const EmailPage());
r.child('/serverinfo', child: (context) => const ServerInfoPage());
}
}

View File

@ -0,0 +1,22 @@
import 'package:flutter/material.dart';
import 'package:routefly/routefly.dart';
class NcBasePage extends StatelessWidget {
const NcBasePage({super.key, required this.body});
final Widget body;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xffa600f9),
body: body,
floatingActionButton: FloatingActionButton(
onPressed: () => {
Routefly.navigate('/'),
},
backgroundColor: Colors.white,
child: const Icon(Icons.home),
));
}
}

View File

@ -0,0 +1,41 @@
import 'package:flutter/material.dart';
import 'package:velocity_x/velocity_x.dart';
class NcButton extends StatelessWidget {
const NcButton({
super.key,
required this.caption,
required this.backgroundColor,
required this.captionColor,
this.onPressed,
this.width,
this.height,
});
final String caption;
final Color backgroundColor;
final Color captionColor;
final double? width;
final double? height;
final void Function()? onPressed;
@override
Widget build(BuildContext context) {
return SizedBox(
width: width,
height: height,
child: ElevatedButton(
onPressed: onPressed,
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(horizontal: 40, vertical: 20),
backgroundColor: Colors.black,
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
child: caption.text.xl4.make(),
),
);
}
}

View File

@ -0,0 +1,27 @@
import 'package:flutter/material.dart';
class NCTextField extends StatelessWidget {
const NCTextField({super.key, required this.hintText, required this.controller});
final String hintText;
final TextEditingController controller;
@override
Widget build(BuildContext context) {
return TextField(
controller: controller,
decoration: InputDecoration(
hintText: hintText,
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: const BorderSide(color: Colors.black),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: const BorderSide(color: Colors.black),
),
),
);
}
}

View File

@ -1,14 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'app_module.dart';
import 'app_widget.dart';
import 'app/app_widget.dart';
void main() {
return runApp(
ModularApp(
module: AppModule(),
child: const AppWidget(),
),
);
runApp(const AppWidget());
}

View File

@ -1,21 +0,0 @@
class MonitorModel {
double? memory;
double? cpu;
double? disk;
MonitorModel({this.memory, this.cpu, this.disk});
MonitorModel.fromJson(Map<String, dynamic> json) {
memory = json['memory'];
cpu = json['cpu'];
disk = json['disk'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['memory'] = memory;
data['cpu'] = cpu;
data['disk'] = disk;
return data;
}
}

View File

@ -1,72 +0,0 @@
class UserModel {
int? iD;
String? createdAt;
String? updatedAt;
String? deletedAt;
String? name;
String? companyname;
String? email;
String? phone;
String? channel;
String? url;
String? cpfcnpj;
String? usertype;
String? blocked;
String? cancelled;
int? serverid;
UserModel(
{this.iD,
this.createdAt,
this.updatedAt,
this.deletedAt,
this.name,
this.companyname,
this.email,
this.phone,
this.channel,
this.url,
this.cpfcnpj,
this.usertype,
this.blocked,
this.cancelled,
this.serverid});
UserModel.fromJson(Map<String, dynamic> json) {
iD = json['ID'];
createdAt = json['CreatedAt'];
updatedAt = json['UpdatedAt'];
deletedAt = json['DeletedAt'];
name = json['name'];
companyname = json['companyname'];
email = json['email'];
phone = json['phone'];
channel = json['channel'];
url = json['url'];
cpfcnpj = json['cpfcnpj'];
usertype = json['usertype'];
blocked = json['blocked'];
cancelled = json['cancelled'];
serverid = json['serverid'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['ID'] = iD;
data['CreatedAt'] = createdAt;
data['UpdatedAt'] = updatedAt;
data['DeletedAt'] = deletedAt;
data['name'] = name;
data['companyname'] = companyname;
data['email'] = email;
data['phone'] = phone;
data['channel'] = channel;
data['url'] = url;
data['cpfcnpj'] = cpfcnpj;
data['usertype'] = usertype;
data['blocked'] = blocked;
data['cancelled'] = cancelled;
data['serverid'] = serverid;
return data;
}
}

View File

@ -1,57 +0,0 @@
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),
),
),
],
),
),
),
);
}
}

View File

@ -1,71 +0,0 @@
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)}%'),
],
),
),
);
}
}
},
);
}
}

View File

@ -1,15 +0,0 @@
import 'package:dio/dio.dart';
import 'package:flutter_modular/flutter_modular.dart';
import '../models/user_model.dart';
class EmailRepository {
EmailRepository();
// Get email from the API
Future<UserModel> getEmail(String email) async {
final dio = Modular.get<Dio>();
final response = await dio.get('https://api.pcastlivetv.com/checkuser/$email');
return UserModel.fromJson(response.data);
}
}

41
lib/routes.dart Normal file
View File

@ -0,0 +1,41 @@
import 'package:routefly/routefly.dart';
import 'app/app_page.dart' as a0;
import 'app/login/login_page.dart' as a1;
import 'app/test/test_page.dart' as a2;
List<RouteEntity> get routes => [
RouteEntity(
key: '/',
uri: Uri.parse('/'),
routeBuilder: (ctx, settings) => Routefly.defaultRouteBuilder(
ctx,
settings,
const a0.AppPage(),
),
),
RouteEntity(
key: '/login',
uri: Uri.parse('/login'),
routeBuilder: (ctx, settings) => Routefly.defaultRouteBuilder(
ctx,
settings,
const a1.LoginPage(),
),
),
RouteEntity(
key: '/test',
uri: Uri.parse('/test'),
routeBuilder: (ctx, settings) => Routefly.defaultRouteBuilder(
ctx,
settings,
const a2.TestPage(),
),
),
];
const routePaths = (
path: '/',
login: '/login',
test: '/test',
);

View File

@ -1,5 +0,0 @@
class Utils {
static bool isValidEmail(String email) {
return RegExp(r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$').hasMatch(email);
}
}

View File

@ -1,6 +1,14 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
ansicolor:
dependency: transitive
description:
name: ansicolor
sha256: "8bf17a8ff6ea17499e40a2d2542c2f481cd7615760c6d34065cb22bfd22e6880"
url: "https://pub.dev"
source: hosted
version: "2.0.2"
async:
dependency: transitive
description:
@ -9,14 +17,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.11.0"
auto_injector:
auto_size_text_pk:
dependency: transitive
description:
name: auto_injector
sha256: "2952a4d4339ed3b65e8e54765ec68ee6ada5cb21d83cb8d39e3f6b4e690ab5ca"
name: auto_size_text_pk
sha256: ced55de5336fa7f438c1f5a9aa234e25d7a120c1d40d376a7cdc2af28cdb6995
url: "https://pub.dev"
source: hosted
version: "2.0.2"
version: "3.0.0"
boolean_selector:
dependency: transitive
description:
@ -49,14 +57,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.18.0"
crypto:
dependency: transitive
description:
name: crypto
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
url: "https://pub.dev"
source: hosted
version: "3.0.3"
cupertino_icons:
dependency: "direct main"
description:
@ -69,10 +69,10 @@ packages:
dependency: "direct main"
description:
name: dio
sha256: "417e2a6f9d83ab396ec38ff4ea5da6c254da71e4db765ad737a42af6930140b7"
sha256: "01870acd87986f768e0c09cc4d7a19a59d814af7b34cbeb0b437d2c33bdfea4c"
url: "https://pub.dev"
source: hosted
version: "5.3.3"
version: "5.3.4"
fake_async:
dependency: transitive
description:
@ -90,23 +90,20 @@ packages:
dependency: "direct dev"
description:
name: flutter_lints
sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04
sha256: e2a421b7e59244faef694ba7b30562e489c2b489866e505074eb005cd7060db7
url: "https://pub.dev"
source: hosted
version: "2.0.3"
flutter_modular:
dependency: "direct main"
description:
name: flutter_modular
sha256: ac6298ce1abd414286ee5a554fc45e81e358461979b5d4e02c8abd685e3b23f2
url: "https://pub.dev"
source: hosted
version: "6.3.2"
version: "3.0.1"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
http_parser:
dependency: transitive
description:
@ -115,14 +112,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.0.2"
intl:
dependency: transitive
description:
name: intl
sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d"
url: "https://pub.dev"
source: hosted
version: "0.18.1"
lints:
dependency: transitive
description:
name: lints
sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452"
sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "3.0.0"
matcher:
dependency: transitive
description:
@ -147,14 +152,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.10.0"
modular_core:
dependency: transitive
description:
name: modular_core
sha256: "5baaa460ac9d85d457d6864ef41a2194b8115a6bdeb585a684789f2d9004c892"
url: "https://pub.dev"
source: hosted
version: "3.3.2"
path:
dependency: transitive
description:
@ -163,14 +160,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.8.3"
result_dart:
dependency: transitive
routefly:
dependency: "direct main"
description:
name: result_dart
sha256: f28a171d55e2e1c1753b41d4d8edcaff886f103e73c575d14764913907e57928
name: routefly
sha256: a7c0f46de8ec6a26e11362f03bf69e97b6f45cfcbd2161cc31ee2a028d4bc22a
url: "https://pub.dev"
source: hosted
version: "1.1.0"
version: "1.0.5"
sky_engine:
dependency: transitive
description: flutter
@ -232,14 +229,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.2"
uuid:
dependency: transitive
description:
name: uuid
sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313"
url: "https://pub.dev"
source: hosted
version: "3.0.7"
vector_math:
dependency: transitive
description:
@ -248,6 +237,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
velocity_x:
dependency: "direct main"
description:
name: velocity_x
sha256: "38585b8ed87c17ccb42a5c13d55bdafdc65e7cd3f41dceb61c38714c758fa228"
url: "https://pub.dev"
source: hosted
version: "4.1.2"
vxstate:
dependency: transitive
description:
name: vxstate
sha256: ed5a880018191c5cfed8528bd77f2a942b04847168ca12636a306c323d311086
url: "https://pub.dev"
source: hosted
version: "2.3.0"
web:
dependency: transitive
description:
@ -258,3 +263,4 @@ packages:
version: "0.3.0"
sdks:
dart: ">=3.2.0-194.0.dev <4.0.0"
flutter: ">=3.13.0"

View File

@ -14,13 +14,14 @@ dependencies:
cupertino_icons: ^1.0.2
dio: ^5.3.3
flutter_modular: ^6.3.2
routefly: ^1.0.5
velocity_x: ^4.1.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
flutter_lints: ^3.0.1
flutter:
uses-material-design: true