update for permission and destination ordering

This commit is contained in:
Mohamed Nouffer
2023-01-19 16:39:25 +05:30
parent 07653e9b9e
commit cf14a85eaf
5 changed files with 99 additions and 40 deletions

View File

@ -643,6 +643,25 @@ class DestinationController extends GetxController {
}
void toggleSelection(Destination dest) async {
DatabaseHelper db = DatabaseHelper.instance;
await db.toggleSelecttion(dest);
destinations.clear();
db.getDestinations().then((value){
destinationCount.value = 0;
currentSelectedDestinations.clear();
for(Destination d in value){
//print("------ destination controller populating destination-------- ${d.checkedin}-------- :::::");
//print("-----populated----- ${d.toMap()}");
if(d.selected!){
currentSelectedDestinations.add(d);
}
destinations.add(d);
}
destinationCount.value = destinations.length;
});
}
void PopulateDestinations(){
print("--------- destination controller populsting destinations ----------- ::::::");

View File

@ -12,6 +12,7 @@ class PermissionHandlerScreen extends StatefulWidget {
class _PermissionHandlerScreenState extends State<PermissionHandlerScreen> {
Future<void> _showMyDialog() async {
return showDialog<void>(
context: context,
@ -45,10 +46,15 @@ class _PermissionHandlerScreenState extends State<PermissionHandlerScreen> {
void initState() {
// TODO: implement initState
super.initState();
permissionServiceCall();
//permissionServiceCall();
}
permissionServiceCall() async {
Future<PermissionStatus> checkLocationPermission() async {
return await Permission.location.status;
}
permissionServiceCall() async {
await permissionServices().then(
(value) {
if (value != null) {
@ -106,11 +112,45 @@ class _PermissionHandlerScreenState extends State<PermissionHandlerScreen> {
@override
Widget build(BuildContext context) {
return Container(
color: Colors.white,
child: Center(
child: Text(""),
),
var status = Permission.location.status.then((value){
if(value.isGranted == false){
Future.delayed(Duration.zero, () => showAlert(context));
}
else {
Get.toNamed(AppPages.TRAVEL);
}
});
return Scaffold(
body: Container(
child: Text(""),
),
);
}
void showAlert(BuildContext context) {
showDialog(
context: context,
builder: (_) => AlertDialog(
title: const Text('ロケーション許可'),
content: SingleChildScrollView(
child: ListBody(
children: const <Widget>[
Text( 'このアプリでは、位置情報の収集を行います。'),
Text('岐阜ナビアプリではチェックポイントの自動チェックインの機能を可能にするために、現在地のデータが収集されます。アプリを閉じている時や、使用していないときにも収集されます。位置情報は、個人を特定できない統計的な情報として、ユーザーの個人情報とは一切結びつかない形で送信されます。お知らせの配信、位置情報の利用を許可しない場合は、この後表示されるダイアログで「許可しない」を選択してください。'),
],
),
),
actions: <Widget>[
TextButton(
child: const Text('わかった'),
onPressed: () {
permissionServiceCall();
},
),
],
)
);
}
}

View File

@ -98,6 +98,35 @@ class DatabaseHelper{
return roglist;
}
Future clearSelection() async {
Database db = await instance.database;
Map<String, dynamic> row_clear = {
"selected": false
};
return await db.update(
"destination",
row_clear
);
}
Future<int> toggleSelecttion(Destination dest) async {
Database db = await instance.database;
bool val = !dest.selected!;
Map<String, dynamic> row_target = {
"selected": val
};
await clearSelection();
return await db.update(
"destination",
row_target,
where: 'location_id = ?',
whereArgs: [dest.location_id!]
);
}
Future<int> deleteRogaining(int id) async {
Database db = await instance.database;
var rog = await db.delete('rog', where: "id = ${id}");

View File

@ -8,6 +8,7 @@ import 'package:rogapp/utils/const.dart';
import 'package:rogapp/utils/database_helper.dart';
import 'package:rogapp/widgets/bottom_sheet_new.dart';
import 'package:rogapp/widgets/bottom_sheet_widget.dart';
import 'package:sqflite/sqlite_api.dart';
import 'package:timeline_tile/timeline_tile.dart';
class DestinationWidget extends StatelessWidget {
@ -176,7 +177,7 @@ class DestinationWidget extends StatelessWidget {
onTap: () async {
{
Destination? fs = destinationController.destinations[index];
print("----fsf-----${fs.location_id}");
print("----fsf-----${index}");
if(fs != null){
if(indexController.currentDestinationFeature.isNotEmpty) {
@ -194,37 +195,7 @@ class DestinationWidget extends StatelessWidget {
};
},
onLongPress: (){
for(Destination d in destinationController.destinations){
if(destinationController.currentSelectedDestinations.length > 0){
if(destinationController.currentSelectedDestinations[0].location_id == destinationController.destinations[index].location_id){
destinationController.currentSelectedDestinations.clear();
print("---- found ----");
destinationController.PopulateDestinations();
return;
}
}
}
destinationController.currentSelectedDestinations.clear();
destinationController.currentSelectedDestinations.add(destinationController.destinations[index]);
// Destination? match_element = null;
// destinationController.currentSelectedDestinations.forEach((element) {
// if(element.location_id == destinationController.destinations[index].location_id){
// match_element = element;
// return;
// }
// });
// if(match_element != null){
// destinationController.currentSelectedDestinations.remove(destinationController.destinations[index]);
// }
// //destinationController.currentSelectedDestinations.clear();
// destinationController.currentSelectedDestinations.add(destinationController.destinations[index]);
destinationController.PopulateDestinations();
destinationController.toggleSelection(destinationController.destinations[index]);
},
selectedTileColor: Colors.amberAccent,
selected:destinationController.destinations[index].selected!,

View File

@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.2+2
version: 1.0.3+3
environment:
sdk: ">=2.16.0 <3.0.0"