ajustes envio das tabelas, criação e edição de cidadão
This commit is contained in:
@@ -1,120 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rkm/widgets/text_default.dart';
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
import '../screens/registers_citizen/register_citizen_screen.dart';
|
||||
import '../service/db/db_sqlite_load.dart';
|
||||
import '../config/color_palette.dart';
|
||||
import 'input_search_text.dart';
|
||||
|
||||
class AlertDialogSearchStateful extends StatefulWidget {
|
||||
|
||||
@override
|
||||
State<AlertDialogSearchStateful> createState() => _AlertDialogSearchStatefulState();
|
||||
}
|
||||
|
||||
class _AlertDialogSearchStatefulState extends State<AlertDialogSearchStateful> {
|
||||
|
||||
List cityDB = [];
|
||||
List showResultSearchCity = [];
|
||||
var controller = TextEditingController();
|
||||
|
||||
_searchCityBirth(){
|
||||
searchCity();
|
||||
}
|
||||
getCity()async{
|
||||
Database db = await DbSqliteLoad().intialDB();
|
||||
var query = "SELECT * FROM MUNICIPIOS ORDER BY NO_MUNICIPIO";
|
||||
List list = await db.rawQuery(query);
|
||||
// print("SELECT * FROM UNIDADES");
|
||||
// print(await db.rawQuery("SELECT * FROM UNIDADES"));
|
||||
for(int i=0; list.length > i;i++){
|
||||
cityDB.add('${list[i]['NO_MUNICIPIO']} - ${list[i]['UF_ESTADO']}');
|
||||
}
|
||||
searchCity();
|
||||
return 'complete';
|
||||
}
|
||||
|
||||
searchCity()async{
|
||||
if(controller.text.isNotEmpty){
|
||||
showResultSearchCity =[];
|
||||
for (int i =0;cityDB.length>i;i++) {
|
||||
String CIDADE = '${cityDB[i]}';
|
||||
|
||||
if(CIDADE.contains(controller.text.toUpperCase())){
|
||||
if(showResultSearchCity.length<10){
|
||||
showResultSearchCity.add(cityDB[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
setState(() {
|
||||
print(showResultSearchCity);
|
||||
});
|
||||
}else{
|
||||
setState(() {
|
||||
for(int i = 0;i<10;i++){
|
||||
showResultSearchCity.add(cityDB[i]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
getCity();
|
||||
controller.addListener(_searchCityBirth);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
double width = MediaQuery.of(context).size.width;
|
||||
double height = MediaQuery.of(context).size.height;
|
||||
|
||||
return AlertDialog(
|
||||
title: InputSearchText(
|
||||
controller: controller,
|
||||
width: width*0.3,
|
||||
hint: 'Buscar...',
|
||||
color: ColorPalette.titleContainer,
|
||||
border: false,
|
||||
),
|
||||
content: Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 10),
|
||||
width: width*0.8,
|
||||
child: Container(
|
||||
width: width*0.8,
|
||||
height: height*0.8,
|
||||
padding: EdgeInsets.symmetric(horizontal: 10),
|
||||
child: ListView.separated(
|
||||
separatorBuilder:(context,index)=> Divider(color: ColorPalette.black54,height: 5,),
|
||||
itemCount: showResultSearchCity.length,
|
||||
itemBuilder: (context,index){
|
||||
return Container(
|
||||
width: width*0.8,
|
||||
color: ColorPalette.white,
|
||||
child: ListTile(
|
||||
onTap: (){
|
||||
setState(() {
|
||||
controller.text = showResultSearchCity[index];
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => RegisterCitizenScreen(select: controller.text,)),
|
||||
);
|
||||
});
|
||||
},
|
||||
title: TextDefault(
|
||||
color: ColorPalette.black54,
|
||||
text: showResultSearchCity[index],
|
||||
fontSize: 16,
|
||||
maxLines: 2,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:rkm/config/color_palette.dart';
|
||||
import '../controllers/format_txt.dart';
|
||||
|
||||
@@ -26,7 +27,7 @@ class InputText extends StatelessWidget {
|
||||
this.textInputType = TextInputType.text,
|
||||
this.maxLines = 1,
|
||||
this.colorBorder = ColorPalette.black54,
|
||||
this.onChanged = null
|
||||
this.onChanged = null,
|
||||
});
|
||||
|
||||
@override
|
||||
|
||||
@@ -5,30 +5,30 @@ import 'button_default.dart';
|
||||
|
||||
class OnBackButton{
|
||||
onBackButton(context)async {
|
||||
bool exiApp = await showDialog(
|
||||
context: context,
|
||||
builder: (context){
|
||||
return AlertDialog(
|
||||
title: TextDefault(text: 'Aviso',color: ColorPalette.black54,textAlign: TextAlign.center,),
|
||||
content: TextDefault(text: 'Deseja sair e descartar as alterações?',color: ColorPalette.black54,),
|
||||
actions: [
|
||||
ButtonDefault(
|
||||
onPressed: ()=>Navigator.pushNamedAndRemoveUntil(context, '/home', (route) => false),
|
||||
title: 'Sim',
|
||||
background: ColorPalette.appBar,
|
||||
borderColor: ColorPalette.appBar,
|
||||
textColor: ColorPalette.white,
|
||||
),
|
||||
ButtonDefault(
|
||||
onPressed: ()=>Navigator.of(context).pop(false),
|
||||
title: 'Não',
|
||||
background: ColorPalette.white,
|
||||
borderColor: ColorPalette.white,
|
||||
textColor: ColorPalette.black54,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (context){
|
||||
return AlertDialog(
|
||||
title: TextDefault(text: 'Aviso',color: ColorPalette.black54,textAlign: TextAlign.center,),
|
||||
content: TextDefault(text: 'Deseja sair e descartar as alterações?',color: ColorPalette.black54,),
|
||||
actions: [
|
||||
ButtonDefault(
|
||||
onPressed: ()=>Navigator.pushNamedAndRemoveUntil(context, '/home', (route) => false),
|
||||
title: 'Sim',
|
||||
background: ColorPalette.appBar,
|
||||
borderColor: ColorPalette.appBar,
|
||||
textColor: ColorPalette.white,
|
||||
),
|
||||
ButtonDefault(
|
||||
onPressed: ()=>Navigator.of(context).pop(false),
|
||||
title: 'Não',
|
||||
background: ColorPalette.white,
|
||||
borderColor: ColorPalette.white,
|
||||
textColor: ColorPalette.black54,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ class SubtitleAppbarCitizen extends StatelessWidget {
|
||||
TextButton.icon(
|
||||
onPressed:edit? ()=> Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => RegisterCitizenScreen(select: '',)),
|
||||
MaterialPageRoute(builder: (context) => RegisterCitizenScreen(listData: [],)),
|
||||
):null,
|
||||
icon: Icon(Icons.person,color: title==1?Colors.black:ColorPalette.gray,),
|
||||
label: TextDefault(text: 'Cadastro Cidadão',fontSize: 14,color: title==1?Colors.black:ColorPalette.gray,)
|
||||
|
||||
Reference in New Issue
Block a user