UIiphoneResponsie

This commit is contained in:
poojakhatawate 2024-06-10 16:41:00 +05:30
parent 6ddaf2774a
commit e13307c953
20 changed files with 8632 additions and 2241 deletions

View File

@ -49,6 +49,8 @@ Future<void> main() async {
var box = await Hive.openBox('mycontact'); var box = await Hive.openBox('mycontact');
var box1 = await Hive.openBox('myfilter'); var box1 = await Hive.openBox('myfilter');
await Hive.openBox('checkvalue');
runApp(MultiProvider( runApp(MultiProvider(
providers: [ providers: [
ChangeNotifierProvider(create: (_) => InteractionProvider()), ChangeNotifierProvider(create: (_) => InteractionProvider()),
@ -173,3 +175,62 @@ class _MyHomePageState extends State<MyHomePage> {
); );
} }
} }
// import 'package:flutter/material.dart';
// class MyGridView extends StatefulWidget {
// @override
// _MyGridViewState createState() => _MyGridViewState();
// }
// class _MyGridViewState extends State<MyGridView> {
// List<List<String>> sections = [["Item 1", "Item 2", "Item 3"]];
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// appBar: AppBar(
// title: Text('GridView Example'),
// ),
// body: Column(
// children: [
// Expanded(
// child: ListView.builder(
// itemCount: sections.length,
// itemBuilder: (context, index) {
// return GridView.count(
// shrinkWrap: true,
// crossAxisCount: 2,
// children: sections[index].map((item) {
// return Card(
// child: Center(
// child: Text(item),
// ),
// );
// }).toList(),
// );
// },
// ),
// ),
// ElevatedButton(
// onPressed: () {
// setState(() {
// sections.add(["Item 1", "Item 2", "Item 3"]);
// });
// },
// child: Icon(Icons.add),
// ),
// ],
// ),
// );
// }
// }
// void main() {
// runApp(MaterialApp(
// home: MyGridView(),
// ));
// }

View File

@ -29,7 +29,8 @@ class _ContactsState extends State<Contacts> {
print( print(
"Data_newww: ${HiveFunctions.getAllUsers()} ,${HiveFunctions.getAllUsers().length} "); "Data_newww: ${HiveFunctions.getAllUsers()} ,${HiveFunctions.getAllUsers().length} ");
return Scaffold( return SafeArea(
child: Scaffold(
// appBar: AppBar( // appBar: AppBar(
// title: const Text('Contacts'), // title: const Text('Contacts'),
// ), // ),
@ -115,8 +116,10 @@ class _ContactsState extends State<Contacts> {
children: [ children: [
ListTile( ListTile(
onTap: () { onTap: () {
Navigator.push(context, Navigator.push(
MaterialPageRoute(builder: (context) => Profile())); context,
MaterialPageRoute(
builder: (context) => Profile()));
}, },
// title: Text(_contactbox.values.toString()), // title: Text(_contactbox.values.toString()),
leading: ProfilePicture( leading: ProfilePicture(
@ -142,6 +145,7 @@ class _ContactsState extends State<Contacts> {
), ),
], ],
), ),
),
); );
} }
} }

View File

@ -98,13 +98,14 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
return Consumer<ViewInteractionProvider>( return Consumer<ViewInteractionProvider>(
builder: (BuildContext context, provider, Widget? child) { builder: (BuildContext context, provider, Widget? child) {
// print("build context"); // print("build context");
// print("${provider.interactionReponseList}"); // print("Providerr_is: ${provider.multipletextEditingControllerList}");
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
FocusScope.of(context).requestFocus(FocusNode()); FocusScope.of(context).requestFocus(FocusNode());
}, },
child: OrientationBuilder(builder: (context, orientation) { child: OrientationBuilder(builder: (context, orientation) {
return Scaffold( return SafeArea(
child: Scaffold(
//resizeToAvoidBottomInset: false, //resizeToAvoidBottomInset: false,
appBar: AppBar( appBar: AppBar(
title: Text( title: Text(
@ -195,7 +196,8 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
Padding( Padding(
padding: isTablet padding: isTablet
? const EdgeInsets.only(left: 14.0) ? const EdgeInsets.only(
left: 14.0)
: const EdgeInsets.only( : const EdgeInsets.only(
left: 12.0, right: 12.0), left: 12.0, right: 12.0),
child: GridView.count( child: GridView.count(
@ -240,7 +242,8 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
childAspectRatio: childAspectRatio:
sectionList.length == 1 sectionList.length == 1
? orientation == ? orientation ==
Orientation.landscape Orientation
.landscape
? 10 ? 10
: 4.8 : 4.8
: isTablet : isTablet
@ -252,9 +255,10 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
// print(sectionList); // print(sectionList);
SectionList sectionItem = SectionList sectionItem =
sectionList[i]; sectionList[i];
dropdownvalue = sectionItem dropdownvalue =
.widget == sectionItem.widget ==
InteractionWidget.DROPDOWN InteractionWidget
.DROPDOWN
? sectionItem.value ?? ? sectionItem.value ??
"Select" "Select"
: ' '; : ' ';
@ -276,8 +280,8 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
sectionItem.widget == sectionItem.widget ==
InteractionWidget InteractionWidget
.CHECKBOX .CHECKBOX
? provider ? provider.getData2(
.getData2(sectionItem) sectionItem)
: []; : [];
return Column( return Column(
@ -289,7 +293,8 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
.BUTTON && .BUTTON &&
sectionItem.input == sectionItem.input ==
'add' 'add'
? const SizedBox.shrink() ? const SizedBox
.shrink()
: Padding( : Padding(
padding: padding:
const EdgeInsets const EdgeInsets
@ -302,7 +307,8 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
color: Colors color: Colors
.orange .orange
.shade800, .shade800,
fontSize: isTablet fontSize:
isTablet
? 18 ? 18
: 12, : 12,
), ),
@ -312,7 +318,8 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
height: isTablet ? 15 : 5, height: isTablet ? 15 : 5,
), ),
returnWidget( returnWidget(
sectionItem: sectionItem, sectionItem:
sectionItem,
item: item, item: item,
provider: provider, provider: provider,
list: list, list: list,
@ -342,7 +349,8 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
item, item,
index) index)
: const SizedBox.shrink(), : const SizedBox.shrink(),
provider.interactionReponseList.length == provider.interactionReponseList
.length ==
index - 1 index - 1
? saveActions(provider) ? saveActions(provider)
: const SizedBox.shrink() : const SizedBox.shrink()
@ -358,7 +366,8 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
// const Spacer(), // const Spacer(),
// saveActions(provider), // saveActions(provider),
], ],
)); )),
);
}), }),
); );
}); });
@ -389,6 +398,7 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
return customMultiselectDropdown(sectionItem, provider, list, multiple); return customMultiselectDropdown(sectionItem, provider, list, multiple);
case InteractionWidget.RADIO: case InteractionWidget.RADIO:
print("Radiiooooo");
return (sectionItem.inputList!.length >= 5) return (sectionItem.inputList!.length >= 5)
? customdropdown( ? customdropdown(
sectionItem, provider, sectionItem.inputList!, multiple) sectionItem, provider, sectionItem.inputList!, multiple)
@ -556,8 +566,10 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [
CustomButton( Padding(
backgroundColor: Colors.green.shade900, padding: const EdgeInsets.all(4.0),
child: CustomButton(
backgroundColor: Colors.green.shade500,
onPressed: () async { onPressed: () async {
// if (textFieldsValidation(provider).isEmpty) { // if (textFieldsValidation(provider).isEmpty) {
await provider.saveJsonObject(context, await provider.saveJsonObject(context,
@ -569,9 +581,12 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
}, },
textColor: Colors.white, textColor: Colors.white,
title: "Update", title: "Update",
height: 40, // height: 40,
width: isTablet ? 120 : 80, // width: isTablet ? 120 : 80,
fontsize: isTablet ? 15 : 12, height: MediaQuery.of(context).size.height * 0.2,
fontsize: isTablet ? 16 : 12,
),
), ),
SizedBox( SizedBox(
width: isTablet ? 20 : 2, width: isTablet ? 20 : 2,
@ -655,7 +670,8 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
Widget customdropdown(SectionList sectionItem, Widget customdropdown(SectionList sectionItem,
ViewInteractionProvider provider, List<InputClass> list, bool multiple) { ViewInteractionProvider provider, List<InputClass> list, bool multiple) {
// sectionItem.value = ''; // sectionItem.value = '';
print("%%%%${sectionItem.selectedValue!.last}"); // print("%%%%${sectionItem.selectedValue!.last}");
print("ItemList_is: $list");
if (list.isEmpty) { if (list.isEmpty) {
print("###list empty###"); print("###list empty###");
list = []; list = [];
@ -987,6 +1003,168 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
); );
} }
// Widget gridViewWidget(
// ViewInteractionProvider provider,
// String sectionName,
// List<SectionList> sectionList,
// Orientation orientation,
// FormFieldData item,
// int listIndex) {
// print("SectionListtt:isss: $sectionList");
// return Padding(
// padding: isTablet
// ? const EdgeInsets.only(left: 8.0)
// : const EdgeInsets.only(left: 12.0, right: 12.0),
// child: GridView.count(
// physics: const NeverScrollableScrollPhysics(),
// crossAxisCount: context.responsive<int>(
// 1, // default
// sm: 1, // small
// md: 1, // medium
// lg: sectionList.length == 1 ? 1 : 4, // large
// xl: 5, // extra large screen
// ),
// mainAxisSpacing: sectionList.length == 1 || !isTablet ? 1 : 2,
// shrinkWrap: true,
// padding: EdgeInsets.zero,
// childAspectRatio: sectionList.length == 1 || !isTablet
// ? orientation == Orientation.landscape
// ? 10
// : 4.2
// : 1.8,
// children: List.generate(
// sectionList.length,
// (i) {
// // print(sectionList);
// SectionList sectionItem = sectionList[i];
// dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN
// ? sectionItem.value ?? "Select"
// : ' ';
// List<InputClass> list =
// sectionItem.widget == InteractionWidget.DROPDOWN ||
// sectionItem.widget == InteractionWidget.AUTOCOMPLETE ||
// sectionItem.widget == InteractionWidget.MULTISELECT
// ? provider.getData2(sectionItem)
// : [];
// provider.checkboxlist =
// sectionItem.widget == InteractionWidget.CHECKBOX
// ? provider.getData2(sectionItem)
// : [];
// return Wrap(children: [
// Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// sectionItem.widget == InteractionWidget.BUTTON &&
// sectionItem.param == 'add' ||
// sectionItem.param == 'deletebtn'
// ? const SizedBox.shrink()
// : Text(
// '${sectionItem.name}:*',
// style: TextStyle(
// color: Colors.orange.shade800,
// fontSize: isTablet ? 18 : 14,
// ),
// ),
// const SizedBox(
// height: 15,
// ),
// sectionItem.widget == InteractionWidget.BUTTON
// ? sectionItem.input == 'chooseFile'
// ? Row(
// children: [
// CustomButton(
// backgroundColor: const Color.fromARGB(
// 255, 233, 229, 229),
// onPressed: () async {
// if (sectionItem
// .selectedValue!.isNotEmpty) {
// showFilesAlertDialog(
// context,
// sectionItem.fileName!.join(','),
// sectionItem);
// } else {
// sectionItem.selectedValue = [];
// sectionItem.extension = [];
// sectionItem.fileName = [];
// await getEncodedFile(sectionItem);
// }
// setState(() {});
// },
// width: 120,
// height: 40,
// fontsize: 12,
// textColor: Colors.black,
// title: sectionItem.name),
// const SizedBox(
// width: 5,
// ),
// Text(
// sectionItem.selectedValue!.isNotEmpty
// ? 'File uploaded'
// : 'No file uploaded',
// style: TextStyle(
// color:
// sectionItem.selectedValue!.isNotEmpty
// ? Colors.green
// : Colors.red),
// ),
// ],
// )
// : isTablet
// ? IconButton(
// onPressed: () {
// provider.deleteMultipleRows(
// sectionItem.gid!,
// sectionList[i],
// sectionName);
// setState(() {});
// },
// icon: const Icon(
// Icons.cancel,
// size: 30,
// color: Color.fromARGB(255, 8, 39, 92),
// ),
// )
// : Padding(
// padding:
// const EdgeInsets.only(left: 3.0, top: 5),
// child: CustomButton(
// backgroundColor: const Color.fromARGB(
// 255, 233, 75, 75),
// onPressed: () {
// provider.deleteMultipleRows(
// sectionItem.gid!,
// sectionList[i],
// sectionName);
// setState(() {});
// },
// width: 80,
// height: 30,
// fontsize: 12,
// textColor: Colors.white,
// title: "Delete"),
// )
// : returnWidget(
// sectionItem: sectionItem,
// item: item,
// provider: provider,
// list: list,
// gridIndex: i,
// listIndex: listIndex,
// widgetData: sectionItem.widget!,
// multiple: true),
// ],
// ),
// ]);
// },
// ),
// ),
// );
// }
Widget gridViewWidget( Widget gridViewWidget(
ViewInteractionProvider provider, ViewInteractionProvider provider,
String sectionName, String sectionName,
@ -994,38 +1172,115 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
Orientation orientation, Orientation orientation,
FormFieldData item, FormFieldData item,
int listIndex) { int listIndex) {
return Padding( print("SectionListtt:isss: $sectionList");
padding: isTablet
? const EdgeInsets.only(left: 8.0) List<SectionList> pooja = sectionList;
: const EdgeInsets.only(left: 12.0, right: 12.0),
child: GridView.count( print("Pooja: $pooja");
physics: const NeverScrollableScrollPhysics(),
crossAxisCount: context.responsive<int>( List<List<SectionList>> convertedArray = [];
1, // default print("Provider Length: ${item.sectionList.length}");
sm: 1, // small
md: 1, // medium for (int i = 0; i < sectionList.length; i += item.sectionList.length + 1) {
lg: sectionList.length == 1 ? 1 : 4, // large print("Section List11111: $sectionList");
xl: 5, // extra large screen print("item.sectionList.length List11111: ${item.sectionList.length}");
convertedArray
.add(sectionList.sublist(i, i + item.sectionList.length + 1));
}
print("ConvertedArrayEditMulti.leangth: $convertedArray");
print("ConvertedArray.leangth: ${convertedArray.length}");
return DecoratedBox(
decoration: BoxDecoration(
border: Border.all(color: Colors.black),
borderRadius: BorderRadius.circular(10.0),
),
child: Padding(
padding: isTablet
? const EdgeInsets.only(left: 14.0)
: const EdgeInsets.only(left: 12.0, right: 12.0),
child: Column(
children: [
for (var i = 0; i < convertedArray.length; i++)
GridView.builder(
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
// crossAxisCount: context.responsive<int>(
// 1, // default
// sm: 1, // small
// md: 1, // medium
// lg: sectionList.length == 1 ? 1 : 4, // large
// xl: 5, // extra large screen
// ),
crossAxisCount: context.responsive<int>(
1,
sm: 1, // small
md: 2, // medium
lg: sectionList.length == 1
? 1
: (sectionList.length >= 1 ? 3 : 3), // large
xl: 3, // extra large screen
),
mainAxisSpacing:
sectionList.length == 1 || !isTablet ? 1 : 2,
// childAspectRatio: isTablet
// ? MediaQuery.of(context).size.width /
// (MediaQuery.of(context).size.height * 0.3)
// : MediaQuery.of(context).size.width /
// (MediaQuery.of(context).size.height * 0.1),
childAspectRatio: isTablet
? MediaQuery.of(context).size.width /
(MediaQuery.of(context).size.height / 3)
: MediaQuery.of(context).size.width /
(MediaQuery.of(context).size.height * 0.2),
// mainAxisSpacing:
// sectionList.length == 1 || !isTablet ? 1 : 3.5,
// childAspectRatio: sectionList.length == 1
// ? orientation == Orientation.landscape
// ? 10
// : 4.8
// : isTablet
// ? 2.8
// : 3.0,
), ),
mainAxisSpacing: sectionList.length == 1 || !isTablet ? 1 : 2,
shrinkWrap: true, shrinkWrap: true,
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
childAspectRatio: sectionList.length == 1 || !isTablet
? orientation == Orientation.landscape // childAspectRatio: sectionList.length == 1 || !isTablet
? 10 // ? orientation == Orientation.landscape
: 4.2 // ? 10
: 1.8, // : 4.2
children: List.generate( // : 1.8,
sectionList.length,
(i) { itemCount: convertedArray[i].length,
// print(sectionList); itemBuilder: (context, index) {
SectionList sectionItem = sectionList[i]; // children: List.generate(
dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN // sectionList.length,
// (i) {
// // print(sectionList);
// SectionList sectionItem = sectionList[i];
// dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN
// ? sectionItem.value ?? "Select"
// : ' ';
// List<InputClass> list =
// sectionItem.widget == InteractionWidget.DROPDOWN ||
// sectionItem.widget == InteractionWidget.AUTOCOMPLETE ||
// sectionItem.widget == InteractionWidget.MULTISELECT
// ? provider.getData2(sectionItem)
// : [];
// provider.checkboxlist =
// sectionItem.widget == InteractionWidget.CHECKBOX
// ? provider.getData2(sectionItem)
// : [];
SectionList sectionItem = convertedArray[i][index];
dropdownvalue =
sectionItem.widget == InteractionWidget.DROPDOWN
? sectionItem.value ?? "Select" ? sectionItem.value ?? "Select"
: ' '; : ' ';
List<InputClass> list = List<InputClass> list = sectionItem.widget ==
sectionItem.widget == InteractionWidget.DROPDOWN || InteractionWidget.DROPDOWN ||
sectionItem.widget == InteractionWidget.AUTOCOMPLETE || sectionItem.widget ==
InteractionWidget.AUTOCOMPLETE ||
sectionItem.widget == InteractionWidget.MULTISELECT sectionItem.widget == InteractionWidget.MULTISELECT
? provider.getData2(sectionItem) ? provider.getData2(sectionItem)
: []; : [];
@ -1033,22 +1288,26 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
sectionItem.widget == InteractionWidget.CHECKBOX sectionItem.widget == InteractionWidget.CHECKBOX
? provider.getData2(sectionItem) ? provider.getData2(sectionItem)
: []; : [];
return SizedBox(
return Wrap(children: [ height: MediaQuery.of(context).size.height,
Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
sectionItem.widget == InteractionWidget.BUTTON && sectionItem.widget == InteractionWidget.BUTTON &&
sectionItem.param == 'add' || sectionItem.param == 'add' ||
sectionItem.param == 'deletebtn' sectionItem.param == 'deletebtn'
? const SizedBox.shrink() ? const SizedBox.shrink()
: Text( : Padding(
padding: const EdgeInsets.only(
left: 8.0, right: 8.0),
child: Text(
'${sectionItem.name}:*', '${sectionItem.name}:*',
style: TextStyle( style: TextStyle(
color: Colors.orange.shade800, color: Colors.orange.shade800,
fontSize: isTablet ? 18 : 14, fontSize: isTablet ? 18 : 14,
), ),
), ),
),
const SizedBox( const SizedBox(
height: 15, height: 15,
), ),
@ -1057,20 +1316,23 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
? Row( ? Row(
children: [ children: [
CustomButton( CustomButton(
backgroundColor: const Color.fromARGB( backgroundColor:
const Color.fromARGB(
255, 233, 229, 229), 255, 233, 229, 229),
onPressed: () async { onPressed: () async {
if (sectionItem if (sectionItem
.selectedValue!.isNotEmpty) { .selectedValue!.isNotEmpty) {
showFilesAlertDialog( showFilesAlertDialog(
context, context,
sectionItem.fileName!.join(','), sectionItem.fileName!
.join(','),
sectionItem); sectionItem);
} else { } else {
sectionItem.selectedValue = []; sectionItem.selectedValue = [];
sectionItem.extension = []; sectionItem.extension = [];
sectionItem.fileName = []; sectionItem.fileName = [];
await getEncodedFile(sectionItem); await getEncodedFile(
sectionItem);
} }
setState(() {}); setState(() {});
}, },
@ -1087,8 +1349,8 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
? 'File uploaded' ? 'File uploaded'
: 'No file uploaded', : 'No file uploaded',
style: TextStyle( style: TextStyle(
color: color: sectionItem
sectionItem.selectedValue!.isNotEmpty .selectedValue!.isNotEmpty
? Colors.green ? Colors.green
: Colors.red), : Colors.red),
), ),
@ -1107,14 +1369,16 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
icon: const Icon( icon: const Icon(
Icons.cancel, Icons.cancel,
size: 30, size: 30,
color: Color.fromARGB(255, 8, 39, 92), color:
Color.fromARGB(255, 8, 39, 92),
), ),
) )
: Padding( : Padding(
padding: padding: const EdgeInsets.only(
const EdgeInsets.only(left: 3.0, top: 5), left: 3.0, top: 5),
child: CustomButton( child: CustomButton(
backgroundColor: const Color.fromARGB( backgroundColor:
const Color.fromARGB(
255, 233, 75, 75), 255, 233, 75, 75),
onPressed: () { onPressed: () {
provider.deleteMultipleRows( provider.deleteMultipleRows(
@ -1141,8 +1405,9 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
multiple: true), multiple: true),
], ],
), ),
]); );
}, }),
],
), ),
), ),
); );

File diff suppressed because it is too large Load Diff

View File

@ -47,7 +47,8 @@ class _InteractionListScreenState extends State<InteractionListScreen> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Consumer<InteractionProvider>( return Consumer<InteractionProvider>(
builder: (BuildContext context, provider, Widget? child) { builder: (BuildContext context, provider, Widget? child) {
return Scaffold( return SafeArea(
child: Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text( title: Text(
'Interaction Forms', 'Interaction Forms',
@ -106,25 +107,28 @@ class _InteractionListScreenState extends State<InteractionListScreen> {
), ),
trailing: provider.savedList.indexWhere((element) => trailing: provider.savedList.indexWhere((element) =>
element.form == element.form ==
provider.intConfigDataList[index].name) != provider
.intConfigDataList[index].name) !=
-1 -1
? InkWell( ? InkWell(
onTap: () { onTap: () {
if (getCount( if (getCount(
provider provider.intConfigDataList[index]
.intConfigDataList[index].name, .name,
provider) != provider) !=
0) { 0) {
provider.savedList provider.savedList
.where((element) => .where((element) =>
element.form == element.form ==
provider.intConfigDataList[index] provider
.intConfigDataList[index]
.name) .name)
.toList(); .toList();
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (BuildContext context) => builder:
(BuildContext context) =>
SavedFormListScreen( SavedFormListScreen(
formname: provider formname: provider
.intConfigDataList[ .intConfigDataList[
@ -162,6 +166,7 @@ class _InteractionListScreenState extends State<InteractionListScreen> {
); );
})), })),
), ),
),
); );
}); });
} }

File diff suppressed because it is too large Load Diff

View File

@ -16,10 +16,12 @@ class MockApiCall {
final response = await dio.get('https://passvault.konectar.io/forms'); final response = await dio.get('https://passvault.konectar.io/forms');
print("response1"); print("response1_isssss");
// print(response.data.toString()); // print(response.data.toString());
log('${jsonEncode(response.data)}'); // log(jsonEncode(response.data));
final parsedJson = json.encode(response.data);
print(parsedJson);
return response.data; return response.data;
} }

View File

@ -98,6 +98,11 @@ class FormFieldData {
Map<String, dynamic> saveToJson() => { Map<String, dynamic> saveToJson() => {
"sectionName": sectionName, "sectionName": sectionName,
}; };
@override
String toString() {
// TODO: implement toString
return multiple.toString();
}
} }
@HiveType(typeId: 5) @HiveType(typeId: 5)

View File

@ -62,6 +62,12 @@ class SaveInteraction {
"form": form, "form": form,
"intId": intId, "intId": intId,
}; };
@override
String toString() {
// TODO: implement toString
return save.toString();
}
} }
class JsonFormat {} class JsonFormat {}

View File

@ -10,7 +10,7 @@ class HiveDataRepository extends ChangeNotifier {
HiveDataRepository(this._hiveBox); HiveDataRepository(this._hiveBox);
List<InteractionConfigData> getAllDataFromHive() { List<InteractionConfigData> getAllDataFromHive() {
print("Stored_ALL_valuesssss : ${_hiveBox.values.toList()}"); print("Stored_ALL_valuesssss : ${_hiveBox.values.toList().toString()}");
print( print(
"Stored_ALL_valuesssss_leangthhh : ${_hiveBox.values.toList().length}"); "Stored_ALL_valuesssss_leangthhh : ${_hiveBox.values.toList().length}");

View File

@ -39,11 +39,13 @@ class _SavedFormListScreenState extends State<SavedFormListScreen> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Consumer<ViewInteractionProvider>( return Consumer<ViewInteractionProvider>(
builder: (BuildContext context, provider, Widget? child) { builder: (BuildContext context, provider, Widget? child) {
return Scaffold( return SafeArea(
child: Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text( title: Text(
'Records of ${widget.formname}', 'Records of ${widget.formname}',
style: TextStyle(fontSize: isTablet ? 22 : 14, color: Colors.white), style:
TextStyle(fontSize: isTablet ? 22 : 14, color: Colors.white),
), ),
automaticallyImplyLeading: false, automaticallyImplyLeading: false,
// backgroundColor: const Color(0xFF2b9af3), // backgroundColor: const Color(0xFF2b9af3),
@ -102,8 +104,8 @@ class _SavedFormListScreenState extends State<SavedFormListScreen> {
MaterialPageRoute( MaterialPageRoute(
builder: (BuildContext context) => builder: (BuildContext context) =>
EditInteractionScreen( EditInteractionScreen(
saveInteraction: saveInteraction: provider
provider.savedList[index], .savedList[index],
))) )))
}); });
}, },
@ -144,6 +146,7 @@ class _SavedFormListScreenState extends State<SavedFormListScreen> {
); );
})), })),
), ),
),
); );
}); });
} }

