qrSharedDialog static method

void qrSharedDialog(
  1. BuildContext context,
  2. HollisticMatchScoutingData match
)

Implementation

static void qrSharedDialog(
    BuildContext context, HollisticMatchScoutingData match) {
  Widget qr = _createPrettyQrDataWidget(data: match.csvData);
  Widget? commentsQr;
  if (match.comments.isNotEmpty) {
    commentsQr =
        _createPrettyQrDataWidget(data: match.commentsCSVData);
  }
  Navigator.of(context).push(
    MaterialPageRoute<void>(
      builder: (BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: const Text("QR Share (Non-DUC)"),
          ),
          body: SingleChildScrollView(
            physics: const AlwaysScrollableScrollPhysics(
                parent: BouncingScrollPhysics()),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                const SizedBox(height: 20),
                const InformationalHintsBlob(
                    "Show to a scouting leader",
                    "A scouting leader will be able to help you with collecting data. Data here is encoded in a CSV format"),
                if (commentsQr != null)
                  const WarningHintsBlob("Comments are separated!",
                      "Due to technical limitations, comments are scanned separately (scroll down)")
                else
                  const InformationalHintsBlob("No Comments Data",
                      "This match didn't have any comments attached to it."),
                const SizedBox(height: 20),
                const Text("Match Data",
                    style: TextStyle(
                        fontSize: 24, fontWeight: FontWeight.bold)),
                const SizedBox(height: 8),
                FilledButton.tonalIcon(
                    onPressed: () async => await Clipboard.setData(
                        ClipboardData(text: match.csvData)),
                    icon: const Icon(Icons.copy_rounded),
                    label: const Text("Copy")),
                const SizedBox(height: 8),
                GestureDetector(
                  onTap: () async => launchConfirmDialog(context,
                      message: SizedBox(
                          width: 512, height: 512, child: qr),
                      onConfirm: () {},
                      title: "QR (Non-DUC)",
                      icon: const Icon(Icons.qr_code_rounded)),
                  child: Container(
                    width: 512,
                    height: 512,
                    decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(8),
                        color: Colors.black),
                    child: Padding(
                      padding: const EdgeInsets.all(24),
                      child: qr,
                    ),
                  ),
                ),
                if (commentsQr != null) const Divider(),
                if (commentsQr != null)
                  const Text("Comments Data",
                      style: TextStyle(
                          fontSize: 24,
                          fontWeight: FontWeight.bold)),
                if (commentsQr != null)
                  Padding(
                    padding: const EdgeInsets.all(12.0),
                    child: TextField(
                      controller: TextEditingController(
                          text: match.comments.comment),
                      readOnly: true,
                      decoration: const InputDecoration(
                        labelText: "Comments View",
                        border: OutlineInputBorder(),
                      ),
                    ),
                  ),
                if (commentsQr != null)
                  FilledButton.tonalIcon(
                      onPressed: () async =>
                          await Clipboard.setData(ClipboardData(
                              text: match.commentsCSVData)),
                      icon: const Icon(Icons.copy_rounded),
                      label: const Text("Copy")),
                const SizedBox(height: 8),
                if (commentsQr != null)
                  GestureDetector(
                    onTap: () async => launchConfirmDialog(context,
                        message: SizedBox(
                            width: 512,
                            height: 512,
                            child: commentsQr),
                        onConfirm: () {},
                        title: "Comments Data (QR)",
                        icon: const Icon(Icons.qr_code_rounded)),
                    child: Container(
                      width: 512,
                      height: 512,
                      decoration: BoxDecoration(
                          borderRadius: BorderRadius.circular(8),
                          color: Colors.black),
                      child: Padding(
                        padding: const EdgeInsets.all(24),
                        child: commentsQr,
                      ),
                    ),
                  ),
              ],
            ),
          ),
        );
      },
    ),
  );
}