mirror of
https://github.com/rainloreley/shlink-manager.git
synced 2024-11-13 23:05:14 +01:00
added logout feature
This commit is contained in:
parent
622496174c
commit
0357a4db6b
|
@ -27,6 +27,12 @@ class ServerManager {
|
||||||
return (_server_url != null);
|
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 {
|
Future<void> _loadCredentials() async {
|
||||||
const storage = FlutterSecureStorage();
|
const storage = FlutterSecureStorage();
|
||||||
_server_url = await storage.read(key: "shlink_url");
|
_server_url = await storage.read(key: "shlink_url");
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:shlink_app/API/Classes/ShlinkStats/ShlinkStats.dart';
|
import 'package:shlink_app/API/Classes/ShlinkStats/ShlinkStats.dart';
|
||||||
import 'package:shlink_app/API/ServerManager.dart';
|
import 'package:shlink_app/API/ServerManager.dart';
|
||||||
|
import 'package:shlink_app/LoginView.dart';
|
||||||
import 'package:shlink_app/ShortURLEditView.dart';
|
import 'package:shlink_app/ShortURLEditView.dart';
|
||||||
import 'globals.dart' as globals;
|
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]))
|
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(
|
SliverToBoxAdapter(
|
||||||
child: Wrap(
|
child: Wrap(
|
||||||
|
|
|
@ -62,7 +62,7 @@ class _LoginViewState extends State<LoginView> {
|
||||||
body: CustomScrollView(
|
body: CustomScrollView(
|
||||||
slivers: [
|
slivers: [
|
||||||
SliverAppBar.medium(
|
SliverAppBar.medium(
|
||||||
title: const Text("Add server")
|
title: const Text("Add server", style: TextStyle(fontWeight: FontWeight.bold))
|
||||||
),
|
),
|
||||||
SliverFillRemaining(
|
SliverFillRemaining(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
|
@ -73,19 +73,29 @@ class _LoginViewState extends State<LoginView> {
|
||||||
children: [
|
children: [
|
||||||
const Padding(padding: EdgeInsets.only(bottom: 8),
|
const Padding(padding: EdgeInsets.only(bottom: 8),
|
||||||
child: Text("Server URL", style: TextStyle(fontWeight: FontWeight.bold),)),
|
child: Text("Server URL", style: TextStyle(fontWeight: FontWeight.bold),)),
|
||||||
TextField(
|
Row(
|
||||||
|
children: [
|
||||||
|
Icon(Icons.dns_outlined),
|
||||||
|
SizedBox(width: 8),
|
||||||
|
Expanded(child: TextField(
|
||||||
controller: _server_url_controller,
|
controller: _server_url_controller,
|
||||||
keyboardType: TextInputType.url,
|
keyboardType: TextInputType.url,
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
labelText: "https://shlink.example.com"
|
labelText: "https://shlink.example.com"
|
||||||
),
|
),
|
||||||
|
))
|
||||||
|
],
|
||||||
),
|
),
|
||||||
const Padding(
|
const Padding(
|
||||||
padding: EdgeInsets.only(top: 8, bottom: 8),
|
padding: EdgeInsets.only(top: 8, bottom: 8),
|
||||||
child: Text("API Key", style: TextStyle(fontWeight: FontWeight.bold)),
|
child: Text("API Key", style: TextStyle(fontWeight: FontWeight.bold)),
|
||||||
),
|
),
|
||||||
TextField(
|
Row(
|
||||||
|
children: [
|
||||||
|
Icon(Icons.key),
|
||||||
|
SizedBox(width: 8),
|
||||||
|
Expanded(child: TextField(
|
||||||
controller: _apikey_controller,
|
controller: _apikey_controller,
|
||||||
keyboardType: TextInputType.text,
|
keyboardType: TextInputType.text,
|
||||||
obscureText: true,
|
obscureText: true,
|
||||||
|
@ -93,6 +103,8 @@ class _LoginViewState extends State<LoginView> {
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
labelText: "..."
|
labelText: "..."
|
||||||
),
|
),
|
||||||
|
))
|
||||||
|
],
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 16),
|
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),
|
padding: EdgeInsets.only(right: 4),
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 20,
|
width: 20,
|
||||||
height: 8,
|
height: 6,
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
@ -182,7 +182,7 @@ class _ListCellState extends State<_ListCell> {
|
||||||
else if (widget.content is DateTime)
|
else if (widget.content is DateTime)
|
||||||
Text(DateFormat('yyyy-MM-dd - HH:mm').format(widget.content))
|
Text(DateFormat('yyyy-MM-dd - HH:mm').format(widget.content))
|
||||||
else
|
else
|
||||||
Text("N/A")
|
const Text("N/A")
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -37,7 +37,7 @@ class MyApp extends StatelessWidget {
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
),
|
),
|
||||||
colorScheme: darkColorScheme?.copyWith(background: Colors.black, primary: Colors.blue) ?? _defaultDarkColorScheme,
|
colorScheme: darkColorScheme?.copyWith(background: Colors.black) ?? _defaultDarkColorScheme,
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
),
|
),
|
||||||
/*theme: ThemeData(
|
/*theme: ThemeData(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user