added link to shlink docs (create api key)

This commit is contained in:
Adrian Baumgart 2024-07-26 23:59:48 +02:00
parent e673dd7b64
commit 8507aaa8bd
No known key found for this signature in database

View File

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:shlink_app/API/server_manager.dart'; import 'package:shlink_app/API/server_manager.dart';
import 'package:shlink_app/main.dart'; import 'package:shlink_app/main.dart';
import 'package:url_launcher/url_launcher.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
class LoginView extends StatefulWidget { class LoginView extends StatefulWidget {
@ -58,6 +59,7 @@ class _LoginViewState extends State<LoginView> {
return Scaffold( return Scaffold(
extendBody: true, extendBody: true,
body: CustomScrollView( body: CustomScrollView(
physics: const NeverScrollableScrollPhysics(),
slivers: [ slivers: [
const SliverAppBar.medium( const SliverAppBar.medium(
title: Text("Add server", title: Text("Add server",
@ -65,79 +67,107 @@ class _LoginViewState extends State<LoginView> {
SliverFillRemaining( SliverFillRemaining(
child: Padding( child: Padding(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
child: Column( child: Stack(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
const Padding( Align(
padding: EdgeInsets.only(bottom: 8), child: Column(
child: Text(
"Server URL",
style: TextStyle(fontWeight: FontWeight.bold),
)),
Row(
children: [
const Icon(Icons.dns_outlined),
const SizedBox(width: 8),
Expanded(
child: TextField(
controller: _serverUrlController,
keyboardType: TextInputType.url,
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: "https://shlink.example.com"),
))
],
),
const Padding(
padding: EdgeInsets.only(top: 8, bottom: 8),
child: Text("API Key",
style: TextStyle(fontWeight: FontWeight.bold)),
),
Row(
children: [
const Icon(Icons.key),
const SizedBox(width: 8),
Expanded(
child: TextField(
controller: _apiKeyController,
keyboardType: TextInputType.text,
obscureText: true,
decoration: const InputDecoration(
border: OutlineInputBorder(), labelText: "..."),
))
],
),
Padding(
padding: const EdgeInsets.only(top: 16),
child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
FilledButton.tonal( const Padding(
onPressed: () => {_connect()}, padding: EdgeInsets.only(bottom: 8),
child: _isLoggingIn child: Text(
? Container( "Server URL",
style: TextStyle(fontWeight: FontWeight.bold),
)),
Row(
children: [
const Icon(Icons.dns_outlined),
const SizedBox(width: 8),
Expanded(
child: TextField(
controller: _serverUrlController,
keyboardType: TextInputType.url,
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: "https://shlink.example.com"),
))
],
),
const Padding(
padding: EdgeInsets.only(top: 8, bottom: 8),
child: Text("API Key",
style: TextStyle(fontWeight: FontWeight.bold)),
),
Row(
children: [
const Icon(Icons.key),
const SizedBox(width: 8),
Expanded(
child: TextField(
controller: _apiKeyController,
keyboardType: TextInputType.text,
obscureText: true,
decoration: const InputDecoration(
border: OutlineInputBorder(), labelText: "..."),
))
],
),
Padding(
padding: const EdgeInsets.only(top: 16),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
FilledButton.tonal(
onPressed: () => {_connect()},
child: _isLoggingIn
? Container(
width: 34, width: 34,
height: 34, height: 34,
padding: const EdgeInsets.all(4), padding: const EdgeInsets.all(4),
child: const CircularProgressIndicator(), child: const CircularProgressIndicator(),
) )
: const Text("Connect", : const Text("Connect",
style: TextStyle(fontSize: 20)), style: TextStyle(fontSize: 20)),
) )
],
),
),
Padding(
padding: const EdgeInsets.only(top: 16),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flexible(
child: Text(_errorMessage,
style: TextStyle(color: Theme.of(context).colorScheme.onError),
textAlign: TextAlign.center))
],
),
),
], ],
), ),
), ),
Padding( Align(
padding: const EdgeInsets.only(top: 16), alignment: Alignment.bottomCenter,
child: Row( child: TextButton(
mainAxisAlignment: MainAxisAlignment.center, onPressed: () async {
children: [ final Uri url = Uri.parse('https://shlink.io/documentation/api-docs/authentication/');
Flexible( try {
child: Text(_errorMessage, if (!await launchUrl(url)) {
style: TextStyle(color: Theme.of(context).colorScheme.onError), throw Exception();
textAlign: TextAlign.center)) }
], } catch (e) {
final snackBar = SnackBar(
content: Text("Unable to launch url. See Shlink docs for more information.",
style: TextStyle(color: Theme.of(context).colorScheme.onError)),
backgroundColor: Theme.of(context).colorScheme.error,
behavior: SnackBarBehavior.floating);
ScaffoldMessenger.of(context).showSnackBar(
snackBar);
}
},
child: Text("How to create an API Key"),
), ),
) )
], ],