mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
Credit section addition in the Settings page
This commit is contained in:
parent
e2288ac2d7
commit
44b1921171
@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:spotube/components/Shared/Hyperlink.dart';
|
||||
import 'package:spotube/components/Shared/PageWindowTitleBar.dart';
|
||||
import 'package:spotube/main.dart';
|
||||
import 'package:spotube/models/LocalStorageKeys.dart';
|
||||
@ -128,17 +129,58 @@ class _SettingsState extends State<Settings> {
|
||||
const SizedBox(height: 10),
|
||||
Builder(builder: (context) {
|
||||
var auth = context.read<Auth>();
|
||||
return ElevatedButton(
|
||||
child: const Text("Logout"),
|
||||
onPressed: () async {
|
||||
SharedPreferences localStorage =
|
||||
await SharedPreferences.getInstance();
|
||||
await localStorage.clear();
|
||||
auth.logout();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text("Log out of this account"),
|
||||
ElevatedButton(
|
||||
child: const Text("Logout"),
|
||||
onPressed: () async {
|
||||
SharedPreferences localStorage =
|
||||
await SharedPreferences.getInstance();
|
||||
await localStorage.clear();
|
||||
auth.logout();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
})
|
||||
}),
|
||||
const SizedBox(height: 40),
|
||||
const Text("Spotube v1.1.0"),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const [
|
||||
Text("Author: "),
|
||||
Hyperlink(
|
||||
"Kingkor Roy Tirtho",
|
||||
"https://github.com/KRTirtho",
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const [
|
||||
Hyperlink(
|
||||
"Sponsor/Donate",
|
||||
"https://opencollective.com/spotube",
|
||||
),
|
||||
Text(" • "),
|
||||
Hyperlink(
|
||||
"BSD 4-Clause LICENSE",
|
||||
"https://github.com/KRTirtho/spotube/blob/master/LICENSE",
|
||||
),
|
||||
Text(" • "),
|
||||
Hyperlink(
|
||||
"Bug Report",
|
||||
"https://github.com/KRTirtho/spotube/issues/new?assignees=&labels=bug&template=bug_report.md&title=",
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const Text("© Spotube 2022. All rights reserved")
|
||||
],
|
||||
),
|
||||
),
|
||||
|
48
lib/components/Shared/AnchorButton.dart
Normal file
48
lib/components/Shared/AnchorButton.dart
Normal file
@ -0,0 +1,48 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AnchorButton<T> extends StatefulWidget {
|
||||
final String text;
|
||||
final TextStyle style;
|
||||
final TextAlign? textAlign;
|
||||
final TextOverflow? overflow;
|
||||
final void Function()? onTap;
|
||||
|
||||
const AnchorButton(
|
||||
this.text, {
|
||||
Key? key,
|
||||
this.onTap,
|
||||
this.textAlign,
|
||||
this.overflow,
|
||||
this.style = const TextStyle(),
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AnchorButton<T>> createState() => _AnchorButtonState<T>();
|
||||
}
|
||||
|
||||
class _AnchorButtonState<T> extends State<AnchorButton<T>> {
|
||||
bool _hover = false;
|
||||
bool _tap = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
child: MouseRegion(
|
||||
cursor: MaterialStateMouseCursor.clickable,
|
||||
child: Text(
|
||||
widget.text,
|
||||
style: widget.style.copyWith(
|
||||
decoration: _hover || _tap ? TextDecoration.underline : null,
|
||||
),
|
||||
textAlign: widget.textAlign,
|
||||
overflow: widget.overflow,
|
||||
),
|
||||
onEnter: (event) => setState(() => _hover = true),
|
||||
onExit: (event) => setState(() => _hover = false),
|
||||
),
|
||||
onTapDown: (event) => setState(() => _tap = true),
|
||||
onTapUp: (event) => setState(() => _tap = false),
|
||||
onTap: widget.onTap,
|
||||
);
|
||||
}
|
||||
}
|
33
lib/components/Shared/Hyperlink.dart
Normal file
33
lib/components/Shared/Hyperlink.dart
Normal file
@ -0,0 +1,33 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:spotube/components/Shared/AnchorButton.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class Hyperlink extends StatelessWidget {
|
||||
final String text;
|
||||
final TextStyle style;
|
||||
final TextAlign? textAlign;
|
||||
final TextOverflow? overflow;
|
||||
final String url;
|
||||
const Hyperlink(
|
||||
this.text,
|
||||
this.url, {
|
||||
Key? key,
|
||||
this.textAlign,
|
||||
this.overflow,
|
||||
this.style = const TextStyle(),
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnchorButton(
|
||||
text,
|
||||
onTap: () async {
|
||||
await launch(url);
|
||||
},
|
||||
key: key,
|
||||
overflow: overflow,
|
||||
style: style.copyWith(color: Colors.blue),
|
||||
textAlign: textAlign,
|
||||
);
|
||||
}
|
||||
}
|
@ -1,50 +1,32 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:spotube/components/Shared/AnchorButton.dart';
|
||||
|
||||
class LinkText<T> extends StatefulWidget {
|
||||
class LinkText<T> extends StatelessWidget {
|
||||
final String text;
|
||||
final TextStyle style;
|
||||
final TextAlign? textAign;
|
||||
final TextAlign? textAlign;
|
||||
final TextOverflow? overflow;
|
||||
final Route<T> route;
|
||||
|
||||
const LinkText(
|
||||
this.text,
|
||||
this.route, {
|
||||
Key? key,
|
||||
this.textAign,
|
||||
this.textAlign,
|
||||
this.overflow,
|
||||
this.style = const TextStyle(),
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<LinkText<T>> createState() => _LinkTextState<T>();
|
||||
}
|
||||
|
||||
class _LinkTextState<T> extends State<LinkText<T>> {
|
||||
bool _hover = false;
|
||||
bool _tap = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
child: MouseRegion(
|
||||
cursor: MaterialStateMouseCursor.clickable,
|
||||
child: Text(
|
||||
widget.text,
|
||||
style: widget.style.copyWith(
|
||||
decoration: _hover || _tap ? TextDecoration.underline : null,
|
||||
),
|
||||
textAlign: widget.textAign,
|
||||
overflow: widget.overflow,
|
||||
),
|
||||
onEnter: (event) => setState(() => _hover = true),
|
||||
onExit: (event) => setState(() => _hover = false),
|
||||
),
|
||||
onTapDown: (event) => setState(() => _tap = true),
|
||||
onTapUp: (event) => setState(() => _tap = false),
|
||||
onTap: () {
|
||||
Navigator.of(context).push(widget.route);
|
||||
return AnchorButton(
|
||||
text,
|
||||
onTap: () async {
|
||||
await Navigator.of(context).push(route);
|
||||
},
|
||||
key: key,
|
||||
overflow: overflow,
|
||||
style: style,
|
||||
textAlign: textAlign,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:bitsdojo_window/bitsdojo_window.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@ -59,7 +61,7 @@ class PageWindowTitleBar extends StatelessWidget
|
||||
children: [
|
||||
if (leading != null) leading!,
|
||||
Expanded(child: MoveWindow(child: Center(child: center))),
|
||||
const TitleBarActionButtons()
|
||||
if (!Platform.isMacOS) const TitleBarActionButtons()
|
||||
],
|
||||
),
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user