Initial commit
This commit is contained in:
53
lib/client.dart
Normal file
53
lib/client.dart
Normal file
@ -0,0 +1,53 @@
|
||||
import 'dbhandler.dart';
|
||||
|
||||
class Client{
|
||||
final String name,
|
||||
telephone,
|
||||
cellular,
|
||||
observations;
|
||||
int id, status, enabled;
|
||||
Client(this.name, this.telephone, this.cellular, this.observations);
|
||||
|
||||
final dbHandler dbh = dbHandler.instance;
|
||||
|
||||
Client.fromJson(Map<String,dynamic> jsona)
|
||||
:id= int.tryParse(jsona['id'].toString()),
|
||||
name = jsona['name'],
|
||||
cellular = jsona['cellular'],
|
||||
telephone = jsona['telephone'],
|
||||
observations = jsona['observations'];
|
||||
|
||||
Map<String, dynamic> toJson() =>
|
||||
{
|
||||
'name':name,
|
||||
'cellular':cellular,
|
||||
'telephone':telephone,
|
||||
'observations':observations
|
||||
};
|
||||
|
||||
void SaveToDB() async
|
||||
{
|
||||
Future<int> t = dbh.insert(this.toJson(),"client");
|
||||
t.then((int value){
|
||||
this.id = value;
|
||||
return value;
|
||||
});
|
||||
}
|
||||
|
||||
Future<Client> LoadFromDB(int num) async{
|
||||
List<Map<String, dynamic>> eq = await dbh.queryByID("client", num);
|
||||
return Client.fromJson(eq[0]);
|
||||
}
|
||||
UpdateDB(int num)
|
||||
{
|
||||
dbh.update(this.toJson(), num, "client").then((value){
|
||||
status = 1;
|
||||
},onError: (object){
|
||||
status = 0;
|
||||
});
|
||||
}
|
||||
Future RemoveDB(int num) async
|
||||
{
|
||||
return await dbh.delete(num, "client");
|
||||
}
|
||||
}
|
147
lib/dbhandler.dart
Normal file
147
lib/dbhandler.dart
Normal file
@ -0,0 +1,147 @@
|
||||
import 'dart:io';
|
||||
import 'package:path/path.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
|
||||
class dbHandler{
|
||||
static final _dbname = "elec.db";
|
||||
static final _dbver = 1;
|
||||
|
||||
dbHandler._privateConstructor();
|
||||
static final dbHandler instance = dbHandler._privateConstructor();
|
||||
|
||||
static Database _db;
|
||||
|
||||
Future<Database> get database async{
|
||||
if(_db != null) return _db;
|
||||
_db = await _initDB();
|
||||
return _db;
|
||||
}
|
||||
|
||||
_initDB() async{
|
||||
Directory docsDirectory = await getApplicationDocumentsDirectory();
|
||||
String path = join(docsDirectory.path,_dbname);
|
||||
return await openDatabase(path,
|
||||
version: _dbver,
|
||||
onCreate: _onCreate
|
||||
);
|
||||
}
|
||||
|
||||
Future _onCreate(Database db, int version) async{
|
||||
Batch batch = db.batch();
|
||||
batch.execute(
|
||||
"CREATE TABLE IF NOT EXISTS client ( "
|
||||
"id INTEGER PRIMARY KEY, "
|
||||
"name TEXT NOT NULL, "
|
||||
"cellular TEXT, "
|
||||
"telephone TEXT, "
|
||||
"observations TEXT);"
|
||||
);
|
||||
batch.execute(
|
||||
"CREATE TABLE IF NOT EXISTS equipment ("
|
||||
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
|
||||
"client_id INTEGER NOT NULL,"
|
||||
"name TEXT NOT NULL,"
|
||||
"problem TEXT NOT NULL,"
|
||||
"observation TEXT NOT NULL,"
|
||||
"images TEXT,"
|
||||
"dateInput TEXT NOT NULL,"
|
||||
"dateExit TEXT,"
|
||||
"isDelivered BOOLEAN NOT NULL); "
|
||||
);
|
||||
batch.execute("CREATE TABLE IF NOT EXISTS repair("
|
||||
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
|
||||
"eq_id INTEGER NOT NULL,"
|
||||
"repair TEXT NOT NULL);"
|
||||
);
|
||||
batch.execute(
|
||||
"CREATE VIEW v_repair "
|
||||
"AS SELECT r.id as repair_id, "
|
||||
"eq.id as id, "
|
||||
"eq.name as name,"
|
||||
"r.repair as repair "
|
||||
"FROM repair r INNER JOIN equipment eq "
|
||||
"WHERE eq.id = r.eq_id"
|
||||
);
|
||||
batch.execute("CREATE VIEW v_equipment "
|
||||
"AS SELECT cli.id as client_id, "
|
||||
"cli.name as name, "
|
||||
"eq.id as id, "
|
||||
"eq.name as equipment, "
|
||||
"eq.problem as problem, "
|
||||
"eq.observation as observation, "
|
||||
"eq.images as images, "
|
||||
"eq.dateInput as dateInput, "
|
||||
"eq.dateExit as dateExit, "
|
||||
"eq.isDelivered as isDelivered "
|
||||
"FROM client cli INNER JOIN equipment eq "
|
||||
"WHERE cli.id = eq.client_id");
|
||||
List<dynamic> res = await batch.commit();
|
||||
}
|
||||
|
||||
Future<int> insert(Map<String,dynamic> row, String table) async
|
||||
{
|
||||
Database db = await instance.database;
|
||||
return await db.insert(table, row);
|
||||
}
|
||||
|
||||
Future<List<Map<String,dynamic>>> queryAllRows(String table) async{
|
||||
Database db = await instance.database;
|
||||
return await db.query(table);
|
||||
}
|
||||
|
||||
Future<List<Map<String,dynamic>>> queryOrdered(String table, String order, String val) async{
|
||||
Database db = await instance.database;
|
||||
return await db.query(table, orderBy: val+' '+order);
|
||||
}
|
||||
|
||||
Future<List<Map<String,dynamic>>> queryAllEquipment() async{
|
||||
Database db = await instance.database;
|
||||
return await db.query("v_equipment", orderBy: 'equipment ASC', where: 'isDelivered = 0');
|
||||
}
|
||||
|
||||
Future<List<Map<String,dynamic>>> queryAllEquipmentDelivered() async{
|
||||
Database db = await instance.database;
|
||||
return await db.query("v_equipment", orderBy: 'equipment ASC', where: 'isDelivered = 1');
|
||||
}
|
||||
|
||||
Future<List<Map<String,dynamic>>> queryRepair(String name) async{
|
||||
Database db = await instance.database;
|
||||
return await db.query("v_repair", where: 'name LIKE ?', whereArgs: ['%$name%'], orderBy: 'name ASC');
|
||||
}
|
||||
|
||||
Future<List<Map<String,dynamic>>> queryEquipment(String equipment) async{
|
||||
Database db = await instance.database;
|
||||
return await db.query("v_equipment", where: 'equipment LIKE ?', whereArgs: ['%$equipment%'], orderBy: 'equipment ASC');
|
||||
}
|
||||
|
||||
Future<List<Map<String,dynamic>>> queryClient(String name) async{
|
||||
Database db = await instance.database;
|
||||
return await db.query("client", where: 'name LIKE ?', whereArgs: ['%$name%'], orderBy: 'name ASC');
|
||||
}
|
||||
|
||||
Future<List<Map<String,dynamic>>> queryEquipmentClient(int client_id) async{
|
||||
Database db = await instance.database;
|
||||
return await db.query("v_equipment", where: 'client_id = ?', whereArgs: [client_id]);
|
||||
}
|
||||
|
||||
Future<List<Map<String,dynamic>>> queryByID(String table, int id) async {
|
||||
Database db = await instance.database;
|
||||
return await db.query(table, where: 'id = ?', whereArgs: [id]);
|
||||
}
|
||||
|
||||
Future<List<Map<String,dynamic>>> queryByName(String table, String name) async {
|
||||
Database db = await instance.database;
|
||||
return await db.query(table, where: 'name LIKE ?', whereArgs: ['%$name%']);
|
||||
}
|
||||
|
||||
Future<int> update(Map<String,dynamic> row, int id, String table) async{
|
||||
Database db = await instance.database;
|
||||
return await db.update(table,row, where: 'id = ?', whereArgs: [id]);
|
||||
}
|
||||
|
||||
Future<int> delete(int id, String table) async{
|
||||
Database db = await instance.database;
|
||||
return await db.delete(table, where: 'id = ?', whereArgs: [id]);
|
||||
}
|
||||
}
|
148
lib/electronic.dart
Normal file
148
lib/electronic.dart
Normal file
@ -0,0 +1,148 @@
|
||||
// Objetivo: Classe p/ guardar eletrônicos
|
||||
// Nome
|
||||
// Cliente (outra classe)
|
||||
// Descrição do problema
|
||||
// Observações
|
||||
// Data da Entrada
|
||||
// Data da Saída
|
||||
// Foto(s) do aparelho
|
||||
import 'dbhandler.dart';
|
||||
|
||||
class Repair{
|
||||
int id, status;
|
||||
final int eq_id;
|
||||
final repair;
|
||||
Repair(this.eq_id,this.repair);
|
||||
|
||||
final dbHandler dbh = dbHandler.instance;
|
||||
|
||||
Map<String,dynamic> toJson() =>{
|
||||
'eq_id': eq_id,
|
||||
'repair': repair
|
||||
};
|
||||
Repair.fromView(Map<String, dynamic> jsona)
|
||||
:
|
||||
id = jsona['repair_id'],
|
||||
eq_id = jsona['id'],
|
||||
repair = jsona['repair'];
|
||||
|
||||
Repair.fromJson(Map<String, dynamic> jsona)
|
||||
:
|
||||
eq_id = jsona['eq_id'],
|
||||
repair = jsona['repair'];
|
||||
|
||||
int SaveToDB() {
|
||||
Future<int> t = dbh.insert(this.toJson(), "repair");
|
||||
t.then((int value) {
|
||||
this.id = value;
|
||||
status = 1;
|
||||
},onError: (object){
|
||||
status = 0;
|
||||
});
|
||||
}
|
||||
|
||||
Future<Repair> LoadFromDB(int num) async {
|
||||
dbh.queryByID("repair", num).then((List<Map<String, dynamic>> value){
|
||||
return Repair.fromJson(value[0]);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
UpdateDB(int num) {
|
||||
dbh.update(this.toJson(), num, "repair").then((value){
|
||||
status = 1;
|
||||
},onError: (object){
|
||||
status = 0;
|
||||
});
|
||||
}
|
||||
|
||||
RemoveDB(int num) {
|
||||
dbh.delete(num, "repair").then((value){
|
||||
status = 1;
|
||||
}, onError: (object){
|
||||
status = 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class Equipment {
|
||||
int id, status;
|
||||
final int client_id;
|
||||
final String name, problem, observation;
|
||||
final DateTime dateInput;
|
||||
DateTime dateExit;
|
||||
List<String> images = [];
|
||||
int isDelivered = 0;
|
||||
Equipment(this.client_id, this.name, this.problem, this.observation,
|
||||
this.dateInput);
|
||||
|
||||
final dbHandler dbh = dbHandler.instance;
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'client_id': client_id,
|
||||
'name': name,
|
||||
'problem': problem,
|
||||
'observation': observation,
|
||||
'dateInput': dateInput.toString(),
|
||||
'dateExit': dateExit.toString(),
|
||||
'images': images.toString(),
|
||||
'isDelivered': isDelivered
|
||||
};
|
||||
|
||||
Equipment.fromJson(Map<String, dynamic> jsona)
|
||||
: id = jsona['id'],
|
||||
client_id = jsona['client_id'],
|
||||
name = jsona['name'],
|
||||
problem = jsona['problem'],
|
||||
observation = jsona['observation'],
|
||||
dateInput = DateTime.tryParse(jsona['dateInput']),
|
||||
dateExit = DateTime.tryParse(jsona['dateExit']),
|
||||
images = jsona['images'].toString().substring(1,jsona['images'].length-1).split(',').toList(),
|
||||
isDelivered = int.tryParse(jsona['isDelivered'].toString());
|
||||
|
||||
void AddImage(String image) {
|
||||
images.add(image);
|
||||
}
|
||||
|
||||
void AddImageAsRange(List<String> imageL) {
|
||||
images.addAll(imageL);
|
||||
}
|
||||
|
||||
void EquipmentLeave(DateTime time) {
|
||||
dateExit = time;
|
||||
isDelivered = 1;
|
||||
}
|
||||
|
||||
int SaveToDB() {
|
||||
Future<int> t = dbh.insert(this.toJson(), "equipment");
|
||||
t.then((int value) {
|
||||
this.id = value;
|
||||
status = 1;
|
||||
}, onError: (value) {
|
||||
status = 0;
|
||||
});
|
||||
}
|
||||
|
||||
Future<Equipment> LoadFromDB(int num) async {
|
||||
dbh.queryByID("equipment", num).then((List<Map<String, dynamic>> value){
|
||||
return Equipment.fromJson(value[0]);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
UpdateDB(int num) {
|
||||
dbh.update(this.toJson(), num, "equipment").then((value){
|
||||
status = 1;
|
||||
},onError: (object){
|
||||
status = 0;
|
||||
});
|
||||
}
|
||||
|
||||
RemoveDB(int num) {
|
||||
dbh.delete(num, "equipment").then((value){
|
||||
status = 1;
|
||||
}, onError: (object){
|
||||
status = 0;
|
||||
});
|
||||
}
|
||||
}
|
181
lib/listEquipmentMain.dart
Normal file
181
lib/listEquipmentMain.dart
Normal file
@ -0,0 +1,181 @@
|
||||
import 'package:esms_project/screens/listEquipment.dart';
|
||||
import 'package:esms_project/screens/listEquipmentByClient.dart';
|
||||
import 'package:esms_project/screens/listEquipmentByID.dart';
|
||||
import 'package:esms_project/screens/listEquipmentDelivered.dart';
|
||||
import 'package:esms_project/widgets/widget_button.dart';
|
||||
import 'package:esms_project/widgets/widget_input.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class listEquipmentMain extends StatefulWidget {
|
||||
@override
|
||||
_listEquipmentMainState createState() => _listEquipmentMainState();
|
||||
}
|
||||
// TODO: Tela pesquisar via cliente
|
||||
// Polir
|
||||
class _listEquipmentMainState extends State<listEquipmentMain> {
|
||||
final _formCli = GlobalKey<FormState>();
|
||||
final _formCli2 = GlobalKey<FormState>();
|
||||
TextEditingController input = TextEditingController();
|
||||
TextEditingController input2 = TextEditingController();
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(body: _layout());
|
||||
}
|
||||
|
||||
_layout() {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: Center(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Colors.black,
|
||||
fontSize: 30),
|
||||
text: "Listagem de Aparelhos")),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w300,
|
||||
color: Colors.black,
|
||||
fontSize: 20),
|
||||
text: "Selecione uma das opções abaixo.")),
|
||||
Divider(color: Colors.black38,),
|
||||
FractionallySizedBox(
|
||||
widthFactor: 0.7,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
BotaoCustom(
|
||||
"Por Cliente",
|
||||
onPressed: () => _modalInput("Digite um nome.",
|
||||
"Ex. José da Silva"),
|
||||
),
|
||||
BotaoCustom(
|
||||
"Por Número",
|
||||
onPressed: () => _modalInputID("Digite um número.",
|
||||
"Ex. 1123"),
|
||||
),
|
||||
BotaoCustom(
|
||||
"Aparelhos Entregues",
|
||||
onPressed: () => _goto(context, listEquipmentDelivered()),
|
||||
),
|
||||
BotaoCustom("Aparelhos em Aberto",
|
||||
onPressed: () => _goto(context, listEquipment()))
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
_goto(context, page) {
|
||||
setState(() {
|
||||
Navigator.of(context)
|
||||
.push(new MaterialPageRoute(builder: (context) => page));
|
||||
});
|
||||
}
|
||||
|
||||
_modalInputID(String label, String hint) {
|
||||
input.clear();
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (_) => SimpleDialog(
|
||||
contentPadding: EdgeInsets.all(20),
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Icon(Icons.search),
|
||||
Text("Filtro de Pesquisa"),
|
||||
],
|
||||
),
|
||||
Divider(color: Colors.black38),
|
||||
Form(key: _formCli, child: InputNumber(label, hint, controller: input)),
|
||||
Botoes(
|
||||
"Pesquisar",
|
||||
onPressed: () => _validateSearchID(),
|
||||
),
|
||||
Botoes(
|
||||
"Fechar",
|
||||
onPressed: () {
|
||||
Navigator.of(context, rootNavigator: true).pop('dialog');
|
||||
},
|
||||
)
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
_modalInput(String label, String hint) {
|
||||
input2.clear();
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (_) => SimpleDialog(
|
||||
contentPadding: EdgeInsets.all(20),
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Icon(Icons.search),
|
||||
Text("Filtro de Pesquisa"),
|
||||
],
|
||||
),
|
||||
Divider(color: Colors.black38),
|
||||
Form(key: _formCli2, child: InputValidado(label, hint, controller: input2)),
|
||||
Botoes(
|
||||
"Pesquisar",
|
||||
onPressed: () => _validateSearchClient(),
|
||||
),
|
||||
Botoes(
|
||||
"Fechar",
|
||||
onPressed: () {
|
||||
Navigator.of(context, rootNavigator: true).pop('dialog');
|
||||
},
|
||||
)
|
||||
],
|
||||
));
|
||||
}
|
||||
_validateSearchClient() {
|
||||
FocusScopeNode currentFocus = FocusScope.of(context);
|
||||
if (!currentFocus.hasPrimaryFocus) {
|
||||
currentFocus.unfocus();
|
||||
}
|
||||
setState(() {
|
||||
if (_formCli2.currentState.validate()) {
|
||||
if (input2 != null) {
|
||||
String name = input2.text;
|
||||
Navigator.of(context, rootNavigator: true).pop('dialog');
|
||||
Navigator.of(context).push(new MaterialPageRoute(
|
||||
builder: (context) => listEquipmentClient(
|
||||
clientName: name,
|
||||
)));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_validateSearchID() {
|
||||
FocusScopeNode currentFocus = FocusScope.of(context);
|
||||
if (!currentFocus.hasPrimaryFocus) {
|
||||
currentFocus.unfocus();
|
||||
}
|
||||
setState(() {
|
||||
if (_formCli.currentState.validate()) {
|
||||
if (input != null) {
|
||||
int goto = int.tryParse(input.text);
|
||||
input.clear();
|
||||
Navigator.of(context, rootNavigator: true).pop('dialog');
|
||||
Navigator.of(context).push(new MaterialPageRoute(
|
||||
builder: (context) => listEquipmentID(goto)));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
25
lib/main.dart
Normal file
25
lib/main.dart
Normal file
@ -0,0 +1,25 @@
|
||||
import 'package:esms_project/mainScreen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() {
|
||||
runApp(ESMSApp());
|
||||
}
|
||||
|
||||
class ESMSApp extends StatelessWidget {
|
||||
/* TODO: Consertos realizados em outros aparelhos parecidos? -- 01/06/2021, adicionado tabela
|
||||
TODO: Fazer telas relacionadas a tabela
|
||||
Vai pegar o nome do aparelho quando colocar data de entrega se o usuário quiser
|
||||
Pode deletar ou alterar informações de reparo*/
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'ESMS - Sistema para Técnicos em Eletrônica',
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: ThemeData(
|
||||
primarySwatch: Colors.red,
|
||||
),
|
||||
home: mainScreen(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
123
lib/mainScreen.dart
Normal file
123
lib/mainScreen.dart
Normal file
@ -0,0 +1,123 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:esms_project/listEquipmentMain.dart';
|
||||
import 'package:esms_project/screens/aboutESMS.dart';
|
||||
import 'package:esms_project/screens/createClient.dart';
|
||||
import 'package:esms_project/screens/createEquipment.dart';
|
||||
import 'package:esms_project/screens/listClients.dart';
|
||||
import 'package:esms_project/screens/listRepairs.dart';
|
||||
import 'package:esms_project/widgets/widget_button.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
class mainScreen extends StatefulWidget {
|
||||
@override
|
||||
_mainScreenState createState() => _mainScreenState();
|
||||
}
|
||||
|
||||
class _mainScreenState extends State<mainScreen> {
|
||||
String verNumber;
|
||||
int superCoolSecret = 0;
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
makeFolders();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(body: _layout());
|
||||
}
|
||||
|
||||
makeFolders() async {
|
||||
final _self = await getApplicationDocumentsDirectory();
|
||||
final _selfPictures = Directory('${_self.path}/Pictures');
|
||||
if (!await _selfPictures.exists()) {
|
||||
final _newFolder = await _selfPictures.create(recursive: true);
|
||||
}
|
||||
PackageInfo.fromPlatform().then((PackageInfo p) {
|
||||
verNumber = p.version;
|
||||
});
|
||||
}
|
||||
|
||||
_layout() {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: Center(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
InkWell(
|
||||
child: SizedBox(
|
||||
child: Column(
|
||||
children: [
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
color: Colors.black,
|
||||
fontSize: 100),
|
||||
text: "ESMS")),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Colors.black,
|
||||
fontSize: 12),
|
||||
text: "Eletronics Servicing Management System"),
|
||||
)
|
||||
],
|
||||
)),
|
||||
onTap: () {
|
||||
setState(() {
|
||||
if (superCoolSecret < 4) superCoolSecret++;
|
||||
});
|
||||
},
|
||||
highlightColor: Colors.transparent,
|
||||
splashColor: Colors.transparent,
|
||||
onLongPress: () {
|
||||
setState(() {
|
||||
if (superCoolSecret >= 4) _goto(context, AboutScr());
|
||||
});
|
||||
},
|
||||
),
|
||||
Divider(
|
||||
color: Colors.black38,
|
||||
),
|
||||
FractionallySizedBox(
|
||||
widthFactor: 0.7,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
BotaoCustom(
|
||||
"Cadastrar Cliente",
|
||||
onPressed: () => _goto(context, CreateClient()),
|
||||
),
|
||||
BotaoCustom("Cadastrar Aparelho",
|
||||
onPressed: () => _goto(context, CreateEquipment())),
|
||||
BotaoCustom("Ver Aparelhos",
|
||||
onPressed: () => _goto(context, listEquipmentMain())),
|
||||
BotaoCustom("Ver Clientes",
|
||||
onPressed: () => _goto(context, ListClients())),
|
||||
BotaoCustom("Ver Reparos",
|
||||
onPressed: () => _goto(context, ListRepairs())),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
_goto(context, page) {
|
||||
setState(() {
|
||||
Navigator.of(context)
|
||||
.push(new MaterialPageRoute(builder: (context) => page));
|
||||
});
|
||||
}
|
||||
}
|
144
lib/screens/aboutESMS.dart
Normal file
144
lib/screens/aboutESMS.dart
Normal file
@ -0,0 +1,144 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
class AboutScr extends StatefulWidget {
|
||||
@override
|
||||
_AboutScrState createState() => _AboutScrState();
|
||||
}
|
||||
|
||||
class _AboutScrState extends State<AboutScr> {
|
||||
PackageInfo p;
|
||||
String os;
|
||||
Future<bool> loaded;
|
||||
|
||||
Timer stuck;
|
||||
Future<bool> loadVals() async {
|
||||
if(Platform.isAndroid)
|
||||
os = "Android";
|
||||
else if(Platform.isIOS)
|
||||
os = "IOS";
|
||||
os += ' ${Platform.operatingSystemVersion}';
|
||||
|
||||
await PackageInfo.fromPlatform().then((value) {
|
||||
p = value;
|
||||
});
|
||||
return true && p != null;
|
||||
}
|
||||
|
||||
_reload() {
|
||||
stuck = Timer(Duration(seconds: 2), () {
|
||||
loaded = loadVals();
|
||||
stuck.cancel();
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
loaded = loadVals();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Sobre"),
|
||||
),
|
||||
body: _layout(),
|
||||
);
|
||||
}
|
||||
|
||||
_layout() {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: FutureBuilder<bool>(
|
||||
future: loaded,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting)
|
||||
return Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
else if (p != null) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 8,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w900,
|
||||
color: Colors.redAccent[700],
|
||||
fontSize: 12,
|
||||
letterSpacing: 10),
|
||||
text: "RELEASE ${p.version}",),
|
||||
),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
color: Colors.black,
|
||||
fontSize: 100),
|
||||
text: "ESMS"),
|
||||
),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Colors.black,
|
||||
fontSize: 12),
|
||||
text: "Eletronics Servicing Management System"),
|
||||
),
|
||||
Divider(
|
||||
color: Colors.black38,
|
||||
),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: Colors.black, fontSize: 20),
|
||||
text:
|
||||
"Informações da Versão"),
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.all(30),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Divider(color: Colors.transparent,),
|
||||
Text("Versão: ${p.version}"),
|
||||
Text("Número da Build: ${p.buildNumber}"),
|
||||
Text("Nome da Package: ${p.packageName}"),
|
||||
Text("Versão Dart: ${Platform.version.substring(0,Platform.version.lastIndexOf('(dev)'))}"),
|
||||
Text("Edição ${os}")
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
),
|
||||
Divider(color: Colors.transparent,),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Text("Desenvolvido por F. Raszeja, 2021")
|
||||
)
|
||||
],
|
||||
));
|
||||
}
|
||||
if (snapshot.data == false) {
|
||||
_reload();
|
||||
}
|
||||
return Container(
|
||||
child: Text("Oops!"),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
215
lib/screens/alterClient.dart
Normal file
215
lib/screens/alterClient.dart
Normal file
@ -0,0 +1,215 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:esms_project/client.dart';
|
||||
import 'package:esms_project/screens/listClients.dart';
|
||||
import 'package:esms_project/widgets/widget_button.dart';
|
||||
import 'package:esms_project/widgets/widget_input.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'clientDetail.dart';
|
||||
|
||||
class alterClient extends StatefulWidget {
|
||||
Client c;
|
||||
|
||||
alterClient(this.c);
|
||||
@override
|
||||
_alterClientState createState() => _alterClientState();
|
||||
}
|
||||
|
||||
class _alterClientState extends State<alterClient> {
|
||||
Timer d;
|
||||
final values = new List<TextEditingController>.generate(
|
||||
4, (_) => TextEditingController());
|
||||
final _formCli = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
values[0].text = widget.c.name;
|
||||
values[1].text = widget.c.telephone;
|
||||
values[2].text = widget.c.cellular;
|
||||
values[3].text = widget.c.observations;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void setState(fn) {
|
||||
if (mounted) {
|
||||
super.setState(fn);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Alterar Cliente"),
|
||||
),
|
||||
body: _layout());
|
||||
}
|
||||
|
||||
_layout() {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(20),
|
||||
height: double.infinity,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Form(
|
||||
key: _formCli,
|
||||
child: Column(
|
||||
children: [
|
||||
InputValidado(
|
||||
"Digite o nome do Cliente",
|
||||
"Ex. João da Silva",
|
||||
controller: values[0],
|
||||
),
|
||||
InputTextosPhone(
|
||||
"Digite um telefone",
|
||||
"Ex. (15) 1234-5678",
|
||||
controller: values[1],
|
||||
),
|
||||
InputTextosPhone(
|
||||
"Digite um celular",
|
||||
"Ex. (15) 991234-5678",
|
||||
controller: values[2],
|
||||
),
|
||||
InputTextos(
|
||||
"Observações:",
|
||||
"Ex. Tem (15) 99123-4567 como outro número celular",
|
||||
controller: values[3],
|
||||
),
|
||||
],
|
||||
)),
|
||||
Divider(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
Botoes(
|
||||
"Atualizar cliente",
|
||||
onPressed: _updateClient,
|
||||
),
|
||||
Botoes(
|
||||
"Remover cliente",
|
||||
onPressed: () {
|
||||
_removeClient();
|
||||
},
|
||||
)
|
||||
]
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
_updateClient() {
|
||||
setState(() {
|
||||
if (_formCli.currentState.validate()) {
|
||||
int temp = widget.c.id;
|
||||
widget.c = new Client(
|
||||
values[0].text,
|
||||
values[1].text,
|
||||
values[2].text,
|
||||
values[3].text,
|
||||
);
|
||||
widget.c.UpdateDB(temp);
|
||||
int StuckCount = 0;
|
||||
d = Timer(Duration(milliseconds: 300), () {
|
||||
if (widget.c.status == 1) {
|
||||
_showcontent(temp);
|
||||
StuckCount = 0;
|
||||
d.cancel();
|
||||
}
|
||||
else
|
||||
StuckCount++;
|
||||
});
|
||||
if (StuckCount >= 2)
|
||||
_displaySnackbar("Verifique os valores");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_displaySnackbar(String text) {
|
||||
setState(() {
|
||||
final snackBar =
|
||||
SnackBar(content: Text(text, style: TextStyle(fontSize: 16)));
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||
});
|
||||
}
|
||||
|
||||
void _showcontent(temp) {
|
||||
setState(() {
|
||||
showDialog(
|
||||
context: context, barrierDismissible: false, // user must tap button!
|
||||
|
||||
builder: (BuildContext context) {
|
||||
return new AlertDialog(
|
||||
title: new Text('Aviso'),
|
||||
content: new SingleChildScrollView(
|
||||
child: new ListBody(
|
||||
children: [
|
||||
new Text('Cliente atualizado.'),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
new TextButton(
|
||||
child: new Text('OK'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).popUntil((route) => route.isFirst);
|
||||
if(values[0].text == "CLIENTE_REMOVIDO")
|
||||
Navigator.of(context).push(new MaterialPageRoute(
|
||||
builder: (context) => ListClients()));
|
||||
else {
|
||||
Navigator.of(context).push(new MaterialPageRoute(
|
||||
builder: (context) => ListClients()));
|
||||
Navigator.of(context).push(new MaterialPageRoute(
|
||||
builder: (context) => ClientDetail(temp)));
|
||||
}
|
||||
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
_removeClient() {
|
||||
setState(() {
|
||||
showDialog(
|
||||
context: context, barrierDismissible: false, // user must tap button!
|
||||
|
||||
builder: (BuildContext context) {
|
||||
return new AlertDialog(
|
||||
title: new Text('Confirmação'),
|
||||
content: new SingleChildScrollView(
|
||||
child: new ListBody(
|
||||
children: [
|
||||
new Text('Tem certeza que quer remover o cliente ${widget.c
|
||||
.name}?'),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
new TextButton(
|
||||
child: new Text('Sim'),
|
||||
onPressed: () {
|
||||
values[0].text = "CLIENTE_REMOVIDO";
|
||||
values[1].text = "";
|
||||
values[2].text = "";
|
||||
values[3].text = "";
|
||||
_updateClient();
|
||||
|
||||
},
|
||||
),
|
||||
new TextButton(
|
||||
child: new Text('Não'),
|
||||
onPressed: () {
|
||||
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
364
lib/screens/alterEquipment.dart
Normal file
364
lib/screens/alterEquipment.dart
Normal file
@ -0,0 +1,364 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'package:esms_project/electronic.dart';
|
||||
import 'package:esms_project/screens/equipmentDetail.dart';
|
||||
import 'package:esms_project/widgets/widget_button.dart';
|
||||
import 'package:esms_project/widgets/widget_generate.dart';
|
||||
import 'package:esms_project/widgets/widget_input.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
class alterEquipment extends StatefulWidget {
|
||||
Equipment e;
|
||||
Repair r;
|
||||
alterEquipment(this.e, {this.r});
|
||||
@override
|
||||
_alterEquipmentState createState() => _alterEquipmentState();
|
||||
}
|
||||
|
||||
class _alterEquipmentState extends State<alterEquipment> {
|
||||
Timer d;
|
||||
final values = new List<TextEditingController>.generate(
|
||||
6, (_) => TextEditingController());
|
||||
final _formEq = new GlobalKey<FormState>();
|
||||
final _formRep = new GlobalKey<FormState>();
|
||||
File _image;
|
||||
|
||||
bool _writeRepair = false;
|
||||
List<String> imagens = [];
|
||||
@override
|
||||
void initState() {
|
||||
imagens = widget.e.images;
|
||||
values[0].text = widget.e.name;
|
||||
values[1].text = widget.e.problem;
|
||||
values[2].text = widget.e.observation;
|
||||
values[3].text = DateFormat.yMd().format(widget.e.dateInput);
|
||||
values[4].text = widget.e.dateExit == null
|
||||
? ""
|
||||
: DateFormat.yMd().format(widget.e.dateExit);
|
||||
if (widget.r != null) {
|
||||
values[5].text = widget.r.repair == null ? "" : widget.r.repair;
|
||||
_writeRepair = true;
|
||||
}
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void setState(fn) {
|
||||
if (mounted) {
|
||||
super.setState(fn);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Alterar Informações"),
|
||||
),
|
||||
body: _layout());
|
||||
}
|
||||
|
||||
_layout() {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(20),
|
||||
height: double.infinity,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 20,
|
||||
fontStyle: FontStyle.normal,
|
||||
fontWeight: FontWeight.w600),
|
||||
text: "Preencha este formulário com informações do aparelho.",
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Form(
|
||||
key: _formEq,
|
||||
child: Column(
|
||||
children: [
|
||||
InputValidado(
|
||||
"Nome do Aparelho",
|
||||
"Ex.: Radio XYZ",
|
||||
controller: values[0],
|
||||
),
|
||||
InputValidado(
|
||||
"Problema apresentado",
|
||||
"Ex.: Tela quebrada",
|
||||
controller: values[1],
|
||||
),
|
||||
InputTextos(
|
||||
"Observações",
|
||||
"Ex.: Vem com cabos",
|
||||
controller: values[2],
|
||||
),
|
||||
InputData(
|
||||
"Data de Entrada",
|
||||
"Ex. " + DateFormat.yMd().format(DateTime.now()),
|
||||
controller: values[3],
|
||||
),
|
||||
InputDataNoValidate(
|
||||
"Data de Saída",
|
||||
"Ex. " +
|
||||
DateFormat.yMd()
|
||||
.format(DateTime.now().add(Duration(days: 30))),
|
||||
controller: values[4],
|
||||
),
|
||||
],
|
||||
)),
|
||||
Divider(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 20,
|
||||
fontStyle: FontStyle.normal,
|
||||
fontWeight: FontWeight.w600),
|
||||
text: "Deseja registrar o reparo?",
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Radio(
|
||||
groupValue: _writeRepair,
|
||||
value: true,
|
||||
onChanged: _onChangeRepair,
|
||||
),
|
||||
Text("Sim", style: TextStyle(fontSize: 18)),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Radio(
|
||||
groupValue: _writeRepair,
|
||||
value: false,
|
||||
onChanged: _onChangeRepair,
|
||||
),
|
||||
Text("Não", style: TextStyle(fontSize: 18)),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
_Repair(),
|
||||
Divider(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
Botoes(
|
||||
"Atualizar Aparelho",
|
||||
onPressed: _update,
|
||||
),
|
||||
if (imagens != null && imagens.length <= 10)
|
||||
Botoes(
|
||||
"Tire uma foto!",
|
||||
onPressed: _snapPic,
|
||||
),
|
||||
if (imagens[0].isNotEmpty)
|
||||
Text("Você tirou " + imagens.length.toString() + " fotos."),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
bool _ValidateInputs() {
|
||||
setState(() {});
|
||||
return widget.e != null && _formEq.currentState.validate();
|
||||
}
|
||||
|
||||
bool _ValidateRepair() {
|
||||
setState(() {});
|
||||
return _writeRepair && _formRep.currentState.validate();
|
||||
}
|
||||
|
||||
_Repair() {
|
||||
return _writeRepair
|
||||
? Container(
|
||||
child: Form(
|
||||
key: _formRep,
|
||||
child: Column(
|
||||
children: [
|
||||
InputValidado(
|
||||
"Reparo realizado",
|
||||
"Troca de peça X, Y, Z",
|
||||
controller: values[5],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: Container();
|
||||
}
|
||||
|
||||
_onChangeRepair(bool value) {
|
||||
setState(() {
|
||||
_writeRepair = value;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _snapPic() async {
|
||||
if (_ValidateInputs()) {
|
||||
Directory dir = await getApplicationDocumentsDirectory();
|
||||
final imagem = await ImagePicker().getImage(source: ImageSource.camera);
|
||||
|
||||
if (imagem != null) {
|
||||
setState(() {
|
||||
_image = File(imagem.path);
|
||||
});
|
||||
final fileName = StringGenerator().getRandomString(10) + ".jpg";
|
||||
final savedImage =
|
||||
await File(_image.path).copy('${dir.path}/Pictures/$fileName');
|
||||
|
||||
if (savedImage != null) {
|
||||
if (imagens[0].isEmpty)
|
||||
imagens[0] = fileName;
|
||||
else
|
||||
imagens.add(fileName);
|
||||
_displaySnackbar("Foto adicionada com sucesso.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_displaySnackbar("Verifique os campos.");
|
||||
}
|
||||
}
|
||||
|
||||
_displaySnackbar(String text) {
|
||||
setState(() {
|
||||
final snackBar =
|
||||
SnackBar(content: Text(text, style: TextStyle(fontSize: 16)));
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||
});
|
||||
}
|
||||
|
||||
_update() {
|
||||
setState(() {
|
||||
if(!_writeRepair && widget.r != null) {
|
||||
_deleteRepair(widget.r.id);
|
||||
}
|
||||
else if(_writeRepair || widget.r == null){
|
||||
_updateSt2();
|
||||
}
|
||||
});
|
||||
}
|
||||
_updateSt2()
|
||||
{
|
||||
if (_ValidateInputs()) {
|
||||
int tmp = widget.e.id;
|
||||
int tmp2 = widget.e.client_id;
|
||||
widget.e = new Equipment(
|
||||
tmp2,
|
||||
values[0].text,
|
||||
values[1].text,
|
||||
values[2].text,
|
||||
DateFormat.yMd().parse(values[3].text),
|
||||
);
|
||||
widget.e.id = tmp;
|
||||
if (values[4].text.isNotEmpty)
|
||||
widget.e.EquipmentLeave(DateFormat.yMd().parse(values[4].text));
|
||||
widget.e.images = imagens;
|
||||
widget.e.UpdateDB(tmp);
|
||||
if (_ValidateRepair()) {
|
||||
if (widget.r == null) {
|
||||
widget.r = new Repair(tmp, values[5].text);
|
||||
widget.r.SaveToDB();
|
||||
} else {
|
||||
int tmp3 = widget.r.id;
|
||||
widget.r = new Repair(tmp, values[5].text);
|
||||
widget.r.UpdateDB(tmp3);
|
||||
}
|
||||
}
|
||||
int TryCount = 0;
|
||||
d = Timer(Duration(milliseconds: 200), () {
|
||||
if ((!_writeRepair && widget.e.status == 1) || (widget.r.status == 1 && widget.e.status == 1)) {
|
||||
TryCount = 0;
|
||||
_showcontent(tmp);
|
||||
d.cancel();
|
||||
} else
|
||||
TryCount++;
|
||||
});
|
||||
if (TryCount >= 2) _displaySnackbar("Erro na operação.");
|
||||
}
|
||||
}
|
||||
void _deleteRepair(temp)
|
||||
{
|
||||
setState(() {
|
||||
showDialog(
|
||||
context: context, barrierDismissible: false, // user must tap button!
|
||||
|
||||
builder: (BuildContext context) {
|
||||
return new AlertDialog(
|
||||
title: new Text('Aviso'),
|
||||
content: new SingleChildScrollView(
|
||||
child: new ListBody(
|
||||
children: [
|
||||
new Text('Deseja remover informações sobre reparo?'),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
new TextButton(
|
||||
child: new Text('Sim'),
|
||||
onPressed: () {
|
||||
widget.r.RemoveDB(temp);
|
||||
_updateSt2();
|
||||
Navigator.of(context, rootNavigator: true).pop('dialog');
|
||||
},
|
||||
),
|
||||
new TextButton(
|
||||
child: new Text('Não'),
|
||||
onPressed: () {
|
||||
_updateSt2();
|
||||
Navigator.of(context, rootNavigator: true).pop('dialog');
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
void _showcontent(temp) {
|
||||
setState(() {
|
||||
showDialog(
|
||||
context: context, barrierDismissible: false, // user must tap button!
|
||||
|
||||
builder: (BuildContext context) {
|
||||
return new AlertDialog(
|
||||
title: new Text('Aviso'),
|
||||
content: new SingleChildScrollView(
|
||||
child: new ListBody(
|
||||
children: [
|
||||
new Text('Equipamento atualizado.'),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
new TextButton(
|
||||
child: new Text('OK'),
|
||||
onPressed: () {
|
||||
int count = 0;
|
||||
Navigator.of(context).popUntil((_) => count++ >= 2);
|
||||
Navigator.of(context).pushReplacement(new MaterialPageRoute(
|
||||
builder: (context) => EquipmentDetail(temp)));
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
200
lib/screens/clientDetail.dart
Normal file
200
lib/screens/clientDetail.dart
Normal file
@ -0,0 +1,200 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:esms_project/dbhandler.dart';
|
||||
import 'package:esms_project/client.dart';
|
||||
import 'package:esms_project/screens/alterClient.dart';
|
||||
import 'package:esms_project/widgets/widget_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import 'listEquipmentByClient.dart';
|
||||
|
||||
class ClientDetail extends StatefulWidget {
|
||||
final int id;
|
||||
ClientDetail(this.id);
|
||||
|
||||
@override
|
||||
_ClientDetailState createState() => _ClientDetailState();
|
||||
}
|
||||
|
||||
class _ClientDetailState extends State<ClientDetail> {
|
||||
final dbHandler dbh = dbHandler.instance;
|
||||
Future<bool> loaded;
|
||||
Timer stuck;
|
||||
Client cli;
|
||||
|
||||
Future<bool> _loadvars() async {
|
||||
Future<List<Map<String, dynamic>>> tmp = dbh.queryByID("client", widget.id);
|
||||
tmp.then((List<Map<String, dynamic>> value) {
|
||||
cli = Client.fromJson(value[0]);
|
||||
});
|
||||
return true && cli != null;
|
||||
}
|
||||
|
||||
@override
|
||||
void setState(fn) {
|
||||
if(mounted) {
|
||||
super.setState(fn);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
loaded = _loadvars();
|
||||
}
|
||||
|
||||
_reload() {
|
||||
stuck = Timer(Duration(seconds: 2), () {
|
||||
loaded = _loadvars();
|
||||
stuck.cancel();
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Detalhes do Cliente"),
|
||||
),
|
||||
body: _layout(),
|
||||
);
|
||||
}
|
||||
|
||||
_layout() {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(30),
|
||||
child: FutureBuilder<bool>(
|
||||
future: loaded,
|
||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done &&
|
||||
cli != null) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Card(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
ListTile(
|
||||
leading: const Icon(Icons.account_circle),
|
||||
title: RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
strutStyle: StrutStyle(fontSize: 16.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: Colors.black, fontSize: 16),
|
||||
text: cli.name)),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.phone),
|
||||
title: RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
strutStyle: StrutStyle(fontSize: 12.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: Colors.black, fontSize: 16),
|
||||
text: "Telefone: ${cli.telephone}",
|
||||
),
|
||||
),
|
||||
onTap: () =>
|
||||
_launchUrl("tel:${cli.telephone}")),
|
||||
ListTile(
|
||||
leading: Icon(Icons.phone_android),
|
||||
title: RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
strutStyle: StrutStyle(fontSize: 12.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: Colors.black, fontSize: 16),
|
||||
text: "Celular: ${cli.cellular}")),
|
||||
onTap: () => _launchUrl("tel:${cli.cellular}")),
|
||||
ListTile(
|
||||
leading: Icon(Icons.notes),
|
||||
title: RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
strutStyle: StrutStyle(fontSize: 12.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: Colors.black, fontSize: 16),
|
||||
text:
|
||||
"Observações: ${cli.observations}")),
|
||||
onTap: () => _modal(
|
||||
cli.observations, "Observações", Icons.notes),
|
||||
),
|
||||
]),
|
||||
),
|
||||
Botoes(
|
||||
"Alterar",
|
||||
onPressed: _update,
|
||||
),
|
||||
Botoes(
|
||||
"Ver Aparelhos",
|
||||
onPressed: () => _list(cli.id),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
if (snapshot.data == false) {
|
||||
_reload();
|
||||
}
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [CircularProgressIndicator(), Text("Carregando.")],
|
||||
),
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
_modal(String value, String type, IconData icon) {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (_) => SimpleDialog(
|
||||
contentPadding: EdgeInsets.all(20),
|
||||
semanticLabel: type,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Icon(icon),
|
||||
Text(type),
|
||||
],
|
||||
),
|
||||
Divider(color: Colors.black38),
|
||||
RichText(
|
||||
strutStyle: StrutStyle(fontSize: 12.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(color: Colors.black, fontSize: 16),
|
||||
text: value)),
|
||||
Botoes(
|
||||
"Fechar",
|
||||
onPressed: () {
|
||||
Navigator.of(context, rootNavigator: true).pop('dialog');
|
||||
},
|
||||
)
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
_launchUrl(String url) async {
|
||||
await canLaunch(url) ? await launch(url) : print("Uh-oh!");
|
||||
}
|
||||
|
||||
_update() {
|
||||
Navigator.of(context)
|
||||
.push(new MaterialPageRoute(builder: (context) => alterClient(cli)))
|
||||
.whenComplete(_reload);
|
||||
}
|
||||
|
||||
_list(int id) {
|
||||
setState(() {
|
||||
Navigator.of(context)
|
||||
.push(new MaterialPageRoute(builder: (context) => listEquipmentClient(id_client: widget.id,)))
|
||||
.whenComplete(_loadvars);
|
||||
});
|
||||
}
|
||||
}
|
103
lib/screens/createClient.dart
Normal file
103
lib/screens/createClient.dart
Normal file
@ -0,0 +1,103 @@
|
||||
import 'package:esms_project/client.dart';
|
||||
import 'package:esms_project/screens/listClients.dart';
|
||||
import 'package:esms_project/widgets/widget_button.dart';
|
||||
import 'package:esms_project/widgets/widget_input.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
class CreateClient extends StatefulWidget {
|
||||
@override
|
||||
_CreateClientState createState() => _CreateClientState();
|
||||
}
|
||||
|
||||
class _CreateClientState extends State<CreateClient> {
|
||||
final values = new List<TextEditingController>.generate(
|
||||
4, (_) => TextEditingController());
|
||||
Client c;
|
||||
final _formCli = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
void setState(fn) {
|
||||
if(mounted) {
|
||||
super.setState(fn);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Adicionar Cliente"),
|
||||
),
|
||||
body: _layout());
|
||||
}
|
||||
_layout() {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(20),
|
||||
height: double.infinity,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Form(
|
||||
key: _formCli,
|
||||
child: Column(
|
||||
children: [
|
||||
InputValidado(
|
||||
"Digite o nome do Cliente",
|
||||
"Ex. João da Silva",
|
||||
controller: values[0],
|
||||
),
|
||||
InputTextosPhone(
|
||||
"Digite um telefone",
|
||||
"Ex. (15) 1234-5678",
|
||||
controller: values[1],
|
||||
),
|
||||
InputTextosPhone(
|
||||
"Digite um celular",
|
||||
"Ex. (15) 991234-5678",
|
||||
controller: values[2],
|
||||
),
|
||||
InputTextos(
|
||||
"Observações:",
|
||||
"Ex. Tem (15) 99123-4567 como outro número celular",
|
||||
controller: values[3],
|
||||
),
|
||||
],
|
||||
)),
|
||||
Divider(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
Botoes(
|
||||
"Cadastrar cliente",
|
||||
onPressed: _addClient,
|
||||
)
|
||||
]
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
_addClient() {
|
||||
setState(() {
|
||||
if (_formCli.currentState.validate()) {
|
||||
c = new Client(
|
||||
values[0].text, values[1].text, values[2].text, values[3].text);
|
||||
c.SaveToDB();
|
||||
if (c.id != null || c.id != 0) {
|
||||
_displaySnackbar("Cliente cadastrado.");
|
||||
Navigator.pushReplacement(
|
||||
context, MaterialPageRoute(builder: (context) => ListClients()));
|
||||
} else {
|
||||
_displaySnackbar("Erro no cadastro.");
|
||||
}
|
||||
} else {
|
||||
_displaySnackbar("Verifique o cadastro!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_displaySnackbar(String text) {
|
||||
setState(() {
|
||||
final snackBar =
|
||||
SnackBar(content: Text(text, style: TextStyle(fontSize: 16)));
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||
});
|
||||
}
|
||||
}
|
360
lib/screens/createEquipment.dart
Normal file
360
lib/screens/createEquipment.dart
Normal file
@ -0,0 +1,360 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:esms_project/client.dart';
|
||||
import 'package:esms_project/dbhandler.dart';
|
||||
import 'package:esms_project/electronic.dart';
|
||||
import 'package:esms_project/mainScreen.dart';
|
||||
import 'package:esms_project/widgets/widget_button.dart';
|
||||
import 'package:esms_project/widgets/widget_generate.dart';
|
||||
import 'package:esms_project/widgets/widget_input.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
class CreateEquipment extends StatefulWidget {
|
||||
Client c;
|
||||
CreateEquipment({this.c});
|
||||
@override
|
||||
_CreateEquipmentState createState() => _CreateEquipmentState();
|
||||
}
|
||||
|
||||
class _CreateEquipmentState extends State<CreateEquipment> {
|
||||
final values = new List<TextEditingController>.generate(
|
||||
9, (_) => TextEditingController());
|
||||
List<String> imagens = [];
|
||||
List<Map<String, dynamic>> clients;
|
||||
Client c;
|
||||
bool _client = true;
|
||||
bool _justregistered = false;
|
||||
File _image;
|
||||
final _formEq = GlobalKey<FormState>();
|
||||
final _formCli = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
void setState(fn) {
|
||||
if(mounted) {
|
||||
super.setState(fn);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
c = widget.c == null? null: widget.c;
|
||||
if(c != null)
|
||||
{
|
||||
_client = true;
|
||||
_justregistered = true;
|
||||
values[3].text = c.name;
|
||||
}
|
||||
super.initState();
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Adicionar Aparelho"),
|
||||
),
|
||||
body: _layout());
|
||||
}
|
||||
|
||||
_layout() {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(20),
|
||||
height: double.infinity,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 20,
|
||||
fontStyle: FontStyle.normal,
|
||||
fontWeight: FontWeight.w600),
|
||||
text: "Preencha este formulário com informações do aparelho.",
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Form(
|
||||
key: _formEq,
|
||||
child: Column(
|
||||
children: [
|
||||
InputValidado(
|
||||
"Nome do Aparelho",
|
||||
"Ex.: Radio XYZ",
|
||||
controller: values[0],
|
||||
),
|
||||
InputValidado(
|
||||
"Problema apresentado",
|
||||
"Ex.: Tela quebrada",
|
||||
controller: values[1],
|
||||
),
|
||||
InputTextos(
|
||||
"Observações",
|
||||
"Ex.: Vem com cabos",
|
||||
controller: values[2],
|
||||
),
|
||||
InputData(
|
||||
"Data de Entrada",
|
||||
"Ex. " + DateFormat.yMd().format(DateTime.now()),
|
||||
controller: values[8],
|
||||
)
|
||||
],
|
||||
)),
|
||||
Divider(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 20,
|
||||
fontStyle: FontStyle.normal,
|
||||
fontWeight: FontWeight.w600),
|
||||
text: "O cliente ja é cadastrado?",
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Radio(
|
||||
groupValue: _client,
|
||||
value: true,
|
||||
onChanged: _onChangeClient,
|
||||
),
|
||||
Text("Sim", style: TextStyle(fontSize: 18)),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Radio(
|
||||
groupValue: _client,
|
||||
value: false,
|
||||
onChanged: _onChangeClient,
|
||||
),
|
||||
Text("Não", style: TextStyle(fontSize: 18)),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
Divider(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
_clientCheck(),
|
||||
Divider(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
if (_justregistered == true)
|
||||
Column(
|
||||
children: [
|
||||
Botoes(
|
||||
"Cadastrar Aparelho",
|
||||
onPressed: _addEquipment,
|
||||
),
|
||||
if (imagens != null && imagens.length <= 10)
|
||||
Botoes(
|
||||
"Tire uma foto!",
|
||||
onPressed: _snapPic,
|
||||
),
|
||||
],
|
||||
),
|
||||
if (imagens != null && imagens.length > 0)
|
||||
Text("Você tirou " + imagens.length.toString() + " fotos.")
|
||||
],
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
_onChangeClient(bool value) {
|
||||
setState(() {
|
||||
_client = value;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _GetClient() async {
|
||||
if (values[3] != null && values[3].text.isNotEmpty) {
|
||||
clients = await dbHandler.instance.queryByName("client", values[3].text);
|
||||
List<Map<String,dynamic>> temp = List.empty(growable: true);
|
||||
setState(() {
|
||||
if (clients != null) {
|
||||
for (int i = 0; i < clients.length; i++) {
|
||||
if (clients[i]['name'] != 'CLIENTE_REMOVIDO')
|
||||
temp.add(clients[i]);
|
||||
}
|
||||
clients = temp;
|
||||
}
|
||||
FocusScope.of(context).unfocus();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
_clientCheck() {
|
||||
return _client
|
||||
? Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: InputTextos(
|
||||
"Buscar por nome",
|
||||
"Ex. João da Silva",
|
||||
controller: values[3],
|
||||
)),
|
||||
IconButton(onPressed: _GetClient, icon: Icon(Icons.search))
|
||||
],
|
||||
),
|
||||
if (clients != null)
|
||||
for (int i = 0; i < clients.length; i++)
|
||||
Column(
|
||||
children: [
|
||||
Divider(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(children: [
|
||||
Icon(Icons.account_circle_rounded),
|
||||
Text(
|
||||
" Cliente: " + clients[i]['name'].toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w300,
|
||||
),
|
||||
),
|
||||
]),
|
||||
Botoes("Selecionar", onPressed: () => _loadCli(i))
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
: Column(
|
||||
children: [
|
||||
Form(
|
||||
key: _formCli,
|
||||
child: Column(
|
||||
children: [
|
||||
InputValidado(
|
||||
"Digite o nome do Cliente",
|
||||
"Ex. João da Silva",
|
||||
controller: values[4],
|
||||
),
|
||||
InputTextosPhone(
|
||||
"Digite um telefone",
|
||||
"Ex. (15) 1234-5678",
|
||||
controller: values[5],
|
||||
),
|
||||
InputTextosPhone(
|
||||
"Digite um celular",
|
||||
"Ex. (15) 991234-5678",
|
||||
controller: values[6],
|
||||
),
|
||||
InputTextos(
|
||||
"Observações:",
|
||||
"Ex. Tem (15) 99123-4567 como outro número celular",
|
||||
controller: values[7],
|
||||
),
|
||||
],
|
||||
)),
|
||||
Divider(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
Botoes(
|
||||
"Cadastrar cliente",
|
||||
onPressed: _addClient,
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
_addClient() {
|
||||
setState(() {
|
||||
if (_formCli.currentState.validate()) {
|
||||
_client = true;
|
||||
c = new Client(
|
||||
values[4].text, values[5].text, values[6].text, values[7].text);
|
||||
c.SaveToDB();
|
||||
if (c.id != null || c.id != 0) {
|
||||
values[3].text = values[4].text;
|
||||
_displaySnackbar("Cliente cadastrado.");
|
||||
_justregistered = true;
|
||||
} else {
|
||||
_displaySnackbar("Erro no cadastro.");
|
||||
}
|
||||
} else {
|
||||
_displaySnackbar("Verifique o cadastro!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
bool _ValidateInputs() {
|
||||
setState(() {});
|
||||
return _formEq.currentState.validate() && c != null;
|
||||
}
|
||||
|
||||
Future<void> _snapPic() async {
|
||||
if (_ValidateInputs()) {
|
||||
Directory dir = await getApplicationDocumentsDirectory();
|
||||
final imagem = await ImagePicker().getImage(source: ImageSource.camera);
|
||||
|
||||
if (imagem != null) {
|
||||
setState(() {
|
||||
_image = File(imagem.path);
|
||||
});
|
||||
|
||||
final fileName = StringGenerator().getRandomString(10) + ".jpg";
|
||||
final savedImage = await File(imagem.path).copy(
|
||||
'${dir.path}/Pictures/$fileName');
|
||||
if(savedImage != null) {
|
||||
imagens.add(fileName);
|
||||
_displaySnackbar("Foto adicionada com sucesso.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_displaySnackbar(String text) {
|
||||
setState(() {
|
||||
final snackBar =
|
||||
SnackBar(content: Text(text, style: TextStyle(fontSize: 16)));
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||
});
|
||||
}
|
||||
|
||||
_addEquipment() {
|
||||
setState(() {
|
||||
if (_formEq.currentState.validate()) {
|
||||
Equipment e = new Equipment(
|
||||
c.id,
|
||||
values[0].text,
|
||||
values[1].text,
|
||||
values[2].text,
|
||||
DateFormat.yMd().parse(values[8].text),
|
||||
);
|
||||
e.AddImageAsRange(imagens);
|
||||
|
||||
if (e.SaveToDB() == 1) {
|
||||
_displaySnackbar("Erro no cadastro!");
|
||||
} else {
|
||||
_displaySnackbar("Cadastrado com sucesso.");
|
||||
Navigator.of(context).pushReplacement(new MaterialPageRoute(builder: (context) => mainScreen()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_loadCli(int index) {
|
||||
setState(() {
|
||||
values[3].text = clients[index]['name'].toString();
|
||||
c = Client.fromJson(clients[index]);
|
||||
clients = null;
|
||||
_justregistered = true;
|
||||
});
|
||||
}
|
||||
}
|
288
lib/screens/equipmentDetail.dart
Normal file
288
lib/screens/equipmentDetail.dart
Normal file
@ -0,0 +1,288 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:esms_project/dbhandler.dart';
|
||||
import 'package:esms_project/electronic.dart';
|
||||
import 'package:esms_project/widgets/widget_button.dart';
|
||||
import 'package:esms_project/widgets/widget_caroussel.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'alterEquipment.dart';
|
||||
|
||||
class EquipmentDetail extends StatefulWidget {
|
||||
final int id;
|
||||
EquipmentDetail(this.id);
|
||||
|
||||
@override
|
||||
_EquipmentDetailState createState() => _EquipmentDetailState();
|
||||
}
|
||||
|
||||
class _EquipmentDetailState extends State<EquipmentDetail> {
|
||||
final dbHandler dbh = dbHandler.instance;
|
||||
Future<bool> loaded;
|
||||
Timer stuck, d;
|
||||
bool openProblem = false;
|
||||
bool openObservation = false;
|
||||
Equipment eq;
|
||||
Repair r;
|
||||
Future<bool> _loadvars() async {
|
||||
dbh
|
||||
.queryByID("equipment", widget.id)
|
||||
.then((List<Map<String, dynamic>> value) {
|
||||
eq = Equipment.fromJson(value[0]);
|
||||
});
|
||||
dbh
|
||||
.queryByID("v_repair", widget.id)
|
||||
.then((List<Map<String, dynamic>> value) {
|
||||
r = Repair.fromView(value[0]);
|
||||
});
|
||||
|
||||
return true && eq != null;
|
||||
}
|
||||
|
||||
_reload() {
|
||||
stuck = Timer(Duration(seconds: 2), () {
|
||||
loaded = _loadvars();
|
||||
stuck.cancel();
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void setState(fn) {
|
||||
if (mounted) {
|
||||
super.setState(fn);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
loaded = _loadvars();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Detalhes do Aparelho"),
|
||||
),
|
||||
body: _layout(),
|
||||
);
|
||||
}
|
||||
|
||||
_layout() {
|
||||
return Container(
|
||||
margin: EdgeInsets.all(10),
|
||||
child: FutureBuilder<bool>(
|
||||
future: loaded,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done &&
|
||||
eq != null) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Card(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
ListTile(
|
||||
title: RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
strutStyle: StrutStyle(fontSize: 16.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: Colors.black, fontSize: 16),
|
||||
text: "N°" + eq.id.toString())),
|
||||
),
|
||||
RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
strutStyle: StrutStyle(fontSize: 16.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: Colors.black, fontSize: 16),
|
||||
text: eq.name)),
|
||||
Divider(color: Colors.black38),
|
||||
Column(children: [
|
||||
if (eq.images.length > 0)
|
||||
eq.images[0].isNotEmpty
|
||||
? SizedBox(
|
||||
height: 270,
|
||||
child: Caroussel(eq.images))
|
||||
: SizedBox(
|
||||
height: 170,
|
||||
child: Center(
|
||||
child: RichText(
|
||||
strutStyle:
|
||||
StrutStyle(fontSize: 30.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: Colors.black26,
|
||||
fontSize: 30,
|
||||
fontWeight:
|
||||
FontWeight.w300,
|
||||
fontStyle:
|
||||
FontStyle.italic),
|
||||
text: "Sem Imagem")),
|
||||
)),
|
||||
]),
|
||||
Divider(color: Colors.black38),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.warning),
|
||||
title: RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
strutStyle: StrutStyle(fontSize: 12.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: Colors.black, fontSize: 16),
|
||||
text: "Problema : " + '${eq.problem}',
|
||||
),
|
||||
),
|
||||
onTap: () => _modal('${eq.problem}', "Problema",
|
||||
Icons.warning_amber_outlined),
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.info),
|
||||
title: RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
strutStyle: StrutStyle(fontSize: 12.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: Colors.black, fontSize: 16),
|
||||
text: "Observações : " +
|
||||
'${eq.observation}')),
|
||||
onTap: () => _modal('${eq.observation}',
|
||||
"Observações", Icons.info_outline),
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.calendar_today),
|
||||
title: Text("Data de Entrada: " +
|
||||
'${DateFormat.yMMMd().format(eq.dateInput)}'),
|
||||
),
|
||||
_Eval(),
|
||||
Divider(color: Colors.black38),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Botoes(
|
||||
"Alterar",
|
||||
onPressed: _update,
|
||||
),
|
||||
Botoes(
|
||||
"Remover",
|
||||
onPressed: _remove,
|
||||
)
|
||||
],
|
||||
),
|
||||
Divider(color: Colors.transparent),
|
||||
]),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
if (snapshot.data == false) {
|
||||
_reload();
|
||||
}
|
||||
return Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
_Eval() {
|
||||
return eq.dateExit != null
|
||||
? ListTile(
|
||||
leading: Icon(Icons.calendar_today_outlined),
|
||||
title: Text("Data de Entrega: " +
|
||||
'${DateFormat.yMMMd().format(eq.dateExit)}'))
|
||||
: Container(width: 0, height: 0);
|
||||
}
|
||||
|
||||
_update() {
|
||||
setState(() {
|
||||
Navigator.of(context)
|
||||
.push(new MaterialPageRoute(
|
||||
builder: (context) => alterEquipment(eq, r: r)))
|
||||
.whenComplete(_reload);
|
||||
});
|
||||
}
|
||||
|
||||
_remove() {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (_) => SimpleDialog(
|
||||
contentPadding: EdgeInsets.all(20),
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Icon(Icons.warning_amber_outlined),
|
||||
Text("Confirmação de Ação")
|
||||
],
|
||||
),
|
||||
Divider(color: Colors.black38),
|
||||
RichText(
|
||||
strutStyle: StrutStyle(fontSize: 12.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(color: Colors.black, fontSize: 16),
|
||||
text: "Deseja realmente remover ${eq.name}?")
|
||||
),
|
||||
Divider(color: Colors.transparent),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Botoes("Sim", onPressed: (){
|
||||
eq.RemoveDB(eq.id);
|
||||
if(r != null)
|
||||
r.RemoveDB(r.id);
|
||||
d = Timer(Duration(milliseconds: 200), ()
|
||||
{
|
||||
if ((r != null && r.status == 1 && eq.status == 1) ||
|
||||
(r == null && eq.status == 1)) {
|
||||
d.cancel();
|
||||
int count = 0;
|
||||
Navigator.of(context).popUntil((_) => count++ >= 2);
|
||||
}
|
||||
});
|
||||
/**/
|
||||
},),
|
||||
Botoes("Não", onPressed: (){
|
||||
Navigator.of(context, rootNavigator: true).pop('dialog');
|
||||
},)
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
_modal(String value, String type, IconData icon) {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (_) => SimpleDialog(
|
||||
contentPadding: EdgeInsets.all(20),
|
||||
semanticLabel: type,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Icon(icon),
|
||||
Text(type),
|
||||
],
|
||||
),
|
||||
Divider(color: Colors.black38),
|
||||
RichText(
|
||||
strutStyle: StrutStyle(fontSize: 12.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(color: Colors.black, fontSize: 16),
|
||||
text: value)),
|
||||
Botoes(
|
||||
"Fechar",
|
||||
onPressed: () {
|
||||
Navigator.of(context, rootNavigator: true).pop('dialog');
|
||||
},
|
||||
)
|
||||
],
|
||||
));
|
||||
}
|
||||
}
|
210
lib/screens/listClients.dart
Normal file
210
lib/screens/listClients.dart
Normal file
@ -0,0 +1,210 @@
|
||||
import 'package:esms_project/dbhandler.dart';
|
||||
import 'package:esms_project/screens/clientDetail.dart';
|
||||
import 'package:esms_project/screens/createClient.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:esms_project/widgets/widget_button.dart';
|
||||
|
||||
class ListClients extends StatefulWidget {
|
||||
@override
|
||||
_ListClientsState createState() => _ListClientsState();
|
||||
}
|
||||
|
||||
class _ListClientsState extends State<ListClients> {
|
||||
final dbHandler dbh = dbHandler.instance;
|
||||
Future<bool> loaded;
|
||||
List<Map<String, dynamic>> cliList = List.empty(growable: true);
|
||||
|
||||
Future<bool> _loadvars() async {
|
||||
cliList = List.empty(growable: true);
|
||||
dbh.queryOrdered("client", "ASC", "name").then((value) {
|
||||
List<Map<String,dynamic>> tmp = value;
|
||||
for(int i = 0; i < tmp.length; i++)
|
||||
{
|
||||
if(tmp[i]['name'] != "CLIENTE_REMOVIDO")
|
||||
{
|
||||
cliList.add(tmp[i]);
|
||||
}
|
||||
}
|
||||
setState(() {
|
||||
return true && cliList != null;
|
||||
});
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
void setState(fn) {
|
||||
if(mounted) {
|
||||
super.setState(fn);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
loaded = _loadvars();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Listagem de Clientes"),
|
||||
actions: <Widget>[
|
||||
IconButton(
|
||||
icon: Icon(Icons.add_box_outlined),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
Navigator.of(context)
|
||||
.push(new MaterialPageRoute(
|
||||
builder: (context) => CreateClient()))
|
||||
.whenComplete(_loadvars);
|
||||
});
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
body: _body(),
|
||||
);
|
||||
}
|
||||
|
||||
_body() {
|
||||
return Container(
|
||||
child: FutureBuilder<bool>(
|
||||
future: loaded,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting)
|
||||
return Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
else if (cliList != null && cliList.length != 0) {
|
||||
return ListView.separated(
|
||||
padding: const EdgeInsets.all(8),
|
||||
itemCount: cliList.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
height: 90,
|
||||
color: Colors.black12,
|
||||
child: InkWell(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
strutStyle: StrutStyle(fontSize: 18.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(color: Colors.black, fontSize: 18.0),
|
||||
text: "Cliente: " +
|
||||
'${cliList[index]['name']}')),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
strutStyle: StrutStyle(fontSize: 18.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(color: Colors.black, fontSize: 18.0),
|
||||
text: "Celular: " +
|
||||
'${cliList[index]['cellular']}'))
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
onTap: () =>
|
||||
onPressWithArg(context, cliList[index]['id']),
|
||||
));
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) =>
|
||||
const Divider());
|
||||
} else {
|
||||
return Container(
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
RichText(
|
||||
strutStyle: StrutStyle(
|
||||
fontSize: 32.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 32.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Colors.black26),
|
||||
text: "Estou vazio!"),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
RichText(
|
||||
strutStyle: StrutStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Colors.black26),
|
||||
text:
|
||||
"Cadastre um cliente clicando no botão "),
|
||||
),
|
||||
Icon(
|
||||
Icons.add_box_outlined,
|
||||
color: Colors.black26,
|
||||
),
|
||||
]),
|
||||
RichText(
|
||||
strutStyle: StrutStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Colors.black26),
|
||||
text: "\nOu tente recarregar a tela."),
|
||||
),
|
||||
Botoes(
|
||||
"Recarregar",
|
||||
onPressed: () => _update(context),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
)));
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_update(BuildContext context) {
|
||||
setState(() {
|
||||
Navigator.pushReplacement(
|
||||
context, MaterialPageRoute(builder: (context) => ListClients()));
|
||||
});
|
||||
}
|
||||
|
||||
onPressWithArg(context, int id) {
|
||||
setState(() {
|
||||
Navigator.of(context)
|
||||
.push(new MaterialPageRoute(builder: (context) => ClientDetail(id)))
|
||||
.whenComplete(_loadvars);
|
||||
});
|
||||
}
|
||||
}
|
236
lib/screens/listEquipment.dart
Normal file
236
lib/screens/listEquipment.dart
Normal file
@ -0,0 +1,236 @@
|
||||
import 'package:esms_project/dbhandler.dart';
|
||||
import 'package:esms_project/screens/createEquipment.dart';
|
||||
import 'package:esms_project/screens/equipmentDetail.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:esms_project/electronic.dart';
|
||||
import 'package:esms_project/widgets/widget_button.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class listEquipment extends StatefulWidget {
|
||||
@override
|
||||
_listEquipmentState createState() => _listEquipmentState();
|
||||
}
|
||||
|
||||
class _listEquipmentState extends State<listEquipment> {
|
||||
final dbHandler dbh = dbHandler.instance;
|
||||
Future<bool> loaded;
|
||||
List<Map<String, dynamic>> eqList;
|
||||
|
||||
Future<bool> _loadvars() async {
|
||||
dbh.queryAllEquipment().then((value) {
|
||||
eqList = value;
|
||||
setState(() {
|
||||
return true && eqList != null;
|
||||
});
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
void setState(fn) {
|
||||
if(mounted) {
|
||||
super.setState(fn);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
loaded = _loadvars();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Aparelhos para Conserto"),
|
||||
actions: <Widget>[
|
||||
IconButton(
|
||||
onPressed: () => _addItem(context),
|
||||
icon: Icon(Icons.add_box_outlined))
|
||||
],
|
||||
),
|
||||
body: _body(),
|
||||
);
|
||||
}
|
||||
|
||||
_body() {
|
||||
return Container(
|
||||
child: FutureBuilder<bool>(
|
||||
future: loaded,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting)
|
||||
return Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
else if (eqList != null && eqList.length != 0) {
|
||||
return ListView.separated(
|
||||
padding: const EdgeInsets.all(8),
|
||||
itemCount: eqList.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
height: 90,
|
||||
color: Colors.black12,
|
||||
child: InkWell(
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceEvenly,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 18.0),
|
||||
text:
|
||||
"Aparelho: "+'${eqList[index]['equipment']}'))),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
strutStyle:
|
||||
StrutStyle(fontSize: 16.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: Colors.black),
|
||||
text: "Cliente: " +
|
||||
'${eqList[index]['name']}'))),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
strutStyle:
|
||||
StrutStyle(fontSize: 16.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: Colors.black),
|
||||
text: "Data: " +
|
||||
'${DateFormat.yMd().format(DateTime.tryParse(eqList[index]['dateInput']))}'))),
|
||||
],
|
||||
),
|
||||
]),
|
||||
),
|
||||
onTap: () => onPressWithArg(
|
||||
context,
|
||||
eqList[index]['id'],
|
||||
)));
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) =>
|
||||
const Divider());
|
||||
} else {
|
||||
return Container(
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
RichText(
|
||||
strutStyle: StrutStyle(
|
||||
fontSize: 32.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 32.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Colors.black26),
|
||||
text: "Estou vazio!"),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
RichText(
|
||||
strutStyle: StrutStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Colors.black26),
|
||||
text:
|
||||
"Cadastre um aparelho clicando no botão "),
|
||||
),
|
||||
Icon(
|
||||
Icons.add_box_outlined,
|
||||
color: Colors.black26,
|
||||
),
|
||||
]),
|
||||
RichText(
|
||||
strutStyle: StrutStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Colors.black26),
|
||||
text: "\nOu tente recarregar a tela."),
|
||||
),
|
||||
Botoes(
|
||||
"Recarregar",
|
||||
onPressed: () => _update(context),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
)));
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_update(ctx) {
|
||||
setState(() {
|
||||
Navigator.pushReplacement(
|
||||
ctx, MaterialPageRoute(builder: (context) => listEquipment()));
|
||||
});
|
||||
}
|
||||
|
||||
//
|
||||
void load(int arg) async {
|
||||
Equipment t = new Equipment(0, "", "", "", DateTime.now());
|
||||
t = await t.LoadFromDB(arg);
|
||||
}
|
||||
|
||||
void onPressWithArg(ctx, int id) {
|
||||
setState(() {
|
||||
Navigator.of(ctx)
|
||||
.push(
|
||||
new MaterialPageRoute(builder: (context) => EquipmentDetail(id)))
|
||||
.whenComplete(_loadvars);
|
||||
});
|
||||
}
|
||||
|
||||
_addItem(ctx) {
|
||||
setState(() {
|
||||
Navigator.of(ctx)
|
||||
.push(new MaterialPageRoute(builder: (context) => CreateEquipment()))
|
||||
.whenComplete(_loadvars);
|
||||
});
|
||||
}
|
||||
}
|
283
lib/screens/listEquipmentByClient.dart
Normal file
283
lib/screens/listEquipmentByClient.dart
Normal file
@ -0,0 +1,283 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:esms_project/client.dart';
|
||||
import 'package:esms_project/dbhandler.dart';
|
||||
import 'package:esms_project/screens/createEquipment.dart';
|
||||
import 'package:esms_project/screens/equipmentDetail.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:esms_project/electronic.dart';
|
||||
import 'package:esms_project/widgets/widget_button.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class listEquipmentClient extends StatefulWidget {
|
||||
int id_client;
|
||||
String clientName;
|
||||
listEquipmentClient({this.id_client,this.clientName});
|
||||
@override
|
||||
_listEquipmentClientState createState() => _listEquipmentClientState();
|
||||
}
|
||||
|
||||
class _listEquipmentClientState extends State<listEquipmentClient> {
|
||||
final dbHandler dbh = dbHandler.instance;
|
||||
Future<bool> loaded;
|
||||
List<Map<String, dynamic>> eqList;
|
||||
Client c;
|
||||
int count = 0;
|
||||
Timer stuck;
|
||||
Future<bool> _loadvars() async {
|
||||
if(widget.id_client!=null) {
|
||||
dbh.queryByID("client", widget.id_client).then((value) {
|
||||
c = Client.fromJson(value[0]);
|
||||
});
|
||||
widget.clientName = null;
|
||||
dbh.queryEquipmentClient(widget.id_client).then((value) {
|
||||
eqList = value;
|
||||
});
|
||||
}
|
||||
if(widget.clientName != null)
|
||||
{
|
||||
widget.id_client = null;
|
||||
dbh.queryByName("v_equipment", widget.clientName).then((value) {
|
||||
eqList = value;
|
||||
});
|
||||
}
|
||||
setState(() {
|
||||
return true && eqList != null;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void setState(fn) {
|
||||
if(mounted) {
|
||||
super.setState(fn);
|
||||
}
|
||||
}
|
||||
|
||||
_reload() {
|
||||
if(count < 2)
|
||||
stuck = Timer(Duration(seconds: 1), () {
|
||||
if(eqList == null)
|
||||
loaded = _loadvars();
|
||||
stuck.cancel();
|
||||
count++;
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
loaded = _loadvars();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Resultados da Pesquisa"),
|
||||
actions: <Widget>[
|
||||
if(widget.id_client != null)
|
||||
IconButton(
|
||||
onPressed: () => _addItem(context),
|
||||
icon: Icon(Icons.add_box_outlined))
|
||||
],
|
||||
),
|
||||
body: _body(),
|
||||
);
|
||||
}
|
||||
|
||||
_body() {
|
||||
return Container(
|
||||
child: FutureBuilder<bool>(
|
||||
future: loaded,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting)
|
||||
return Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
else if (eqList != null && eqList.length > 0) {
|
||||
return ListView.separated(
|
||||
padding: const EdgeInsets.all(8),
|
||||
itemCount: eqList.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
height: 90,
|
||||
color: Colors.black12,
|
||||
child: InkWell(
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 18.0),
|
||||
text:
|
||||
'${eqList[index]['equipment']}'))),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
strutStyle:
|
||||
StrutStyle(fontSize: 18.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 18.0),
|
||||
text:
|
||||
'${eqList[index]['problem']}'))),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
strutStyle:
|
||||
StrutStyle(fontSize: 16.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: Colors.black),
|
||||
text: "Data: " +
|
||||
'${DateFormat.yMd().format(DateTime.tryParse(eqList[index]['dateInput']))}'))),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
strutStyle:
|
||||
StrutStyle(fontSize: 16.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: Colors.black),
|
||||
text: "Cliente: "+eqList[index]['name'])
|
||||
)
|
||||
)
|
||||
],
|
||||
),
|
||||
]),
|
||||
),
|
||||
onTap: () => onPressWithArg(
|
||||
context,
|
||||
eqList[index]['id'],
|
||||
)));
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) =>
|
||||
const Divider());
|
||||
}
|
||||
if (snapshot.data == null) {
|
||||
_reload();
|
||||
}
|
||||
return Container(
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
RichText(
|
||||
strutStyle: StrutStyle(
|
||||
fontSize: 32.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 32.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Colors.black26),
|
||||
text: "Estou vazio!"),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
RichText(
|
||||
strutStyle: StrutStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Colors.black26),
|
||||
text:
|
||||
"Cadastre um aparelho clicando no botão "),
|
||||
),
|
||||
Icon(
|
||||
Icons.add_box_outlined,
|
||||
color: Colors.black26,
|
||||
),
|
||||
]),
|
||||
RichText(
|
||||
strutStyle: StrutStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Colors.black26),
|
||||
text: "\nOu tente recarregar a tela."),
|
||||
),
|
||||
Botoes(
|
||||
"Recarregar",
|
||||
onPressed: () => _update(context),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
)));
|
||||
}
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_update(ctx) {
|
||||
setState(() {
|
||||
Navigator.pushReplacement(
|
||||
ctx,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => listEquipmentClient(id_client: widget.id_client, clientName: widget.clientName,)));
|
||||
});
|
||||
}
|
||||
|
||||
//
|
||||
void load(int arg) async {
|
||||
Equipment t = new Equipment(0, "", "", "", DateTime.now());
|
||||
t = await t.LoadFromDB(arg);
|
||||
}
|
||||
|
||||
void onPressWithArg(ctx, int id) {
|
||||
setState(() {
|
||||
Navigator.of(ctx)
|
||||
.push(
|
||||
new MaterialPageRoute(builder: (context) => EquipmentDetail(id)))
|
||||
.whenComplete(_loadvars);
|
||||
});
|
||||
}
|
||||
|
||||
_addItem(ctx) {
|
||||
setState(() {
|
||||
Navigator.of(ctx)
|
||||
.push(new MaterialPageRoute(builder: (context) => CreateEquipment(c: c)))
|
||||
.whenComplete(_loadvars);
|
||||
});
|
||||
}
|
||||
}
|
236
lib/screens/listEquipmentByID.dart
Normal file
236
lib/screens/listEquipmentByID.dart
Normal file
@ -0,0 +1,236 @@
|
||||
import 'package:esms_project/dbhandler.dart';
|
||||
import 'package:esms_project/screens/equipmentDetail.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:esms_project/electronic.dart';
|
||||
import 'package:esms_project/widgets/widget_button.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class listEquipmentID extends StatefulWidget {
|
||||
final int id;
|
||||
|
||||
listEquipmentID(this.id);
|
||||
@override
|
||||
_listEquipmentIDState createState() => _listEquipmentIDState();
|
||||
}
|
||||
|
||||
class _listEquipmentIDState extends State<listEquipmentID> {
|
||||
final dbHandler dbh = dbHandler.instance;
|
||||
Future<bool> loaded;
|
||||
List<Map<String, dynamic>> eqList;
|
||||
|
||||
Future<bool> _loadvars() async {
|
||||
dbh.queryByID("v_equipment", widget.id).then((value) {
|
||||
eqList = value;
|
||||
setState(() {
|
||||
return true && eqList != null;
|
||||
});
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
void setState(fn) {
|
||||
if(mounted) {
|
||||
super.setState(fn);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
loaded = _loadvars();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Resultados da Pesquisa"),
|
||||
),
|
||||
body: _body(),
|
||||
);
|
||||
}
|
||||
|
||||
_body() {
|
||||
return Container(
|
||||
child: FutureBuilder<bool>(
|
||||
future: loaded,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting)
|
||||
return Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
else if (eqList != null && eqList.length != 0) {
|
||||
return ListView.separated(
|
||||
padding: const EdgeInsets.all(8),
|
||||
itemCount: eqList.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
height: 90,
|
||||
color: Colors.black12,
|
||||
child: InkWell(
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 18.0),
|
||||
text: "Aparelho: " +
|
||||
'${eqList[index]['equipment']}'))),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
strutStyle:
|
||||
StrutStyle(fontSize: 16.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: Colors.black),
|
||||
text: "Cliente: " +
|
||||
'${eqList[index]['name']}'))),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
strutStyle:
|
||||
StrutStyle(fontSize: 16.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: Colors.black),
|
||||
text: "Entrada: " +
|
||||
'${DateFormat.yMd().format(DateTime.tryParse(eqList[index]['dateInput']))}'))),
|
||||
if (eqList != null && DateTime.tryParse(eqList[index]['dateExit']) != null)
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
strutStyle:
|
||||
StrutStyle(fontSize: 16.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: Colors.black),
|
||||
text: "Saída: " +
|
||||
'${DateFormat.yMd().format(DateTime.tryParse(eqList[index]['dateExit']))}')))
|
||||
],
|
||||
),
|
||||
]),
|
||||
),
|
||||
onTap: () => onPressWithArg(
|
||||
context,
|
||||
eqList[index]['id'],
|
||||
)));
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) =>
|
||||
const Divider());
|
||||
} else {
|
||||
return Container(
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
RichText(
|
||||
strutStyle: StrutStyle(
|
||||
fontSize: 32.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 32.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Colors.black26),
|
||||
text: "Estou vazio!"),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
RichText(
|
||||
strutStyle: StrutStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Colors.black26),
|
||||
text:
|
||||
"Cadastre um aparelho clicando no botão "),
|
||||
),
|
||||
Icon(
|
||||
Icons.add_box_outlined,
|
||||
color: Colors.black26,
|
||||
),
|
||||
]),
|
||||
RichText(
|
||||
strutStyle: StrutStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Colors.black26),
|
||||
text: "\nOu tente recarregar a tela."),
|
||||
),
|
||||
Botoes(
|
||||
"Recarregar",
|
||||
onPressed: () => _update(context),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
)));
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_update(ctx) {
|
||||
setState(() {
|
||||
Navigator.pushReplacement(ctx,
|
||||
MaterialPageRoute(builder: (context) => listEquipmentID(widget.id)));
|
||||
});
|
||||
}
|
||||
|
||||
//
|
||||
void load(int arg) async {
|
||||
Equipment t = new Equipment(0, "", "", "", DateTime.now());
|
||||
t = await t.LoadFromDB(arg);
|
||||
}
|
||||
|
||||
void onPressWithArg(ctx, int id) {
|
||||
setState(() {
|
||||
Navigator.of(ctx)
|
||||
.push(
|
||||
new MaterialPageRoute(builder: (context) => EquipmentDetail(id)))
|
||||
.whenComplete(_loadvars);
|
||||
});
|
||||
}
|
||||
}
|
228
lib/screens/listEquipmentDelivered.dart
Normal file
228
lib/screens/listEquipmentDelivered.dart
Normal file
@ -0,0 +1,228 @@
|
||||
import 'package:esms_project/dbhandler.dart';
|
||||
import 'package:esms_project/screens/equipmentDetail.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:esms_project/electronic.dart';
|
||||
import 'package:esms_project/widgets/widget_button.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class listEquipmentDelivered extends StatefulWidget {
|
||||
@override
|
||||
_listEquipmentDeliveredState createState() => _listEquipmentDeliveredState();
|
||||
}
|
||||
|
||||
class _listEquipmentDeliveredState extends State<listEquipmentDelivered> {
|
||||
final dbHandler dbh = dbHandler.instance;
|
||||
Future<bool> loaded;
|
||||
List<Map<String, dynamic>> eqList;
|
||||
|
||||
Future<bool> _loadvars() async {
|
||||
dbh.queryAllEquipmentDelivered().then((value) {
|
||||
eqList = value;
|
||||
setState(() {
|
||||
return true && eqList != null;
|
||||
});
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
void setState(fn) {
|
||||
if(mounted) {
|
||||
super.setState(fn);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
loaded = _loadvars();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Aparelhos Entregues"),
|
||||
),
|
||||
body: _body(),
|
||||
);
|
||||
}
|
||||
|
||||
_body() {
|
||||
return Container(
|
||||
child: FutureBuilder<bool>(
|
||||
future: loaded,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting)
|
||||
return Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
else if (eqList != null && eqList.length != 0) {
|
||||
return ListView.separated(
|
||||
padding: const EdgeInsets.all(8),
|
||||
itemCount: eqList.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
height: 90,
|
||||
color: Colors.black12,
|
||||
child: InkWell(
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 18.0),
|
||||
text:
|
||||
"Aparelho: "+'${eqList[index]['equipment']}'))),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
strutStyle:
|
||||
StrutStyle(fontSize: 16.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: Colors.black),
|
||||
text: "Cliente: " +
|
||||
'${eqList[index]['name']}'))),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
strutStyle:
|
||||
StrutStyle(fontSize: 16.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: Colors.black),
|
||||
text: "Entrada: " +
|
||||
'${DateFormat.yMd().format(DateTime.tryParse(eqList[index]['dateInput']))}'))),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
strutStyle:
|
||||
StrutStyle(fontSize: 16.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: Colors.black),
|
||||
text: "Entrega: " +
|
||||
'${DateFormat.yMd().format(DateTime.tryParse(eqList[index]['dateExit']))}')))
|
||||
],
|
||||
),
|
||||
]),
|
||||
),
|
||||
onTap: () => onPressWithArg(
|
||||
context,
|
||||
eqList[index]['id'],
|
||||
)));
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) =>
|
||||
const Divider());
|
||||
} else {
|
||||
return Container(
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
RichText(
|
||||
strutStyle: StrutStyle(
|
||||
fontSize: 32.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 32.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Colors.black26),
|
||||
text: "Estou vazio!"),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
RichText(
|
||||
strutStyle: StrutStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Colors.black26),
|
||||
text:
|
||||
"Nenhum aparelho entregue até o momento."),
|
||||
),
|
||||
]),
|
||||
RichText(
|
||||
strutStyle: StrutStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Colors.black26),
|
||||
text: "\nTente recarregar a tela."),
|
||||
),
|
||||
Botoes(
|
||||
"Recarregar",
|
||||
onPressed: () => _update(context),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
)));
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_update(ctx) {
|
||||
setState(() {
|
||||
Navigator.pushReplacement(
|
||||
ctx, MaterialPageRoute(builder: (context) => listEquipmentDelivered()));
|
||||
});
|
||||
}
|
||||
|
||||
//
|
||||
void load(int arg) async {
|
||||
Equipment t = new Equipment(0, "", "", "", DateTime.now());
|
||||
t = await t.LoadFromDB(arg);
|
||||
}
|
||||
|
||||
void onPressWithArg(ctx, int id) {
|
||||
setState(() {
|
||||
Navigator.of(ctx)
|
||||
.push(
|
||||
new MaterialPageRoute(builder: (context) => EquipmentDetail(id)))
|
||||
.whenComplete(_loadvars);
|
||||
});
|
||||
}
|
||||
}
|
260
lib/screens/listRepairs.dart
Normal file
260
lib/screens/listRepairs.dart
Normal file
@ -0,0 +1,260 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:esms_project/dbhandler.dart';
|
||||
import 'package:esms_project/screens/equipmentDetail.dart';
|
||||
import 'package:esms_project/widgets/widget_button.dart';
|
||||
import 'package:esms_project/widgets/widget_input.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../electronic.dart';
|
||||
|
||||
class ListRepairs extends StatefulWidget {
|
||||
@override
|
||||
_ListRepairsState createState() => _ListRepairsState();
|
||||
}
|
||||
|
||||
class _ListRepairsState extends State<ListRepairs> {
|
||||
final dbHandler dbh = dbHandler.instance;
|
||||
Future<bool> loaded;
|
||||
|
||||
List<Map<String, dynamic>> repList;
|
||||
Future<bool> _loadvars() async {
|
||||
dbh.queryOrdered("v_repair", "ASC", "name").then((value) {
|
||||
repList = value;
|
||||
setState(() {
|
||||
return true && repList != null;
|
||||
});
|
||||
});
|
||||
return false;
|
||||
}
|
||||
@override
|
||||
void setState(fn) {
|
||||
if (mounted) {
|
||||
super.setState(fn);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
loaded = _loadvars();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Exemplares de Consertos"),
|
||||
actions: [
|
||||
IconButton(onPressed: (){
|
||||
showSearch(context: context, delegate: CustomSearch(type: 0, loadList: repList));
|
||||
}, icon: Icon(Icons.search))
|
||||
],
|
||||
),
|
||||
body: _body(),
|
||||
);
|
||||
}
|
||||
|
||||
_body() {
|
||||
return Container(
|
||||
child: FutureBuilder<bool>(
|
||||
future: loaded,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting)
|
||||
return Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
else if (repList != null && repList.length != 0) {
|
||||
return ListView.separated(
|
||||
padding: const EdgeInsets.all(8),
|
||||
itemCount: repList.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
height: 90,
|
||||
color: Colors.black12,
|
||||
child: InkWell(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
strutStyle: StrutStyle(fontSize: 18.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 18.0),
|
||||
text: "Aparelho: " +
|
||||
'${repList[index]['name']}')),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
strutStyle: StrutStyle(fontSize: 18.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 18.0),
|
||||
text: "Reparo: " +
|
||||
'${repList[index]['repair']}'))
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
onTap: () => onPressWithArg(
|
||||
repList[index]['repair'],repList[index]['id'],repList[index]['repair_id']),
|
||||
));
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) =>
|
||||
const Divider());
|
||||
} else {
|
||||
return Container(
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
RichText(
|
||||
strutStyle: StrutStyle(
|
||||
fontSize: 32.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 32.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Colors.black26),
|
||||
text: "Nenhum reparo cadastrado."),
|
||||
),
|
||||
RichText(
|
||||
strutStyle: StrutStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Colors.black26),
|
||||
text: "\nTente recarregar a tela."),
|
||||
),
|
||||
Botoes(
|
||||
"Recarregar",
|
||||
onPressed: () => _update(context),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
)));
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_update(BuildContext context) {
|
||||
setState(() {
|
||||
Navigator.of(context).popUntil((route) => route.isFirst);
|
||||
Navigator.of(context).push(new MaterialPageRoute(builder: (context)=> ListRepairs()));
|
||||
});
|
||||
}
|
||||
|
||||
onPressWithArg(String rep, int id, int repid) {
|
||||
setState(() {
|
||||
_modalInput(rep, id, repid);
|
||||
});
|
||||
}
|
||||
|
||||
_modalInput(String repair, int eq, int rep) {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (_) => SimpleDialog(
|
||||
contentPadding: EdgeInsets.all(20),
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text("Detalhes do Reparo"),
|
||||
IconButton(
|
||||
iconSize: 20,
|
||||
onPressed: () {
|
||||
Navigator.of(context, rootNavigator: true)
|
||||
.pop('dialog');
|
||||
},
|
||||
icon: Icon(Icons.close))
|
||||
],
|
||||
),
|
||||
Divider(color: Colors.black38),
|
||||
RichText(
|
||||
strutStyle: StrutStyle(fontSize: 16.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(color: Colors.black, fontSize: 20.0, fontWeight: FontWeight.w300),
|
||||
text:repair)),
|
||||
Divider(color: Colors.transparent),
|
||||
Botoes(
|
||||
"Ver Aparelho",
|
||||
onPressed: () {
|
||||
Navigator.of(context)
|
||||
.push(new MaterialPageRoute(builder: (context) => EquipmentDetail(eq)))
|
||||
.whenComplete(_loadvars);
|
||||
},
|
||||
),
|
||||
Botoes(
|
||||
"Remover Reparo",
|
||||
onPressed: () {
|
||||
_confirmDelete(rep);
|
||||
},
|
||||
)
|
||||
],
|
||||
)
|
||||
);
|
||||
}
|
||||
_confirmDelete(int id)
|
||||
{
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (_) => SimpleDialog(
|
||||
contentPadding: EdgeInsets.all(20),
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text("Deseja remover o reparo?"),
|
||||
IconButton(
|
||||
iconSize: 20,
|
||||
onPressed: () {
|
||||
Navigator.of(context, rootNavigator: true)
|
||||
.pop('dialog');
|
||||
},
|
||||
icon: Icon(Icons.close))
|
||||
],
|
||||
),
|
||||
Divider(color: Colors.black38),
|
||||
Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Botoes("Sim", onPressed: (){
|
||||
Repair r = new Repair(0,"temp");
|
||||
r.RemoveDB(id);
|
||||
setState(() {
|
||||
_update(context);
|
||||
});
|
||||
},), Botoes("Não", onPressed: (){
|
||||
Navigator.of(context, rootNavigator: true)
|
||||
.pop('dialog');
|
||||
})
|
||||
],)
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
13
lib/widgets/button_styles.dart
Normal file
13
lib/widgets/button_styles.dart
Normal file
@ -0,0 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ButtonStyles {
|
||||
|
||||
ButtonStyle btnS = ButtonStyle(
|
||||
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
|
||||
RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
side: BorderSide(color: Colors.redAccent, width: 1.2))),
|
||||
backgroundColor: MaterialStateProperty.all(Colors.redAccent[700]),);
|
||||
TextStyle txS = TextStyle(
|
||||
color: Colors.white, fontSize: 20, fontWeight: FontWeight.w400);
|
||||
}
|
35
lib/widgets/widget_button.dart
Normal file
35
lib/widgets/widget_button.dart
Normal file
@ -0,0 +1,35 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'button_styles.dart';
|
||||
class Botoes extends StatelessWidget {
|
||||
final String texto;
|
||||
final Function onPressed;
|
||||
Botoes(this.texto, {this.onPressed});
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ElevatedButton(
|
||||
child:Text(
|
||||
texto,
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
onPressed: onPressed
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BotaoCustom extends StatelessWidget {
|
||||
final String texto;
|
||||
final Function onPressed;
|
||||
BotaoCustom(this.texto, {this.onPressed});
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ElevatedButton(
|
||||
style: ButtonStyles().btnS,
|
||||
child:Text(texto, style: ButtonStyles().txS),
|
||||
onPressed: onPressed
|
||||
);
|
||||
}
|
||||
}
|
80
lib/widgets/widget_caroussel.dart
Normal file
80
lib/widgets/widget_caroussel.dart
Normal file
@ -0,0 +1,80 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
class Caroussel extends StatefulWidget {
|
||||
List<String> images;
|
||||
String path;
|
||||
List<Image> finalImg = List<Image>.empty(growable: true);
|
||||
Caroussel(this.images);
|
||||
@override
|
||||
_CarousselState createState() => _CarousselState();
|
||||
}
|
||||
class _CarousselState extends State<Caroussel> {
|
||||
Future<bool> loaded;
|
||||
Future<bool> getPath() async{
|
||||
final directory = await getApplicationDocumentsDirectory().then((Directory value){
|
||||
widget.path = value.path;
|
||||
});
|
||||
for (int i = 0; i < widget.images.length; i++) {
|
||||
widget.finalImg.add(Image.file(File(widget.path+"/Pictures/"+widget.images[i].trimLeft())));
|
||||
}
|
||||
return true && widget.path.isNotEmpty;
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
loaded = getPath();
|
||||
}
|
||||
|
||||
@override
|
||||
void setState(fn) {
|
||||
if(mounted) {
|
||||
super.setState(fn);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: EdgeInsets.all(10),
|
||||
child: FutureBuilder<bool>(
|
||||
future: loaded,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done &&
|
||||
widget.finalImg.length > 0) {
|
||||
return
|
||||
ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const ScrollPhysics(),
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: widget.finalImg.length,
|
||||
itemBuilder: (BuildContext context, int index)
|
||||
{
|
||||
return Container(
|
||||
margin: EdgeInsets.only(right:5),
|
||||
child: widget.finalImg[index],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
return Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}));
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
* Center(
|
||||
child: ListView(
|
||||
physics: const ScrollPhysics(),
|
||||
scrollDirection: Axis.horizontal,
|
||||
children: [
|
||||
for(int i = 0; i < widget.finalImg.length; i++)
|
||||
widget.finalImg[i],
|
||||
],
|
||||
),
|
||||
);*/
|
9
lib/widgets/widget_generate.dart
Normal file
9
lib/widgets/widget_generate.dart
Normal file
@ -0,0 +1,9 @@
|
||||
import 'dart:math';
|
||||
|
||||
class StringGenerator{
|
||||
static const _chars = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890';
|
||||
Random _rnd = Random();
|
||||
|
||||
String getRandomString(int length) => String.fromCharCodes(Iterable.generate(
|
||||
length, (_) => _chars.codeUnitAt(_rnd.nextInt(_chars.length))));
|
||||
}
|
441
lib/widgets/widget_input.dart
Normal file
441
lib/widgets/widget_input.dart
Normal file
@ -0,0 +1,441 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:esms_project/dbhandler.dart';
|
||||
import 'package:esms_project/screens/equipmentDetail.dart';
|
||||
import 'package:esms_project/widgets/widget_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
class InputTextos extends StatelessWidget {
|
||||
String rotulo, hint;
|
||||
TextEditingController controller;
|
||||
bool readonly;
|
||||
InputTextos(this.rotulo,this.hint, {this.controller, this.readonly});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextFormField(
|
||||
readOnly: readonly == null ? false : readonly,
|
||||
controller: controller,
|
||||
style : TextStyle(
|
||||
color: Colors.black,
|
||||
backgroundColor: Colors.transparent
|
||||
),
|
||||
decoration : InputDecoration(
|
||||
labelText: rotulo,
|
||||
hintText: hint
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CustomSearch extends SearchDelegate{
|
||||
dbHandler dbh= dbHandler.instance;
|
||||
List<Map<String,dynamic>> loadList;
|
||||
int type;
|
||||
CustomSearch({this.type, this.loadList});
|
||||
@override
|
||||
List<Widget> buildActions(BuildContext context) {
|
||||
return[
|
||||
IconButton(onPressed: (){
|
||||
query = '';
|
||||
}, icon: Icon(Icons.clear))
|
||||
];
|
||||
}
|
||||
@override
|
||||
String get searchFieldLabel => "Pesquisar";
|
||||
|
||||
@override
|
||||
ThemeData appBarTheme(BuildContext context) {
|
||||
return ThemeData(
|
||||
primaryColor: Colors.red,
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.red[300]),
|
||||
),
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.white),
|
||||
),
|
||||
border: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.redAccent),
|
||||
),
|
||||
hintStyle: TextStyle(
|
||||
color: Colors.white, fontWeight: FontWeight.w400),
|
||||
),
|
||||
textTheme: TextTheme(headline6: TextStyle(
|
||||
color: Colors.white, fontWeight: FontWeight.w400),)
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildLeading(BuildContext context) {
|
||||
return IconButton(
|
||||
onPressed: (){
|
||||
close(context, null);
|
||||
},
|
||||
icon: Icon(Icons.arrow_back)
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildResults(BuildContext context) {
|
||||
List<Map<String,dynamic>> searchList = List.empty(growable: true);
|
||||
|
||||
if(query.length < 3)
|
||||
{
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Center(
|
||||
child: Text(
|
||||
"Termo deve ser maior que 2 letras.",
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
for(int i = 0; i < loadList.length; i++)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if(loadList[i]['name'].toUpperCase().contains(query.toUpperCase())){
|
||||
searchList.add(loadList[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if(loadList[i]['equipment'].toUpperCase().contains(query.toUpperCase())){
|
||||
searchList.add(loadList[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(searchList != null){
|
||||
return ListView.separated(
|
||||
padding: const EdgeInsets.all(8),
|
||||
itemCount: searchList.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
height: 90,
|
||||
color: Colors.black12,
|
||||
child: InkWell(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
strutStyle: StrutStyle(fontSize: 18.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 18.0),
|
||||
text: "Aparelho: " +
|
||||
'${searchList[index]['name']}')),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
RichText(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
strutStyle: StrutStyle(fontSize: 18.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 18.0),
|
||||
text: "Reparo: " +
|
||||
'${searchList[index]['repair']}'))
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
onTap: () => onPressWithArg(
|
||||
searchList[index]['repair'],searchList[index]['id'],searchList[index]['repair_id'],context),
|
||||
));
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) =>
|
||||
const Divider());
|
||||
}
|
||||
|
||||
return Container(
|
||||
padding: EdgeInsets.only(left:10,right:10),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Center(
|
||||
child: Text(
|
||||
"Insira um termo de busca válido",
|
||||
style: TextStyle(
|
||||
fontSize: 26.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Colors.black26)
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: Text(
|
||||
"(Ex. Aparelho XYZ, João da Silva)",
|
||||
style: TextStyle(
|
||||
fontSize: 24.0,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Colors.black26)
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildSuggestions(BuildContext context) {
|
||||
if(query.length < 3)
|
||||
{
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Center(
|
||||
child: Text(
|
||||
"Termo deve ser maior que 2 letras.",
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
return Column();
|
||||
}
|
||||
onPressWithArg(String rep, int id, int repid, context) {
|
||||
_modalInput(rep, id, repid, context);
|
||||
}
|
||||
|
||||
_modalInput(String repair, int eq, int rep, context) {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (_) => SimpleDialog(
|
||||
contentPadding: EdgeInsets.all(20),
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text("Detalhes do Reparo"),
|
||||
],
|
||||
),
|
||||
Divider(color: Colors.black38),
|
||||
RichText(
|
||||
strutStyle: StrutStyle(fontSize: 16.0),
|
||||
text: TextSpan(
|
||||
style: TextStyle(color: Colors.black, fontSize: 20.0, fontWeight: FontWeight.w300),
|
||||
text:repair)),
|
||||
Divider(color: Colors.transparent),
|
||||
Botoes(
|
||||
"Ver Aparelho",
|
||||
onPressed: () {
|
||||
Navigator.of(context)
|
||||
.push(new MaterialPageRoute(builder: (context) => EquipmentDetail(eq)));
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class InputData extends StatelessWidget {
|
||||
String rotulo, hint;
|
||||
TextEditingController controller;
|
||||
InputData(this.rotulo,this.hint, {this.controller});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
readOnly: true,
|
||||
keyboardType: TextInputType.datetime,
|
||||
validator: (value){
|
||||
try{
|
||||
DateFormat.yMd().parseStrict(value);
|
||||
}
|
||||
on FormatException catch (_)
|
||||
{
|
||||
return 'Valor inválido';
|
||||
}
|
||||
},
|
||||
controller: controller,
|
||||
style : TextStyle(
|
||||
color: Colors.black,
|
||||
backgroundColor: Colors.transparent
|
||||
),
|
||||
decoration : InputDecoration(
|
||||
labelText: rotulo,
|
||||
hintText: hint
|
||||
)
|
||||
),
|
||||
),
|
||||
IconButton(icon: Icon(Icons.calendar_today), onPressed: (){
|
||||
Future<DateTime> tmp = _showCalendar(context);
|
||||
tmp.then((DateTime res){
|
||||
controller.text = DateFormat.yMd().format(res);
|
||||
});
|
||||
})
|
||||
],
|
||||
);
|
||||
}
|
||||
_showCalendar(context)
|
||||
{
|
||||
return showDatePicker(
|
||||
context: context,
|
||||
initialDate: DateTime.now(), firstDate: DateTime.now(), lastDate: DateTime(2050)
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class InputDataNoValidate extends StatelessWidget {
|
||||
String rotulo, hint;
|
||||
bool readonly;
|
||||
TextEditingController controller;
|
||||
InputDataNoValidate(this.rotulo,this.hint, {this.controller, this.readonly});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
readOnly: readonly == null ? false : readonly,
|
||||
keyboardType: TextInputType.datetime,
|
||||
validator: (value) {
|
||||
if (value.isNotEmpty)
|
||||
{
|
||||
try{
|
||||
DateFormat.yMd().parseStrict(value);
|
||||
}
|
||||
on FormatException catch (_)
|
||||
{
|
||||
return 'Valor inválido';
|
||||
}
|
||||
}
|
||||
},
|
||||
controller: controller,
|
||||
style : TextStyle(
|
||||
color: Colors.black,
|
||||
backgroundColor: Colors.transparent
|
||||
),
|
||||
decoration : InputDecoration(
|
||||
labelText: rotulo,
|
||||
hintText: hint
|
||||
)
|
||||
),
|
||||
),
|
||||
IconButton(icon: Icon(Icons.calendar_today), onPressed: (){
|
||||
Future<DateTime> tmp = _showCalendar(context);
|
||||
tmp.then((DateTime res){
|
||||
controller.text = DateFormat.yMd().format(res);
|
||||
});
|
||||
})
|
||||
],
|
||||
);
|
||||
}
|
||||
_showCalendar(context)
|
||||
{
|
||||
return showDatePicker(
|
||||
context: context,
|
||||
initialDate: DateTime.now(), firstDate: DateTime.now(), lastDate: DateTime(2050)
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class InputValidado extends StatelessWidget {
|
||||
String rotulo, hint;
|
||||
TextEditingController controller;
|
||||
bool readonly;
|
||||
InputValidado(this.rotulo,this.hint, {this.controller, this.readonly});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextFormField(
|
||||
validator: (value){
|
||||
if(value.isEmpty)
|
||||
return 'Preencha o valor';
|
||||
},
|
||||
readOnly: readonly == null ? false : readonly,
|
||||
controller: controller,
|
||||
style : TextStyle(
|
||||
color: Colors.black,
|
||||
backgroundColor: Colors.transparent
|
||||
),
|
||||
decoration : InputDecoration(
|
||||
labelText: rotulo,
|
||||
hintText: hint
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class InputNumber extends StatelessWidget {
|
||||
String rotulo, hint;
|
||||
TextEditingController controller;
|
||||
bool readonly;
|
||||
InputNumber(this.rotulo,this.hint, {this.controller, this.readonly});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextFormField(
|
||||
validator: (value){
|
||||
if(int.tryParse(value) == null)
|
||||
return 'Valor inválido';
|
||||
},
|
||||
keyboardType: TextInputType.number,
|
||||
readOnly: readonly == null ? false : readonly,
|
||||
controller: controller,
|
||||
style : TextStyle(
|
||||
color: Colors.black,
|
||||
backgroundColor: Colors.transparent
|
||||
),
|
||||
decoration : InputDecoration(
|
||||
labelText: rotulo,
|
||||
hintText: hint
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class InputTextosPhone extends StatelessWidget {
|
||||
String rotulo, hint;
|
||||
TextEditingController controller;
|
||||
|
||||
InputTextosPhone(this.rotulo,this.hint, {this.controller});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextFormField(
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
FilteringTextInputFormatter.allow(RegExp(r'\+|\(|\)|\d|\s|\-'))
|
||||
],
|
||||
keyboardType: TextInputType.phone,
|
||||
controller: controller,
|
||||
style : TextStyle(
|
||||
color: Colors.black,
|
||||
backgroundColor: Colors.transparent
|
||||
),
|
||||
decoration : InputDecoration(
|
||||
labelText: rotulo,
|
||||
hintText: hint
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user