added debug windows
This commit is contained in:
@ -17,6 +17,7 @@ import 'package:rogapp/utils/const.dart';
|
|||||||
import 'package:rogapp/utils/database_helper.dart';
|
import 'package:rogapp/utils/database_helper.dart';
|
||||||
import 'package:rogapp/utils/text_util.dart';
|
import 'package:rogapp/utils/text_util.dart';
|
||||||
import 'package:rogapp/widgets/bottom_sheet_controller.dart';
|
import 'package:rogapp/widgets/bottom_sheet_controller.dart';
|
||||||
|
import 'package:rogapp/widgets/debug_widget.dart';
|
||||||
import 'package:sqflite/sqflite.dart';
|
import 'package:sqflite/sqflite.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
@ -396,6 +397,13 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
|||||||
destinationController.currentLat, destinationController.currentLon),
|
destinationController.currentLat, destinationController.currentLon),
|
||||||
LatLng(cdest.lat!, cdest.lon!));
|
LatLng(cdest.lat!, cdest.lon!));
|
||||||
|
|
||||||
|
LogManager().addLog("Distance from current point : $distanceToDest");
|
||||||
|
LogManager().addLog(
|
||||||
|
"forced distance for point : ${destinationController.getForcedChckinDistance(destination)}");
|
||||||
|
LogManager().addLog("is already checked in : $isAlreadyCheckedIn");
|
||||||
|
LogManager().addLog("Checkin radius : ${destination.checkin_radious}");
|
||||||
|
LogManager().addLog("--${destination.cp}--");
|
||||||
|
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
134
lib/widgets/debug_widget.dart
Normal file
134
lib/widgets/debug_widget.dart
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class LogManager {
|
||||||
|
static final LogManager _instance = LogManager._internal();
|
||||||
|
|
||||||
|
factory LogManager() {
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
LogManager._internal();
|
||||||
|
|
||||||
|
List<String> _logs = [];
|
||||||
|
List<VoidCallback> _listeners = [];
|
||||||
|
|
||||||
|
List<String> get logs => _logs;
|
||||||
|
|
||||||
|
void addLog(String log) {
|
||||||
|
_logs.add(log);
|
||||||
|
_notifyListeners(); // Notify all listeners
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearLogs() {
|
||||||
|
_logs.clear();
|
||||||
|
_notifyListeners(); // Notify all listeners
|
||||||
|
}
|
||||||
|
|
||||||
|
void addListener(VoidCallback listener) {
|
||||||
|
_listeners.add(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
void removeListener(VoidCallback listener) {
|
||||||
|
_listeners.remove(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _notifyListeners() {
|
||||||
|
for (var listener in _listeners) {
|
||||||
|
listener();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DebugWidget extends StatefulWidget {
|
||||||
|
const DebugWidget({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<DebugWidget> createState() => _DebugWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DebugWidgetState extends State<DebugWidget> {
|
||||||
|
final LogManager logManager = LogManager();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
logManager.addListener(_updateLogs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
logManager.removeListener(_updateLogs);
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _updateLogs() {
|
||||||
|
Future.delayed(Duration.zero, () {
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void toggleExpanded() {
|
||||||
|
setState(() {
|
||||||
|
isExpanded = !isExpanded;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearLogs() {
|
||||||
|
logManager.clearLogs();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isExpanded = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Positioned(
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: 0,
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: toggleExpanded,
|
||||||
|
child: AnimatedContainer(
|
||||||
|
duration: Duration(milliseconds: 200),
|
||||||
|
color: Colors.black54,
|
||||||
|
height: isExpanded ? 450.0 : 50.0, // Adjust sizes as needed
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
// Top bar with clear button
|
||||||
|
if (isExpanded)
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 10.0),
|
||||||
|
color: Colors.blueGrey, // Adjust color as needed
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text('Debug Logs', style: TextStyle(color: Colors.white)),
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.clear, color: Colors.white),
|
||||||
|
onPressed: clearLogs,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// Log messages
|
||||||
|
Expanded(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: logManager.logs.reversed
|
||||||
|
.map((log) => Text(
|
||||||
|
"${DateTime.now().hour}:${DateTime.now().minute}:${DateTime.now().second}:${DateTime.now().microsecond} - $log",
|
||||||
|
style: const TextStyle(color: Colors.white)))
|
||||||
|
.toList(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -14,6 +14,7 @@ import 'package:rogapp/utils/database_helper.dart';
|
|||||||
import 'package:rogapp/utils/text_util.dart';
|
import 'package:rogapp/utils/text_util.dart';
|
||||||
import 'package:rogapp/widgets/base_layer_widget.dart';
|
import 'package:rogapp/widgets/base_layer_widget.dart';
|
||||||
import 'package:rogapp/widgets/bottom_sheet_new.dart';
|
import 'package:rogapp/widgets/bottom_sheet_new.dart';
|
||||||
|
import 'package:rogapp/widgets/debug_widget.dart';
|
||||||
|
|
||||||
class MapWidget extends StatelessWidget {
|
class MapWidget extends StatelessWidget {
|
||||||
final IndexController indexController = Get.find<IndexController>();
|
final IndexController indexController = Get.find<IndexController>();
|
||||||
@ -228,7 +229,12 @@ class MapWidget extends StatelessWidget {
|
|||||||
)
|
)
|
||||||
: const Center(child: CircularProgressIndicator()),
|
: const Center(child: CircularProgressIndicator()),
|
||||||
],
|
],
|
||||||
))
|
)),
|
||||||
|
const Positioned(
|
||||||
|
bottom: 10,
|
||||||
|
left: 0,
|
||||||
|
child: DebugWidget(),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user