View File

@ -51,7 +51,8 @@ class _ViewInteractionScreenState extends State<ViewInteractionScreen> {
FocusScope.of(context).requestFocus(FocusNode()); FocusScope.of(context).requestFocus(FocusNode());
}, },
child: OrientationBuilder(builder: (context, orientation) { child: OrientationBuilder(builder: (context, orientation) {
return Scaffold( return SafeArea(
child: Scaffold(
//resizeToAvoidBottomInset: false, //resizeToAvoidBottomInset: false,
appBar: AppBar( appBar: AppBar(
title: Text( title: Text(
@ -106,7 +107,8 @@ class _ViewInteractionScreenState extends State<ViewInteractionScreen> {
Padding( Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment:
CrossAxisAlignment.center,
children: [ children: [
const SizedBox( const SizedBox(
height: 20, height: 20,
@ -142,7 +144,8 @@ class _ViewInteractionScreenState extends State<ViewInteractionScreen> {
// ? 10 // ? 10
// : 3.8 // : 3.8
// : 2.8, // : 2.8,
crossAxisCount: context.responsive<int>( crossAxisCount:
context.responsive<int>(
1, 1,
sm: 1, // small sm: 1, // small
md: 2, // medium md: 2, // medium
@ -152,7 +155,8 @@ class _ViewInteractionScreenState extends State<ViewInteractionScreen> {
xl: 3, // extra large screen xl: 3, // extra large screen
), ),
mainAxisSpacing: mainAxisSpacing:
sectionList.length == 1 || !isTablet sectionList.length == 1 ||
!isTablet
? 1 ? 1
: 3.5, : 3.5,
childAspectRatio: childAspectRatio:
@ -175,9 +179,11 @@ class _ViewInteractionScreenState extends State<ViewInteractionScreen> {
dropdownvalue = sectionItem dropdownvalue = sectionItem
.widget == .widget ==
InteractionWidget.DROPDOWN InteractionWidget.DROPDOWN
? sectionItem.value ?? "Select" ? sectionItem.value ??
"Select"
: ' '; : ' ';
List<InputClass> list = sectionItem List<
InputClass> list = sectionItem
.widget == .widget ==
InteractionWidget InteractionWidget
.DROPDOWN || .DROPDOWN ||
@ -187,12 +193,15 @@ class _ViewInteractionScreenState extends State<ViewInteractionScreen> {
sectionItem.widget == sectionItem.widget ==
InteractionWidget InteractionWidget
.MULTISELECT .MULTISELECT
? provider.getData2(sectionItem) ? provider
.getData2(sectionItem)
: []; : [];
provider.checkboxlist = sectionItem provider.checkboxlist =
.widget == sectionItem.widget ==
InteractionWidget.CHECKBOX InteractionWidget
? provider.getData2(sectionItem) .CHECKBOX
? provider
.getData2(sectionItem)
: []; : [];
return Column( return Column(
@ -208,8 +217,8 @@ class _ViewInteractionScreenState extends State<ViewInteractionScreen> {
: Text( : Text(
'${sectionItem.name}:*', '${sectionItem.name}:*',
style: TextStyle( style: TextStyle(
color: Colors color: Colors.orange
.orange.shade800, .shade800,
fontSize: isTablet fontSize: isTablet
? 18 ? 18
: 12, : 12,
@ -263,7 +272,8 @@ class _ViewInteractionScreenState extends State<ViewInteractionScreen> {
// const Spacer(), // const Spacer(),
// saveActions(provider), // saveActions(provider),
], ],
)); )),
);
}), }),
); );
}); });
@ -375,6 +385,88 @@ class _ViewInteractionScreenState extends State<ViewInteractionScreen> {
); );
} }
// Widget gridViewWidget(
// InteractionProvider provider,
// String sectionName,
// List<SectionList> sectionList,
// Orientation orientation,
// FormFieldData item,
// int listIndex) {
// return Padding(
// padding: isTablet
// ? const EdgeInsets.only(left: 22.0)
// : const EdgeInsets.only(left: 12.0, right: 12.0),
// child: GridView.count(
// physics: const NeverScrollableScrollPhysics(),
// crossAxisCount: context.responsive<int>(
// 1, // default
// sm: 1, // small
// md: 1, // medium
// lg: sectionList.length == 1 ? 1 : 4, // large
// xl: 5, // extra large screen
// ),
// mainAxisSpacing: sectionList.length == 1 || !isTablet ? 1 : 2,
// shrinkWrap: true,
// padding: EdgeInsets.zero,
// childAspectRatio: sectionList.length == 1 || !isTablet
// ? orientation == Orientation.landscape
// ? 10
// : 4.2
// : 1.8,
// children: List.generate(
// sectionList.length,
// (i) {
// print(sectionList);
// SectionList sectionItem = sectionList[i];
// dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN
// ? sectionItem.value ?? "Select"
// : ' ';
// List<InputClass> list =
// sectionItem.widget == InteractionWidget.DROPDOWN ||
// sectionItem.widget == InteractionWidget.AUTOCOMPLETE ||
// sectionItem.widget == InteractionWidget.MULTISELECT
// ? provider.getData2(sectionItem)
// : [];
// provider.checkboxlist =
// sectionItem.widget == InteractionWidget.CHECKBOX
// ? provider.getData2(sectionItem)
// : [];
// return Wrap(children: [
// Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// sectionItem.widget == InteractionWidget.BUTTON &&
// sectionItem.param == 'add' ||
// sectionItem.param == 'deletebtn'
// ? const SizedBox.shrink()
// : Text(
// '${sectionItem.name}:*',
// style: TextStyle(
// color: Colors.orange.shade800,
// fontSize: isTablet ? 18 : 14,
// ),
// ),
// const SizedBox(
// height: 15,
// ),
// returnWidget(
// sectionItem: sectionItem,
// item: item,
// provider: provider,
// list: list,
// gridIndex: i,
// listIndex: listIndex,
// widgetData: sectionItem.widget!),
// ],
// ),
// ]);
// },
// ),
// ),
// );
// }
Widget gridViewWidget( Widget gridViewWidget(
InteractionProvider provider, InteractionProvider provider,
String sectionName, String sectionName,
@ -382,12 +474,33 @@ class _ViewInteractionScreenState extends State<ViewInteractionScreen> {
Orientation orientation, Orientation orientation,
FormFieldData item, FormFieldData item,
int listIndex) { int listIndex) {
List<SectionList> pooja = sectionList;
print("Pooja: $pooja");
List<List<SectionList>> convertedArray = [];
print("Provider Length: ${item.sectionList.length}");
for (int i = 0; i < sectionList.length; i += item.sectionList.length + 1) {
print("Section List11111: $sectionList");
print("item.sectionList.length List11111: ${item.sectionList.length}");
convertedArray
.add(sectionList.sublist(i, i + item.sectionList.length + 1));
}
print("ConvertedArrayEdit.leangth: $convertedArray");
print("ConvertedArray.leangth2323: ${convertedArray.length}");
return Padding( return Padding(
padding: isTablet padding: isTablet
? const EdgeInsets.only(left: 22.0) ? const EdgeInsets.only(left: 22.0)
: const EdgeInsets.only(left: 12.0, right: 12.0), : const EdgeInsets.only(left: 12.0, right: 12.0),
child: GridView.count( child: Column(
children: [
for (var i = 0; i < convertedArray.length; i++)
GridView.builder(
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: context.responsive<int>( crossAxisCount: context.responsive<int>(
1, // default 1, // default
sm: 1, // small sm: 1, // small
@ -396,23 +509,40 @@ class _ViewInteractionScreenState extends State<ViewInteractionScreen> {
xl: 5, // extra large screen xl: 5, // extra large screen
), ),
mainAxisSpacing: sectionList.length == 1 || !isTablet ? 1 : 2, mainAxisSpacing: sectionList.length == 1 || !isTablet ? 1 : 2,
),
shrinkWrap: true, shrinkWrap: true,
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
childAspectRatio: sectionList.length == 1 || !isTablet // childAspectRatio: sectionList.length == 1 || !isTablet
? orientation == Orientation.landscape // ? orientation == Orientation.landscape
? 10 // ? 10
: 4.2 // : 4.2
: 1.8, // : 1.8,
children: List.generate( itemCount: convertedArray[i].length,
sectionList.length, itemBuilder: (context, index) {
(i) { // children: List.generate(
print(sectionList); // sectionList.length,
SectionList sectionItem = sectionList[i]; // (i) {
// print(sectionList);
// SectionList sectionItem = sectionList[i];
// dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN
// ? sectionItem.value ?? "Select"
// : ' ';
// List<InputClass> list =
// sectionItem.widget == InteractionWidget.DROPDOWN ||
// sectionItem.widget == InteractionWidget.AUTOCOMPLETE ||
// sectionItem.widget == InteractionWidget.MULTISELECT
// ? provider.getData2(sectionItem)
// : [];
// provider.checkboxlist =
// sectionItem.widget == InteractionWidget.CHECKBOX
// ? provider.getData2(sectionItem)
// : [];
SectionList sectionItem = convertedArray[i][index];
dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN
? sectionItem.value ?? "Select" ? sectionItem.value ?? "Select"
: ' '; : ' ';
List<InputClass> list = List<InputClass> list = sectionItem.widget ==
sectionItem.widget == InteractionWidget.DROPDOWN || InteractionWidget.DROPDOWN ||
sectionItem.widget == InteractionWidget.AUTOCOMPLETE || sectionItem.widget == InteractionWidget.AUTOCOMPLETE ||
sectionItem.widget == InteractionWidget.MULTISELECT sectionItem.widget == InteractionWidget.MULTISELECT
? provider.getData2(sectionItem) ? provider.getData2(sectionItem)
@ -422,8 +552,9 @@ class _ViewInteractionScreenState extends State<ViewInteractionScreen> {
? provider.getData2(sectionItem) ? provider.getData2(sectionItem)
: []; : [];
return Wrap(children: [ return SizedBox(
Column( height: MediaQuery.of(context).size.height,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
sectionItem.widget == InteractionWidget.BUTTON && sectionItem.widget == InteractionWidget.BUTTON &&
@ -450,9 +581,11 @@ class _ViewInteractionScreenState extends State<ViewInteractionScreen> {
widgetData: sectionItem.widget!), widgetData: sectionItem.widget!),
], ],
), ),
]); );
}, },
), ),
//),
],
), ),
); );
} }

View File

@ -140,13 +140,22 @@ class ViewInteractionProvider extends ChangeNotifier {
for (SectionList obj in item.multipleList!) { for (SectionList obj in item.multipleList!) {
obj.gid = obj.gid ?? item.multipleList!.length; obj.gid = obj.gid ?? item.multipleList!.length;
if (obj.widget == InteractionWidget.TEXT) { if (obj.widget == InteractionWidget.TEXT) {
debugPrint("textcontr:${obj.gid}");
debugPrint("textcontr:${obj.selectedValue}");
// debugPrint("textcontr:${obj.controller!.value}");
var textEditingController = TextEditingController(); var textEditingController = TextEditingController();
textEditingController.value = TextEditingValue(
text: obj.selectedValue!.isNotEmpty
? obj.selectedValue!.last ?? ""
: "");
textEditingController.text = obj.selectedValue!.isNotEmpty textEditingController.text = obj.selectedValue!.isNotEmpty
? obj.selectedValue!.last ?? "" ? obj.selectedValue!.last ?? ""
: ""; : "";
multipletextEditingControllerList.add(textEditingController); multipletextEditingControllerList.add(textEditingController);
obj.controller = multipletextEditingControllerList.last; // obj.controller!.value = textEditingController.value;
obj.controller = textEditingController;
// obj.controller = obj.selectedValue.last ?? " "; // obj.controller = obj.selectedValue.last ?? " ";
} }
if (obj.widget == InteractionWidget.DROPDOWN || if (obj.widget == InteractionWidget.DROPDOWN ||
@ -608,6 +617,23 @@ class ViewInteractionProvider extends ChangeNotifier {
// if (interactionReponseList[index].multipleList!.isEmpty) { // if (interactionReponseList[index].multipleList!.isEmpty) {
// newList = addList; // newList = addList;
// } else { // } else {
if (addList.isNotEmpty) {
for (SectionList obj in addList) {
// obj.gid = obj.gid ?? addList.length;
if (obj.widget == InteractionWidget.TEXT) {
var textEditingController = TextEditingController();
multipletextEditingControllerList.add(textEditingController);
obj.controller = multipletextEditingControllerList.last;
obj.controller!.text =
obj.selectedValue != null && obj.selectedValue!.isNotEmpty
? obj.selectedValue!.last
: '';
}
// newList.add(obj);
}
}
if (interactionReponseList[index].multipleList == null) { if (interactionReponseList[index].multipleList == null) {
interactionReponseList[index].multipleList = addList; interactionReponseList[index].multipleList = addList;
} else { } else {
@ -622,10 +648,6 @@ class ViewInteractionProvider extends ChangeNotifier {
for (SectionList obj in interactionReponseList[index].multipleList!) { for (SectionList obj in interactionReponseList[index].multipleList!) {
obj.gid = obj.gid ?? interactionReponseList[index].multipleList!.length; obj.gid = obj.gid ?? interactionReponseList[index].multipleList!.length;
if (obj.widget == InteractionWidget.TEXT) { if (obj.widget == InteractionWidget.TEXT) {
var textEditingController = TextEditingController();
multipletextEditingControllerList.add(textEditingController);
obj.controller = multipletextEditingControllerList.last;
obj.controller!.text = obj.controller!.text =
obj.selectedValue != null && obj.selectedValue!.isNotEmpty obj.selectedValue != null && obj.selectedValue!.isNotEmpty
? obj.selectedValue!.last ? obj.selectedValue!.last
@ -653,6 +675,14 @@ class ViewInteractionProvider extends ChangeNotifier {
saveJsonObject(BuildContext context, String form, saveJsonObject(BuildContext context, String form,
SaveInteraction saveInteraction) async { SaveInteraction saveInteraction) async {
for (var res in interactionReponseList) {
for (var sec in res.sectionList) {
debugPrint("print ${sec.selectedValue}");
}
for (var sec in res.multipleList!) {
debugPrint("printmultiple ${sec.selectedValue}");
}
}
List<FormFieldData> resultData = interactionReponseList List<FormFieldData> resultData = interactionReponseList
.map((e) => FormFieldData( .map((e) => FormFieldData(
multipleList: e.multipleList == null multipleList: e.multipleList == null
@ -793,3 +823,814 @@ class ViewInteractionProvider extends ChangeNotifier {
return false; return false;
} }
} }
// import 'dart:convert';
// import 'package:dio/dio.dart';
// import 'package:discover_module/ui_screen/interactionform/interactionprovider.dart';
// import 'package:discover_module/ui_screen/interactionform/model/interaction_config_data.dart';
// import 'package:discover_module/ui_screen/interactionform/model/interaction_data.dart';
// import 'package:discover_module/ui_screen/interactionform/model/json_form_data.dart';
// import 'package:discover_module/ui_screen/interactionform/model/location_model.dart';
// import 'package:discover_module/ui_screen/interactionform/model/save_interaction.dart';
// import 'package:discover_module/ui_screen/interactionform/repository/hive_repository.dart';
// import 'package:flutter/cupertino.dart';
// import 'package:flutter/services.dart';
// import 'package:hive_flutter/hive_flutter.dart';
// class ViewInteractionProvider extends ChangeNotifier {
// List<FormFieldData> interactionReponseList = [];
// // List<dynamic> sectionList = [];
// List<SectionList> sectionList = [];
// late Location locationList;
// List<TextEditingController> textEditingControllerList = [];
// List<TextEditingController> multipletextEditingControllerList = [];
// int textfieldIndex = 0;
// List<Country> countryList = [];
// List<States> stateList = [];
// List<City> cityList = [];
// List<InputClass> checkboxlist = [];
// String selectedCountry = 'Selected Country';
// String radioValue = '';
// bool checkboxValue = false;
// late SaveInteraction saveInteraction;
// List<SaveData> saveData = [];
// List<SectionList> newList = [];
// String sectionName = '';
// late String selectedCity = 'Selected City', selectedState = 'Selected State';
// String customdropdownValue = '';
// String? selectedValue;
// List<String> selectedItems = [];
// InputClass? selectedObj;
// List<SaveInteraction> savedList = [];
// List<InteractionConfigData> intConfigDataList = [];
// String? intId, intName;
// final HiveDataRepository _hiveprovider = HiveDataRepository(
// Hive.box<InteractionConfigData>('InteractionConfigDataBox'));
// late final InteractionProvider interactionProvider;
// initConfigData() async {
// intConfigDataList = _hiveprovider.getAllDataFromHive();
// notifyListeners();
// }
// Future<void> getRecords(String formname) async {
// var box = await Hive.openBox<SaveInteraction>('InteractionDataBox');
// savedList = box.values.toList();
// savedList = savedList
// .where(
// (element) => element.form == formname,
// )
// .toList();
// notifyListeners();
// }
// Future<List<SaveInteraction>> getAllRecords() async {
// var box = await Hive.openBox<SaveInteraction>('InteractionDataBox');
// List<SaveInteraction> savedList = box.values.toList();
// return savedList;
// }
// init(int index) async {
// // _hiveprovider = HiveDataRepository(
// // Hive.box<InteractionConfigData>('InteractionConfigDataBox'));
// // intConfigDataList = _hiveprovider.getAllDataFromHive();
// InteractionConfigData interactionConfigData = intConfigDataList[index];
// intId = intConfigDataList[index].id;
// intName = intConfigDataList[index].name;
// print("data $intConfigDataList");
// // await fetchSaveDataJson();
// // await fetchDataSet();
// await fetchData(interactionConfigData.widgets);
// await fetchLocationData();
// }
// initSavedForm(SaveInteraction saveInteractiondata) {
// intConfigDataList
// .indexWhere((element) => element.id == saveInteractiondata.intId);
// interactionReponseList = saveInteractiondata.save
// .map((e) => FormFieldData(
// multipleList: e.multipleList == null
// ? []
// : e.multipleList!
// .map((mobj) => SectionList(
// depid: mobj.depid,
// id: mobj.id,
// inputList: mobj.inputList,
// isRequired: mobj.isRequired,
// extension: mobj.extension,
// fileName: mobj.fileName,
// selectedObject: mobj.selectedObject,
// name: mobj.name,
// param: mobj.param,
// selectedValue: mobj.selectedValue,
// widget: mobj.widget,
// controller: mobj.controller,
// gid: mobj.gid,
// input: mobj.input,
// selectedId: mobj.selectedId,
// value: mobj.value))
// .toList(),
// sectionList: e.sectionList
// .map((obj) => SectionList(
// depid: obj.depid,
// id: obj.id,
// inputList: obj.inputList,
// isRequired: obj.isRequired,
// extension: obj.extension,
// fileName: obj.fileName,
// name: obj.name,
// param: obj.param,
// selectedObject: obj.selectedObject,
// selectedValue: obj.selectedValue,
// widget: obj.widget,
// controller: obj.controller,
// gid: obj.gid,
// input: obj.input,
// selectedId: obj.selectedId,
// value: obj.value))
// .toList(),
// sectionName: e.sectionName,
// multiple: e.multiple))
// .toList();
// textEditingControllerList.clear();
// for (var item in interactionReponseList) {
// sectionList = item.sectionList;
// for (SectionList obj in item.multipleList!) {
// obj.gid = obj.gid ?? item.multipleList!.length;
// if (obj.widget == InteractionWidget.TEXT) {
// var textEditingController = TextEditingController();
// textEditingController.value = TextEditingValue(
// text: obj.selectedValue!.isNotEmpty
// ? obj.selectedValue!.last ?? ""
// : "");
// textEditingController.text = obj.selectedValue!.isNotEmpty
// ? obj.selectedValue!.last ?? ""
// : "";
// multipletextEditingControllerList.add(textEditingController);
// // obj.controller = multipletextEditingControllerList.last;
// obj.controller = textEditingController;
// }
// if (obj.widget == InteractionWidget.DROPDOWN ||
// obj.widget == InteractionWidget.AUTOCOMPLETE ||
// obj.widget == InteractionWidget.MULTISELECT) {
// List<InputClass> list = obj.inputList!;
// if (obj.selectedObject != null) {
// } else {
// obj.selectedObject = obj.selectedValue!.isNotEmpty
// ? getDataObject(obj.id, obj.selectedValue!.last, list)
// : list[0];
// }
// print("value : ${list.first.name} ");
// }
// if (obj.widget == InteractionWidget.CHECKBOX) {
// List<String> selectedvalues = [];
// if (obj.selectedValue!.isNotEmpty) {
// for (var id in obj.selectedValue!) {
// int ind =
// obj.inputList!.indexWhere((element) => element.id == id);
// if (ind != -1) {
// obj.inputList![ind].ischecked = true;
// selectedvalues.add(obj.inputList![ind].name);
// }
// }
// }
// }
// if (obj.widget == InteractionWidget.RADIO) {
// List<InputClass> list = obj.inputList!;
// if (obj.selectedValue!.isNotEmpty) {
// int ind = list
// .indexWhere((element) => element.id == obj.selectedValue!.last);
// if (ind != -1) {
// obj.inputList![ind].ischecked = true;
// radioValue = obj.inputList![ind].name;
// }
// }
// }
// // newList.add(obj);
// }
// for (var sectionItem in item.sectionList) {
// if (sectionItem.widget == InteractionWidget.TEXT) {
// var textEditingController = TextEditingController();
// textEditingController.text = sectionItem.selectedValue!.isNotEmpty
// ? sectionItem.selectedValue!.last ?? " "
// : " ";
// textEditingControllerList.add(textEditingController);
// sectionItem.controller = textEditingControllerList.last;
// }
// if (sectionItem.widget == InteractionWidget.DROPDOWN) {
// List<InputClass> list = sectionItem.inputList!;
// if (sectionItem.selectedObject != null) {
// print("#######not null");
// } else {
// print("#######is_null");
// if (sectionItem.selectedValue == null) {
// print("#######is_null#####");
// } else {
// print('###${sectionItem.selectedValue}');
// }
// sectionItem.selectedObject = sectionItem.selectedValue!.isNotEmpty
// ? getDataObject(
// sectionItem.id, sectionItem.selectedValue!.last, list)
// : list[0];
// }
// print("valuesssss : ${sectionItem.selectedObject!.name} ");
// }
// if (sectionItem.widget == InteractionWidget.AUTOCOMPLETE ||
// sectionItem.widget == InteractionWidget.MULTISELECT) {
// List<InputClass> list = sectionItem.inputList!;
// if (sectionItem.selectedObject != null) {
// } else {
// sectionItem.selectedObject = sectionItem.selectedValue!.isNotEmpty
// ? getDataObject(
// sectionItem.id, sectionItem.selectedValue!.last, list)
// : list[0];
// }
// print("value : ${list.first.name} ");
// }
// if (sectionItem.widget == InteractionWidget.CHECKBOX) {
// List<String> selectedvalues = [];
// if (sectionItem.selectedValue!.isNotEmpty) {
// for (var id in sectionItem.selectedValue!) {
// int ind = sectionItem.inputList!
// .indexWhere((element) => element.id == id);
// if (ind != -1) {
// sectionItem.inputList![ind].ischecked = true;
// selectedvalues.add(sectionItem.inputList![ind].name);
// }
// }
// }
// }
// if (sectionItem.widget == InteractionWidget.RADIO) {
// List<InputClass> list = sectionItem.inputList!;
// if (sectionItem.selectedValue!.isNotEmpty) {
// int ind = list.indexWhere(
// (element) => element.id == sectionItem.selectedValue!.last);
// if (ind != -1) {
// sectionItem.inputList![ind].ischecked = true;
// radioValue = sectionItem.inputList![ind].name;
// }
// }
// }
// if (sectionItem.widget == InteractionWidget.BUTTON &&
// sectionItem.param == 'chooseFile' &&
// sectionItem.selectedValue!.isNotEmpty) {
// print("choosed file");
// print(sectionItem.selectedValue!.last);
// }
// }
// }
// print(interactionReponseList);
// print("check textcontrollers ${textEditingControllerList.length}");
// }
// Future<String> fetchDataSet() async {
// List<InputClass> list = getData("intlocation_1");
// print(list);
// return "success";
// }
// List<InputClass> getData(String widgetId) {
// List<InputClass> list = [];
// return list;
// }
// InputClass getDataObject(String widgetId, String id, List<InputClass> list) {
// // if (id != "") {
// // List<InputClass> list = [];
// InputClass value = InputClass(id: '', name: '');
// if (list.isNotEmpty) {
// int index = list.indexWhere((element) => element.id.toString() == id);
// if (index != -1) {
// value = list[index];
// }
// }
// return value;
// }
// // TODO: Search for widget with depid and check if selected is not null and by selected id get the data of current widget
// List<InputClass> getData2(SectionList sectionItem) {
// List<InputClass> list = [];
// // if (sectionItem.inputList != null) {
// list = sectionItem.inputList!;
// if (sectionItem.depid != "") {
// // print("check depid : ${sectionItem.depid}");
// int i = 0;
// for (var obj in interactionReponseList) {
// i = obj.sectionList
// .indexWhere((element) => element.id == sectionItem.depid);
// // print("check depid index: $i");
// if (i != -1) {
// //print("check depid value: ${obj.sectionList[i].value}");
// if (obj.sectionList[i].value != null) {
// if (list
// .where((element) => element.pid == obj.sectionList[i].value)
// .isNotEmpty) {
// list = list
// .where((element) => element.pid == obj.sectionList[i].value)
// .toList();
// sectionItem.selectedObject = list[0];
// } else {
// // InputClass obj = InputClass(
// // id: "obj.sectionList[i].value",
// // name: "Select ${sectionItem.name}");
// list = [];
// // list.add(obj);
// sectionItem.selectedObject = null;
// }
// } else {
// // int index = obj.sectionList
// // .indexWhere((element) => element.id == sectionItem.id);
// // list = obj.sectionList[index].inputList;
// }
// }
// }
// // int index = data[i].data.indexWhere((element) => element.)
// }
// // }
// print("I_am_Returning_list: $list");
// return list;
// }
// setDropDownValue(String value, SectionList sectionItem, bool multiple,
// InputClass selectedObject) {
// int i = 0;
// for (var obj in interactionReponseList) {
// if (multiple && obj.multipleList != null) {
// i = obj.multipleList!.indexWhere((element) =>
// element.id == sectionItem.id && element.gid == sectionItem.gid);
// if (i != -1) {
// obj.multipleList![i].value = value;
// obj.multipleList![i].tempselectedValue = [];
// obj.multipleList![i].tempselectedValue!.add(value);
// // obj.multipleList![i].selectedObject = selectedObj;
// }
// } else {
// i = obj.sectionList
// .indexWhere((element) => element.id == sectionItem.id);
// if (i != -1) {
// obj.sectionList[i].value = value;
// obj.sectionList[i].tempselectedValue = [];
// obj.sectionList[i].tempselectedValue!.add(value);
// // obj.sectionList[i].selectedObject = selectedObj;
// }
// }
// }
// notifyListeners();
// }
// Future<void> disposeValues() async {
// print("dispose called");
// // await _hiveprovider.closeHiveBox();
// for (var obj in interactionReponseList) {
// obj.multipleList!.clear();
// // for (var obj2 in obj.sectionList) {
// // obj2.selectedObject = null;
// // }
// obj.sectionList.clear();
// }
// interactionReponseList.clear();
// }
// setTextValue(String value, SectionList sectionItem, bool multiple) {
// int i = 0;
// for (var obj in interactionReponseList) {
// if (multiple && obj.multipleList != null) {
// i = obj.multipleList!.indexWhere((element) =>
// element.id == sectionItem.id && element.gid == sectionItem.gid);
// if (i != -1) {
// obj.multipleList![i].value = value;
// obj.multipleList![i].selectedValue!.add(value);
// }
// } else {
// i = obj.sectionList
// .indexWhere((element) => element.id == sectionItem.id);
// if (i != -1) {
// obj.sectionList[i].value = value;
// obj.sectionList[i].selectedValue!.add(value);
// }
// }
// }
// notifyListeners();
// }
// setAutoCompleteValue(String value, SectionList sectionItem, bool multiple) {
// int i = 0;
// for (var obj in interactionReponseList) {
// if (multiple && obj.multipleList != null) {
// i = obj.multipleList!.indexWhere((element) =>
// element.id == sectionItem.id && element.gid == sectionItem.gid);
// if (i != -1) {
// obj.multipleList![i].value = value;
// obj.multipleList![i].tempselectedValue = [];
// obj.multipleList![i].tempselectedValue!.add(value);
// }
// } else {
// i = obj.sectionList
// .indexWhere((element) => element.id == sectionItem.id);
// if (i != -1) {
// obj.sectionList[i].value = value;
// obj.sectionList[i].tempselectedValue = [];
// obj.sectionList[i].tempselectedValue!.add(value);
// }
// }
// }
// notifyListeners();
// }
// String getDropDownValue(
// String value, SectionList sectionItem, List<InputClass> list) {
// int i = 0;
// String svalue = '';
// i = list.indexWhere((element) => element.id == value);
// if (i != -1) {
// svalue = list[i].name;
// } else {
// svalue = list[0].name;
// }
// return svalue;
// }
// Future<String> fetchData(InteractionResultData interactionResultData) async {
// InteractionResultData interactionConfig = interactionResultData;
// print("itemCategoryModel Item = + ${interactionConfig.result}");
// interactionReponseList = interactionConfig.result;
// print("check stored: $interactionReponseList");
// textEditingControllerList.clear();
// for (var item in interactionReponseList) {
// sectionList = item.sectionList;
// for (var sectionItem in item.sectionList) {
// if (sectionItem.widget == InteractionWidget.TEXT) {
// var textEditingController = TextEditingController();
// textEditingControllerList.add(textEditingController);
// sectionItem.controller = textEditingControllerList.last;
// }
// if (sectionItem.widget == InteractionWidget.DROPDOWN ||
// sectionItem.widget == InteractionWidget.AUTOCOMPLETE ||
// sectionItem.widget == InteractionWidget.MULTISELECT) {
// List<InputClass> list = sectionItem.inputList!;
// sectionItem.value = list[0].name;
// print("value : ${list.first} ");
// }
// }
// }
// print(interactionReponseList);
// print("check textcontrollers ${textEditingControllerList.length}");
// return "success";
// }
// Future<String> fetchLocationData() async {
// var data =
// await rootBundle.loadString("assets/images/locationdetailsform.json");
// Locations loc =
// Locations(location: Location.fromJson(json.decode(data)["location"]));
// locationList = loc.location;
// countryList = locationList.country;
// stateList = locationList.state;
// cityList = locationList.city;
// print(locationList);
// notifyListeners();
// return "success";
// }
// List<States> getState(String cid) {
// List<States> states =
// stateList.where((element) => element.countryId == cid).toList();
// return states;
// }
// List<City> getCity(String sid) {
// List<City> city =
// cityList.where((element) => element.stateId == sid).toList();
// return city;
// }
// String getCountryId(String name) {
// if (countryList.isNotEmpty) {
// int i = countryList.indexWhere((element) => element.countryName == name);
// return countryList[i].countryId;
// }
// return '';
// }
// String getStateId(String name) {
// if (stateList.isNotEmpty) {
// int i = stateList.indexWhere((element) => element.stateName == name);
// return stateList[i].stateId;
// }
// return '';
// }
// String getCityId(String name) {
// if (cityList.isNotEmpty) {
// int i = cityList.indexWhere((element) => element.cityName == name);
// return cityList[i].distId;
// }
// return '';
// }
// setRadioValue(SectionList sectionItem) {
// List<InputClass> list = (sectionItem.input as List)
// .map((itemWord) => InputClass.fromJson(itemWord))
// .toList();
// radioValue = list[0].name;
// notifyListeners();
// }
// setcheckBoxValue(SectionList sectionItem, String sectionName, bool newValue,
// String id, bool multiple) {
// int index =
// sectionItem.inputList!.indexWhere((element) => element.id == id);
// sectionItem.inputList![index].ischecked = newValue;
// // sectionItem.selectedValue.add(data[i].data[index].id);
// int index2 = 0;
// for (var obj in interactionReponseList) {
// if (multiple && obj.multipleList != null) {
// index2 = obj.multipleList!.indexWhere((element) =>
// element.id == sectionItem.id && element.gid == sectionItem.gid);
// if (index2 != -1) {
// obj.multipleList![index2].value = sectionItem.inputList![index].id;
// obj.multipleList![index2].selectedValue!
// .add(sectionItem.inputList![index].id);
// }
// } else {
// index2 = obj.sectionList
// .indexWhere((element) => element.id == sectionItem.id);
// if (index2 != -1) {
// obj.sectionList[index2].value = sectionItem.inputList![index].id;
// obj.sectionList[index2].selectedValue!
// .add(sectionItem.inputList![index].id);
// }
// }
// }
// notifyListeners();
// }
// getSectionItem(String sectionName) {
// newList = [];
// List<SectionList> addList = [];
// int index = interactionReponseList
// .indexWhere((element) => element.sectionName == sectionName);
// addList = interactionReponseList[index]
// .sectionList
// .map((e) => SectionList(
// depid: e.depid,
// id: e.id,
// inputList: e.inputList,
// isRequired: e.isRequired,
// name: e.name,
// param: e.param,
// selectedValue: [],
// widget: e.widget,
// controller: e.controller,
// gid: e.gid,
// input: e.input,
// selectedId: e.selectedId,
// value: e.value))
// .toList();
// SectionList delItem = SectionList(
// name: "delete",
// param: "deletebtn",
// id: "deletebtn",
// selectedValue: [],
// depid: "",
// widget: InteractionWidget.BUTTON,
// inputList: [],
// isRequired: true);
// addList.add(delItem);
// // if (interactionReponseList[index].multipleList!.isEmpty) {
// // newList = addList;
// // } else {
// if (interactionReponseList[index].multipleList == null) {
// interactionReponseList[index].multipleList = addList;
// } else {
// interactionReponseList[index].multipleList =
// interactionReponseList[index].multipleList! + addList;
// }
// newList = interactionReponseList[index].multipleList!;
// // newList = newList + addList;
// // }
// if (interactionReponseList[index].multipleList != null) {
// for (SectionList obj in interactionReponseList[index].multipleList!) {
// obj.gid = obj.gid ?? interactionReponseList[index].multipleList!.length;
// if (obj.widget == InteractionWidget.TEXT) {
// var textEditingController = TextEditingController();
// multipletextEditingControllerList.add(textEditingController);
// obj.controller = multipletextEditingControllerList.last;
// obj.controller!.text =
// obj.selectedValue != null && obj.selectedValue!.isNotEmpty
// ? obj.selectedValue!.last
// : '';
// }
// // newList.add(obj);
// }
// }
// print(
// "check length : ${interactionReponseList[index].multipleList!.length}");
// notifyListeners();
// }
// deleteMultipleRows(
// int gid, SectionList sectionItem, String selectedSectionName) {
// int index = interactionReponseList
// .indexWhere((element) => element.sectionName == selectedSectionName);
// interactionReponseList[index]
// .multipleList!
// .removeWhere((item) => item.gid == gid);
// notifyListeners();
// }
// saveJsonObject(BuildContext context, String form,
// SaveInteraction saveInteraction) async {
// List<FormFieldData> resultData = interactionReponseList
// .map((e) => FormFieldData(
// multipleList: e.multipleList == null
// ? []
// : e.multipleList!
// .map((mobj) => SectionList(
// depid: mobj.depid,
// id: mobj.id,
// inputList: mobj.inputList,
// isRequired: mobj.isRequired,
// extension: mobj.extension,
// fileName: mobj.fileName,
// name: mobj.name,
// param: mobj.param,
// selectedValue:
// mobj.tempselectedValue ?? mobj.selectedValue,
// widget: mobj.widget,
// gid: mobj.gid,
// input: mobj.input,
// selectedId: mobj.selectedId,
// value: mobj.value))
// .toList(),
// sectionList: e.sectionList
// .map((obj) => SectionList(
// depid: obj.depid,
// id: obj.id,
// inputList: obj.inputList,
// extension: obj.extension,
// fileName: obj.fileName,
// isRequired: obj.isRequired,
// name: obj.name,
// param: obj.param,
// selectedValue: obj.tempselectedValue ?? obj.selectedValue,
// widget: obj.widget,
// controller: obj.controller,
// gid: obj.gid,
// input: obj.input,
// selectedId: obj.selectedId,
// value: obj.value))
// .toList(),
// sectionName: e.sectionName,
// multiple: e.multiple,
// ))
// .toList();
// final data = SaveInteraction(
// save: resultData,
// id: saveInteraction.id,
// updatedTime: DateTime.now().toString(),
// form: saveInteraction.form,
// intId: saveInteraction.intId,
// intName: saveInteraction.intName,
// );
// var box = Hive.box<SaveInteraction>('InteractionDataBox');
// if (!box.isOpen) {
// box = await Hive.openBox<SaveInteraction>('InteractionDataBox');
// }
// int index =
// box.values.toList().indexWhere((element) => element.id == data.id);
// box.putAt(index, data);
// await getRecords(saveInteraction.form!);
// // box.close();
// // await MockApiCall().postFormData(data);
// }
// Future<void> deleteRecord(SaveInteraction saveInteraction) async {
// var box = await Hive.openBox<SaveInteraction>('InteractionDataBox');
// final Map<dynamic, SaveInteraction> deliveriesmap = box.toMap();
// dynamic deleteKey;
// deliveriesmap.forEach((key, value) {
// if (value.id == saveInteraction.id) {
// deleteKey = key;
// }
// });
// box.delete(deleteKey);
// await getRecords(saveInteraction.form!);
// //box.close();
// }
// List<MultipleSectionList> getModifiedList(List<SectionList> sectionList) {
// List<MultipleSectionList> newSectionList = [];
// for (var obj in sectionList) {
// if (obj.id != 'deletebtn') {
// if (obj.id == 'chooseFile') {
// List<MultipartFile> files = [];
// if (obj.selectedValue!.isNotEmpty && obj.selectedValue != null) {
// for (var file in obj.selectedValue!) {
// files.add(MultipartFile.fromFileSync(file));
// }
// }
// MultipleSectionList newobj = MultipleSectionList(
// id: obj.id,
// selectedValue: files,
// );
// newSectionList.add(newobj);
// } else {
// MultipleSectionList newobj = MultipleSectionList(
// id: obj.id,
// selectedValue: obj.selectedValue!,
// );
// newSectionList.add(newobj);
// }
// }
// }
// return newSectionList;
// }
// bool validateMultipleRows() {
// for (var obj in interactionReponseList) {
// if (obj.multipleList != null) {
// for (var mulobj in obj.multipleList!) {
// if (mulobj.widget == InteractionWidget.TEXT) {
// if (mulobj.controller!.text.isEmpty) {
// return true;
// }
// }
// }
// }
// }
// return false;
// }
// bool validateTextFields() {
// for (var obj in interactionReponseList) {
// for (var mulobj in obj.sectionList) {
// if (mulobj.widget == InteractionWidget.TEXT) {
// if (mulobj.controller!.text.isEmpty) {
// return true;
// }
// }
// }
// }
// return false;
// }
// }

View File

@ -42,6 +42,9 @@ class InteractionTextField extends StatelessWidget {
onChanged: (value) { onChanged: (value) {
onChanged(value); onChanged(value);
}, },
onSubmitted: (value) {
onChanged(value);
},
inputFormatters: [ inputFormatters: [
inputType == TextInputType.number inputType == TextInputType.number
? FilteringTextInputFormatter.digitsOnly ? FilteringTextInputFormatter.digitsOnly

View File

@ -8,7 +8,8 @@ class DataTableDemo extends StatefulWidget {
class _DataTableDemoState extends State<DataTableDemo> { class _DataTableDemoState extends State<DataTableDemo> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return SafeArea(
child: Scaffold(
body: ListView( body: ListView(
padding: const EdgeInsets.all(3), padding: const EdgeInsets.all(3),
children: [ children: [
@ -85,6 +86,7 @@ class _DataTableDemoState extends State<DataTableDemo> {
), ),
], ],
), ),
),
); );
} }
} }

View File

@ -14,7 +14,8 @@ class FormList extends StatefulWidget {
class _FormListState extends State<FormList> { class _FormListState extends State<FormList> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return SafeArea(
child: Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text("Form List"), title: Text("Form List"),
), ),
@ -97,6 +98,7 @@ class _FormListState extends State<FormList> {
Divider(), Divider(),
], ],
), ),
),
); );
} }
} }

View File

@ -14,7 +14,8 @@ class Profile extends StatefulWidget {
class _ProfileState extends State<Profile> { class _ProfileState extends State<Profile> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return SafeArea(
child: Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Text('Profile'), title: const Text('Profile'),
actions: const [ actions: const [
@ -193,7 +194,8 @@ class _ProfileState extends State<Profile> {
padding: EdgeInsets.only(bottom: 18.0), padding: EdgeInsets.only(bottom: 18.0),
child: Card( child: Card(
surfaceTintColor: Colors.white, surfaceTintColor: Colors.white,
margin: EdgeInsets.symmetric(horizontal: 15.0, vertical: 5.0), margin:
EdgeInsets.symmetric(horizontal: 15.0, vertical: 5.0),
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
color: Colors.white, color: Colors.white,
elevation: 5.0, elevation: 5.0,
@ -359,6 +361,7 @@ class _ProfileState extends State<Profile> {
child: new Icon(Icons.add), child: new Icon(Icons.add),
), ),
), ),
),
); );
} }
} }

View File

@ -1,5 +1,6 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'dart:js_interop';
import 'package:discover_module/custom_widget/floating_btn.dart'; import 'package:discover_module/custom_widget/floating_btn.dart';
import 'package:discover_module/custom_widget/show_alert.dart'; import 'package:discover_module/custom_widget/show_alert.dart';
@ -19,8 +20,9 @@ class Ranking extends StatefulWidget {
} }
class _RankingState extends State<Ranking> { class _RankingState extends State<Ranking> {
late _DataSource _dataSource; // Instance variable for _DataSource late _DataSource _dataSource;
List<int> selectedno = [];
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@ -28,10 +30,10 @@ class _RankingState extends State<Ranking> {
_dataSource = _DataSource(context); // Initialize _DataSource _dataSource = _DataSource(context); // Initialize _DataSource
} }
@override
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return SafeArea(
child: Scaffold(
body: ListView( body: ListView(
padding: const EdgeInsets.all(3), padding: const EdgeInsets.all(3),
children: [ children: [
@ -138,18 +140,24 @@ class _RankingState extends State<Ranking> {
child: FloatingBtn( child: FloatingBtn(
icon: Icons.add, icon: Icons.add,
title: "add", title: "add",
onTap: () { onTap: () async {
List<String> selectedRowIds = _dataSource.getSelectedRowIds(); List<int> selectedRowIds = _dataSource.getSelectedRowIds();
// Do something with selectedRowIds // Do something with selectedRowIds
print('Selected Row IDstrndsss: $selectedRowIds'); print('Selected Row IDstrndsss: $selectedRowIds');
for (int i = 0; i < selectedRowIds.length; i++) { for (int i = 0; i < selectedRowIds.length; i++) {
print('The id id : ${selectedRowIds[i]}');
print("checking_value_istrends: ${selectedRowIds[i]}"); print("checking_value_istrends: ${selectedRowIds[i]}");
// selectedno.add(selectedRowIds[i]);
HiveFunctions.addno(selectedRowIds[i]);
// _contactbox.put(i, selectedRowIds[i]); // _contactbox.put(i, selectedRowIds[i]);
HiveFunctions.createUser({ HiveFunctions.createUser({
"name": selectedRowIds[i], "name": "Gerosa,Gino",
"org": "Azienda Ospedaliera di Padova", "org": "Azienda Ospedaliera di Padova",
"adrr": "Via Giustiniani 2, Padova, Veneto 35128, Italy", "adrr": "Via Giustiniani 2, Padova, Veneto 35128, Italy",
"phone": "+390498212410X12", "phone": "+390498212410X12",
@ -168,6 +176,7 @@ class _RankingState extends State<Ranking> {
}); });
}, },
)), )),
),
); );
} }
@ -291,6 +300,7 @@ class HiveFunctions {
// String userHiveBox="User Box"; // String userHiveBox="User Box";
// Box which will use to store the things // Box which will use to store the things
static final _contactbox = Hive.box("mycontact"); static final _contactbox = Hive.box("mycontact");
static var box1 = Hive.box('checkvalue');
static createUser(Map data) { static createUser(Map data) {
_contactbox.add(data); _contactbox.add(data);
@ -337,11 +347,35 @@ class HiveFunctions {
return data.reversed.toList(); return data.reversed.toList();
} }
static addno(int selectedRowId) {
// final box1 = Hive.box("mycontact");
print("SelectedStoredvaluessss: $selectedRowId");
box1.add(selectedRowId);
}
static getno() {
// final box1 = Hive.box("mycontact");
return box1.values;
}
} }
class _Row { class _Row {
_Row(this.identifier, this.valueA, this.valueC, this.valueD, this.valueE, _Row(
this.valueF, this.valueG, this.valueH, this.valueI); this.identifier,
this.valueA,
this.valueC,
this.valueD,
this.valueE,
this.valueF,
this.valueG,
this.valueH,
this.valueI,
this.selected, // Add selected parameter
);
final int identifier; final int identifier;
final String valueA; final String valueA;
@ -360,17 +394,18 @@ class _DataSource extends DataTableSource {
final BuildContext context; final BuildContext context;
late List<_Row> _rows; late List<_Row> _rows;
// late List<int> _selectedRowsIndexes = []; // List to track selected rows // late List<int> _selectedRowsIndexes = []; // List to track selected rows
final List<String> _selectedRowIds = []; final List<int> _selectedRowIds = [];
_DataSource(this.context) { _DataSource(this.context) {
_rows = <_Row>[ _rows = <_Row>[
for (int i = 0; i < 20; i++) for (int i = 0; i < 20; i++)
_Row(i, 'Gerosa, Gino', 'Tier1', '1', '0', '0', '0', '0', '0'), _Row(
i, 'Gerosa, Gino', 'Tier1', '1', '0', '0', '0', '0', '0', check(i)),
]; ];
//} //}
} }
List<String> getSelectedRowIds() { List<int> getSelectedRowIds() {
return _selectedRowIds; // Return a copy to prevent direct modification return _selectedRowIds; // Return a copy to prevent direct modification
} }
@ -392,11 +427,11 @@ class _DataSource extends DataTableSource {
if (value) { if (value) {
print("Selected"); print("Selected");
_selectedRowIds.add(row.valueA); // Add the row ID to the list _selectedRowIds.add(row.identifier); // Add the row ID to the list
print("Selected_selectedRowIds :$_selectedRowIds"); print("Selected_selectedRowIds :$_selectedRowIds");
} else { } else {
_selectedRowIds _selectedRowIds
.remove(row.valueA); // Remove the row ID from the list .remove(row.identifier); // Remove the row ID from the list
} }
notifyListeners(); notifyListeners();
@ -433,4 +468,17 @@ class _DataSource extends DataTableSource {
@override @override
int get selectedRowCount => _selectedCount; int get selectedRowCount => _selectedCount;
bool check(int i) {
// print("I_am_i: $i");
print("_selectedRowIds_i: ${HiveFunctions.getno()}");
//HiveFunctions.getno();
if (HiveFunctions.getno().contains(i)) {
print("Iam_in: $i");
return true;
}
return false;
}
} }

View File

@ -23,7 +23,8 @@ class RisingStarState extends State<RisingStar> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return SafeArea(
child: Scaffold(
body: ListView( body: ListView(
padding: const EdgeInsets.all(3), padding: const EdgeInsets.all(3),
children: [ children: [
@ -131,6 +132,7 @@ class RisingStarState extends State<RisingStar> {
}); });
}, },
)), )),
),
); );
} }
} }

View File

@ -22,7 +22,8 @@ class _TrendsState extends State<Trends> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return SafeArea(
child: Scaffold(
body: ListView( body: ListView(
padding: const EdgeInsets.all(3), padding: const EdgeInsets.all(3),
children: [ children: [
@ -104,6 +105,7 @@ class _TrendsState extends State<Trends> {
}); });
}, },
)), )),
),
); );
} }
} }