Add warning when connected to demo server

This commit is contained in:
Lea 2023-02-05 17:40:06 +01:00
parent ca3f89c31e
commit 30904ecc21
Signed by: Lea
GPG key ID: 1BAFFE8347019C42

View file

@ -88,6 +88,7 @@ class _MyHomePageState extends State<MyHomePage> {
var _fetched = false;
var _fetchedCount = 0;
var _knownPostsSize = -1;
var _isDemoUser = false;
List<int> _feedFilter = [];
Future<void> refresh() async {
@ -136,6 +137,11 @@ class _MyHomePageState extends State<MyHomePage> {
@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<MyHomePage> {
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<MyHomePage> {
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");
},
),
]),