mirror of
https://github.com/rainloreley/shlink-manager.git
synced 2024-11-09 13:55:12 +01:00
added logout feature
This commit is contained in:
parent
622496174c
commit
0357a4db6b
|
@ -27,6 +27,12 @@ class ServerManager {
|
|||
return (_server_url != null);
|
||||
}
|
||||
|
||||
Future<void> logOut() async {
|
||||
const storage = FlutterSecureStorage();
|
||||
await storage.delete(key: "shlink_url");
|
||||
await storage.delete(key: "shlink_apikey");
|
||||
}
|
||||
|
||||
Future<void> _loadCredentials() async {
|
||||
const storage = FlutterSecureStorage();
|
||||
_server_url = await storage.read(key: "shlink_url");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:shlink_app/API/Classes/ShlinkStats/ShlinkStats.dart';
|
||||
import 'package:shlink_app/API/ServerManager.dart';
|
||||
import 'package:shlink_app/LoginView.dart';
|
||||
import 'package:shlink_app/ShortURLEditView.dart';
|
||||
import 'globals.dart' as globals;
|
||||
|
||||
|
@ -57,6 +58,25 @@ class _HomeViewState extends State<HomeView> {
|
|||
Text(globals.serverManager.getServerUrl(), style: TextStyle(fontSize: 16, color: Colors.grey[600]))
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
PopupMenuButton(
|
||||
itemBuilder: (context) {
|
||||
return [
|
||||
PopupMenuItem(
|
||||
value: 0,
|
||||
child: Text("Log out...", style: TextStyle(color: Colors.red)),
|
||||
)
|
||||
];
|
||||
},
|
||||
onSelected: (value) {
|
||||
if (value == 0) {
|
||||
globals.serverManager.logOut().then((value) => Navigator.of(context).pushReplacement(
|
||||
MaterialPageRoute(builder: (context) => const LoginView())
|
||||
));
|
||||
}
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: Wrap(
|
||||
|
|
|
@ -62,7 +62,7 @@ class _LoginViewState extends State<LoginView> {
|
|||
body: CustomScrollView(
|
||||
slivers: [
|
||||
SliverAppBar.medium(
|
||||
title: const Text("Add server")
|
||||
title: const Text("Add server", style: TextStyle(fontWeight: FontWeight.bold))
|
||||
),
|
||||
SliverFillRemaining(
|
||||
child: Padding(
|
||||
|
@ -73,26 +73,38 @@ class _LoginViewState extends State<LoginView> {
|
|||
children: [
|
||||
const Padding(padding: EdgeInsets.only(bottom: 8),
|
||||
child: Text("Server URL", style: TextStyle(fontWeight: FontWeight.bold),)),
|
||||
TextField(
|
||||
controller: _server_url_controller,
|
||||
keyboardType: TextInputType.url,
|
||||
decoration: const InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: "https://shlink.example.com"
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.dns_outlined),
|
||||
SizedBox(width: 8),
|
||||
Expanded(child: TextField(
|
||||
controller: _server_url_controller,
|
||||
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)),
|
||||
),
|
||||
TextField(
|
||||
controller: _apikey_controller,
|
||||
keyboardType: TextInputType.text,
|
||||
obscureText: true,
|
||||
decoration: const InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: "..."
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.key),
|
||||
SizedBox(width: 8),
|
||||
Expanded(child: TextField(
|
||||
controller: _apikey_controller,
|
||||
keyboardType: TextInputType.text,
|
||||
obscureText: true,
|
||||
decoration: const InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: "..."
|
||||
),
|
||||
))
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 16),
|
||||
|
|
|
@ -169,7 +169,7 @@ class _ShortURLEditViewState extends State<ShortURLEditView> with SingleTickerPr
|
|||
});
|
||||
|
||||
},
|
||||
icon: Icon(randomSlug ? Icons.casino : Icons.casino_outlined, color: randomSlug ? Colors.green : Theme.of(context).primaryColor,)
|
||||
icon: Icon(randomSlug ? Icons.casino : Icons.casino_outlined, color: randomSlug ? Colors.green : Colors.grey)
|
||||
),
|
||||
)
|
||||
],
|
||||
|
|
|
@ -160,7 +160,7 @@ class _ListCellState extends State<_ListCell> {
|
|||
padding: EdgeInsets.only(right: 4),
|
||||
child: SizedBox(
|
||||
width: 20,
|
||||
height: 8,
|
||||
height: 6,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
|
@ -182,7 +182,7 @@ class _ListCellState extends State<_ListCell> {
|
|||
else if (widget.content is DateTime)
|
||||
Text(DateFormat('yyyy-MM-dd - HH:mm').format(widget.content))
|
||||
else
|
||||
Text("N/A")
|
||||
const Text("N/A")
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -37,7 +37,7 @@ class MyApp extends StatelessWidget {
|
|||
foregroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
),
|
||||
colorScheme: darkColorScheme?.copyWith(background: Colors.black, primary: Colors.blue) ?? _defaultDarkColorScheme,
|
||||
colorScheme: darkColorScheme?.copyWith(background: Colors.black) ?? _defaultDarkColorScheme,
|
||||
useMaterial3: true,
|
||||
),
|
||||
/*theme: ThemeData(
|
||||
|
|
Loading…
Reference in New Issue
Block a user