import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import '../../storage/base/settingsProvider.dart';
import 'jsonViewer.dart';

class DebugTile {
  Map<String, dynamic> data;

  DebugTile(this.data);

  Widget asTile(BuildContext context, {bool ignoreConfig = false}) {
    return Visibility(
      visible: Provider.of<SettingsProvider>(context).val().devToolsEnabled || ignoreConfig,
      child: ListTile(
        leading: const Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [Icon(Icons.data_object)],
        ),
        title: const Text("JSON daten anzeigen"),
        subtitle: const Text("Entwicklermodus aktiviert"),
        onTap: () => JsonViewer.asDialog(context, data),
      ),
    );
  }
}