81 lines
2.9 KiB
Dart
81 lines
2.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
import 'package:simplecloudnotifier/components/badge_display/badge_display.dart';
|
|
import 'package:simplecloudnotifier/state/app_auth.dart';
|
|
import 'package:simplecloudnotifier/utils/toaster.dart';
|
|
import 'package:simplecloudnotifier/utils/ui.dart';
|
|
|
|
class ShowTokenModal extends StatelessWidget {
|
|
final AppAuth account;
|
|
|
|
const ShowTokenModal({
|
|
Key? key,
|
|
required this.account,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AlertDialog(
|
|
title: const Text('UserID + Token'),
|
|
content: Container(
|
|
width: 9000,
|
|
height: 400,
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
const BadgeDisplay(
|
|
text: "Use your UserID and Send-Token to send messages to your account.\n\nThe Admin-Token should not be shared.",
|
|
icon: null,
|
|
mode: BadgeMode.warn,
|
|
),
|
|
const SizedBox(height: 16),
|
|
if (this.account.userID != null)
|
|
UI.metaCard(
|
|
context: context,
|
|
icon: FontAwesomeIcons.solidUser,
|
|
title: 'UserID',
|
|
values: [this.account.userID!],
|
|
iconActions: [(FontAwesomeIcons.copy, null, () => _copy('UserID', this.account.userID!))],
|
|
),
|
|
const SizedBox(height: 4),
|
|
if (this.account.tokenSend != null)
|
|
UI.metaCard(
|
|
context: context,
|
|
icon: FontAwesomeIcons.solidKey,
|
|
title: 'Send-Token',
|
|
values: [this.account.tokenSend!],
|
|
iconActions: [(FontAwesomeIcons.copy, null, () => _copy('Send-Token', this.account.tokenSend!))],
|
|
),
|
|
const SizedBox(height: 4),
|
|
if (this.account.tokenSend != null)
|
|
UI.metaCard(
|
|
context: context,
|
|
icon: FontAwesomeIcons.solidKey,
|
|
title: 'Admin-Token',
|
|
values: [this.account.tokenAdmin!],
|
|
iconActions: [(FontAwesomeIcons.copy, null, () => _copy('Admin-Token', this.account.tokenAdmin!))],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
actions: <Widget>[
|
|
TextButton(
|
|
child: const Text('Close'),
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
void _copy(String txt, String v) {
|
|
Clipboard.setData(new ClipboardData(text: v));
|
|
Toaster.info("Clipboard", 'Copied ${txt} to Clipboard');
|
|
print('================= [CLIPBOARD] =================\n${v}\n================= [/CLIPBOARD] =================');
|
|
}
|
|
}
|