diff --git a/lib/main.dart b/lib/main.dart index f9713e6..192c590 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -88,6 +88,7 @@ class _MyHomePageState extends State { var _fetched = false; var _fetchedCount = 0; var _knownPostsSize = -1; + var _isDemoUser = false; List _feedFilter = []; Future refresh() async { @@ -136,6 +137,11 @@ class _MyHomePageState extends State { @override void initState() { super.initState(); + + setState(() { + _isDemoUser = widget.prefs.getBool("isDemo") ?? false; + }); + refresh().then((_) => setState(() { _fetched = true; })); @@ -204,6 +210,47 @@ class _MyHomePageState extends State { appBar: AppBar( title: Text(widget.title), actions: [ + _isDemoUser + ? ElevatedButton( + onPressed: () { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text("Connected to demo server"), + content: RichText(text: TextSpan( + children: [ + const TextSpan( + text: "You are currently connected to the demo server.\n" + "Use the" + ), + WidgetSpan(child: Icon(Icons.adaptive.more, size: 20), + ), + const TextSpan( + text: "button in the top right to log out and switch " + "to your own instance once you're done exploring." + ), + ], + )), + actions: [ + TextButton( + onPressed: () => Navigator.of(context).pop(), + child: const Text("Got it!"), + ), + ], + ), + ); + }, + style: ElevatedButton.styleFrom( + backgroundColor: const Color.fromARGB(255, 114, 77, 7), + foregroundColor: Colors.amber, + ), + child: Row(children: const [ + Icon(Icons.warning), + SizedBox(width: 8), + Text("Demo"), + ]) + ) + : Container(), IconButton( onPressed: () { var theme = Theme.of(context); @@ -290,7 +337,8 @@ class _MyHomePageState extends State { value: "feedback", child: const Text("Feedback"), onTap: () async { - await openUrl(context, "https://git.amogus.cloud/Lea/feet/issues"); + await openUrl(context, + "https://git.amogus.cloud/Lea/feet/issues"); }, ), ]),