feito o cadastro do cidadão

This commit is contained in:
Reginaldo
2023-04-13 22:54:17 -03:00
parent cdee8fcc44
commit 632cdbfeef
34 changed files with 2076 additions and 1108 deletions

View File

@@ -0,0 +1,120 @@
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 '../utils/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,
),
),
);
}
),
),
),
);
}
}

View File

@@ -1,14 +1,13 @@
import 'package:flutter/material.dart';
import 'package:rkm/models/args_load_init_model.dart';
import 'package:rkm/widgets/alert_dialog_settings.dart';
import '../screens/login/sync_login_screen.dart';
import '../screens/login/login_saved_screen.dart';
import '../utils/color_palette.dart';
import 'icon_button_default.dart';
class AppBarDefault{
@override
PreferredSize appbar(BuildContext context,String title,{ArgsLoadInitModel? args}) {
PreferredSize appbar(BuildContext context,String title) {
return PreferredSize(
preferredSize: Size.fromHeight(50),
child: AppBar(
@@ -26,7 +25,7 @@ class AppBarDefault{
onPressed: (){
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SyncLoginScreen(args: args!)),
MaterialPageRoute(builder: (context) => LoginSavedScreen(listControl: [])),
);
}),
],

View File

@@ -0,0 +1,33 @@
import 'package:flutter/material.dart';
import 'package:rkm/widgets/text_default.dart';
class ErrorDefault extends StatelessWidget {
double widthDefault;
String error;
ErrorDefault({
this.widthDefault = 0.7,
this.error = 'Esse campo é obrigatório!'
});
@override
Widget build(BuildContext context) {
double height = MediaQuery.of(context).size.height;
double width = MediaQuery.of(context).size.width;
return Container(
height: 20,
width: width*widthDefault,
child: Column(
children: [
Divider(color: Colors.red,height: 2,thickness:2),
Container(
height: 15,
width: width*widthDefault,
child: TextDefault(text:error,color: Colors.red,fontSize: 12),
),
],
),
);
}
}

View File

@@ -9,6 +9,7 @@ class InputSearchText extends StatelessWidget {
double width;
Color color;
bool border;
var onChanged;
InputSearchText({
required this.controller,
@@ -17,6 +18,7 @@ class InputSearchText extends StatelessWidget {
this.hint = '',
this.color = ColorPalette.white,
this.border = true,
this.onChanged = null
});
@override
@@ -26,9 +28,10 @@ class InputSearchText extends StatelessWidget {
margin: ConstVariable().marginHightInput,
width: width,
child: TextFormField(
onChanged: onChanged,
controller: this.controller,
style: TextStyle(
color: ColorPalette.gray,
color: Colors.black,
fontSize: this.fontSize,
),
decoration: InputDecoration(
@@ -37,7 +40,7 @@ class InputSearchText extends StatelessWidget {
border: border?OutlineInputBorder():null,
hintText: this.hint,
hintStyle: TextStyle(
color: ColorPalette.gray,
color: Colors.black,
fontSize: this.fontSize,
)
)

View File

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:rkm/utils/color_palette.dart';
import '../controllers/format_txt.dart';
import '../utils/const_variable.dart';
class InputText extends StatelessWidget {
@@ -9,7 +10,6 @@ class InputText extends StatelessWidget {
String hint;
double width;
String label;
String error;
bool enable;
TextInputType textInputType;
int maxLines;
@@ -23,7 +23,6 @@ class InputText extends StatelessWidget {
this.fontSize = 15.0,
this.hint = '',
this.label = '',
this.error = '',
this.enable = true,
this.textInputType = TextInputType.text,
this.maxLines = 1,
@@ -35,18 +34,15 @@ class InputText extends StatelessWidget {
Widget build(BuildContext context) {
return Container(
color: ColorPalette.white,
margin: ConstVariable().marginHightInput,
margin: EdgeInsets.only(top: 5),
width: width,
child: TextFormField(
keyboardType: textInputType,
maxLines: maxLines,
onChanged: onChanged,
validator: (value) {
if (value!=null && value!.length==0) {
return error;
}
return null;
},
inputFormatters: [
FormatText()
],
obscureText: this.obscure,
controller: this.controller,
style: TextStyle(

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:rkm/widgets/text_default.dart';
import '../utils/color_palette.dart';
import 'error_default.dart';
import 'input_text.dart';
class InputWithSubtitle extends StatelessWidget {
@@ -10,8 +11,11 @@ class InputWithSubtitle extends StatelessWidget {
String labelInput;
double widthSubtitle;
double widthInput;
double widthError;
var controller;
var onChanged;
bool enable;
bool mandatory;
TextInputType textInputType;
int maxLines;
Color colorBorder;
@@ -25,9 +29,12 @@ class InputWithSubtitle extends StatelessWidget {
required this.widthInput,
required this.controller,
this.enable = true,
this.mandatory = true,
this.textInputType = TextInputType.text,
this.maxLines = 1,
this.colorBorder = ColorPalette.black54
this.colorBorder = ColorPalette.black54,
required this.onChanged,
this.widthError = 0.7
});
@override
@@ -49,13 +56,14 @@ class InputWithSubtitle extends StatelessWidget {
controller: controller,
width: widthInput,
hint: hintInput,
error: errorInput,
label: labelInput,
enable: enable,
textInputType: textInputType,
maxLines:maxLines,
colorBorder: colorBorder,
onChanged: onChanged,
),
controller.text=='' &&(enable&&mandatory)?ErrorDefault(widthDefault: widthError,):Container(),
Divider(color: ColorPalette.black54,height: 5,endIndent: 10,)
],
);

View File

@@ -0,0 +1,57 @@
import 'package:flutter/material.dart';
import 'package:rkm/widgets/text_default.dart';
import '../screens/registers_citizen/register_citizen_screen.dart';
import '../screens/registers_citizen/register_home_screen.dart';
import '../screens/registers_citizen/register_individual_screen.dart';
import '../utils/color_palette.dart';
class SubtitleAppbarCitizen extends StatelessWidget {
int title;
bool edit;
SubtitleAppbarCitizen({
required this.title,
this.edit = false
});
@override
Widget build(BuildContext context) {
double heigth = MediaQuery.of(context).size.height;
double width = MediaQuery.of(context).size.width;
return Container(
color: ColorPalette.white,
width: width,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextButton.icon(
onPressed:edit? ()=> Navigator.push(
context,
MaterialPageRoute(builder: (context) => RegisterCitizenScreen(select: '',)),
):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,)
),
TextButton.icon(
onPressed:edit? ()=> Navigator.push(
context,
MaterialPageRoute(builder: (context) => RegisterIndividualScreen()),
):null,
icon: Icon(Icons.assignment_outlined,color: title==2?Colors.black:ColorPalette.gray,),
label: TextDefault(text: 'Cadastro Individual',fontSize: 14,color: title==2?Colors.black:ColorPalette.gray,)
),
TextButton.icon(
onPressed:edit? ()=> Navigator.push(
context,
MaterialPageRoute(builder: (context) => RegisterHomeScreen()),
):null,
icon: Icon(Icons.home,color: title==3?Colors.black:ColorPalette.gray,),
label: TextDefault(text: 'Cadastro Domiciliar',fontSize: 14,color: title==3?Colors.black:ColorPalette.gray,)
),
],
),
);
}
}