diff --git a/lib/components/Settings.dart b/lib/components/Settings.dart index 517e0b46..e3c70693 100644 --- a/lib/components/Settings.dart +++ b/lib/components/Settings.dart @@ -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 { const SizedBox(height: 10), Builder(builder: (context) { var auth = context.read(); - 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") ], ), ), diff --git a/lib/components/Shared/AnchorButton.dart b/lib/components/Shared/AnchorButton.dart new file mode 100644 index 00000000..c02d82fa --- /dev/null +++ b/lib/components/Shared/AnchorButton.dart @@ -0,0 +1,48 @@ +import 'package:flutter/material.dart'; + +class AnchorButton 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> createState() => _AnchorButtonState(); +} + +class _AnchorButtonState extends State> { + 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, + ); + } +} diff --git a/lib/components/Shared/Hyperlink.dart b/lib/components/Shared/Hyperlink.dart new file mode 100644 index 00000000..d4a70b1c --- /dev/null +++ b/lib/components/Shared/Hyperlink.dart @@ -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, + ); + } +} diff --git a/lib/components/Shared/LinkText.dart b/lib/components/Shared/LinkText.dart index 634c96b3..9d5d63e3 100644 --- a/lib/components/Shared/LinkText.dart +++ b/lib/components/Shared/LinkText.dart @@ -1,50 +1,32 @@ import 'package:flutter/material.dart'; +import 'package:spotube/components/Shared/AnchorButton.dart'; -class LinkText extends StatefulWidget { +class LinkText extends StatelessWidget { final String text; final TextStyle style; - final TextAlign? textAign; + final TextAlign? textAlign; final TextOverflow? overflow; final Route route; - const LinkText( this.text, this.route, { Key? key, - this.textAign, + this.textAlign, this.overflow, this.style = const TextStyle(), }) : super(key: key); - @override - State> createState() => _LinkTextState(); -} - -class _LinkTextState extends State> { - 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, ); } } diff --git a/lib/components/Shared/PageWindowTitleBar.dart b/lib/components/Shared/PageWindowTitleBar.dart index 506998e8..2225d6d5 100644 --- a/lib/components/Shared/PageWindowTitleBar.dart +++ b/lib/components/Shared/PageWindowTitleBar.dart @@ -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() ], ), );