Skip to content

Commit

Permalink
feat: Add credits
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisL61 committed Jun 12, 2024
1 parent 6518c3e commit 4ef502b
Show file tree
Hide file tree
Showing 17 changed files with 268 additions and 56 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions sot_richpresence/assets/translations/en.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"_app_title": "Sea of Thieves Rich Presence",
"_app_description": "An open-source rich presence app for Sea of Thieves",
"_app_developer": "Made by {developer}",

"_ship":"Ship",
"_no_ship_selected":"No ship selected",
Expand Down
2 changes: 2 additions & 0 deletions sot_richpresence/assets/translations/fr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"_app_title":"Sea of Thieves Rich Presence",
"_app_description":"Une application open-source pour afficher votre activité Sea of Thieves sur Discord.",
"_app_developer":"Créé par {developer}",

"_ship":"Navire",
"_no_ship_selected":"Aucun bateau sélectionné",
Expand Down
39 changes: 39 additions & 0 deletions sot_richpresence/lib/components/dialogs/credit_dialog.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:sot_richpresence/components/buttons/icon_button.dart';
import 'package:sot_richpresence/components/dialogs/sot_dialog.dart';
import 'package:sot_richpresence/components/texts/styles.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:url_launcher/url_launcher_string.dart';

class CreditDialog extends StatelessWidget {
const CreditDialog({super.key});

@override
Widget build(BuildContext context) {
return SOTDialog(
child: SizedBox(
width: 500,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(tr("_app_title"),
textAlign: TextAlign.center, style: SotTextStyles.mediumYellow),
SizedBox(height: 20),
Text(tr("_app_description"),
textAlign: TextAlign.center, style: SotTextStyles.mediumWhite),
SizedBox(height: 40),
Text(tr("_app_developer", namedArgs: {"developer": "AlexisL61"}),
textAlign: TextAlign.center, style: SotTextStyles.mediumWhite),
SizedBox(height: 20),
SotIconButton(
onPressed: () {
launchUrlString(
"https://github.com/AlexisL61/SOT_RichPresence");
},
icon: FluentIcons.heart)
],
),
));
}
}
37 changes: 37 additions & 0 deletions sot_richpresence/lib/components/dialogs/sot_dialog.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter_svg/svg.dart';

class SOTDialog extends StatefulWidget {
final Widget child;

const SOTDialog({super.key, required this.child});

@override
State<SOTDialog> createState() => _SOTDialogState();
}

class _SOTDialogState extends State<SOTDialog> {
@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Stack(children: [
Positioned.fill(
child: SvgPicture.asset(
'assets/svg/background/pop-up-background.svg',
allowDrawingOutsideViewBox: true,
fit: BoxFit.fill,
clipBehavior: Clip.hardEdge)),
Padding(
padding: EdgeInsets.all(24),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [widget.child],
))
])
]);
}
}
49 changes: 33 additions & 16 deletions sot_richpresence/lib/components/panels/large_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ class LargePanel extends StatefulWidget {
final String? actionText;
final void Function()? action;

const LargePanel({super.key, required this.image, required this.child, required this.title, this.description, this.actionText, this.action});
const LargePanel(
{super.key,
required this.image,
required this.child,
required this.title,
this.description,
this.actionText,
this.action});

@override
State<LargePanel> createState() => _LargePanelState();
Expand All @@ -23,23 +30,32 @@ class _LargePanelState extends State<LargePanel> {
@override
Widget build(BuildContext context) {
return Stack(children: [
Positioned.fill(child: Padding(padding: EdgeInsets.all(6), child: Image(image: widget.image, fit: BoxFit.cover))),
Positioned.fill(
child: Padding(
padding: EdgeInsets.all(6),
child: Image(image: widget.image, fit: BoxFit.cover))),
Positioned.fill(
child: Padding(
padding: EdgeInsets.all(6),
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [SotColors.green.withOpacity(0.8), SotColors.green.withOpacity(0)],
begin: Alignment.topCenter,
end: Alignment.bottomCenter)),
gradient: LinearGradient(colors: [
SotColors.green.withOpacity(0.8),
SotColors.green.withOpacity(0)
], begin: Alignment.topCenter, end: Alignment.bottomCenter)),
))),
Positioned.fill(
child: SvgPicture.asset('assets/svg/panels/large-panel-background.svg',
allowDrawingOutsideViewBox: true, fit: BoxFit.fill, clipBehavior: Clip.hardEdge)),
child: SvgPicture.asset(
'assets/svg/panels/large-panel-background.svg',
allowDrawingOutsideViewBox: true,
fit: BoxFit.fill,
clipBehavior: Clip.hardEdge)),
Positioned.fill(
child: SvgPicture.asset('assets/svg/panels/large-panel-foreground.svg',
allowDrawingOutsideViewBox: true, fit: BoxFit.fill, clipBehavior: Clip.hardEdge)),
child: SvgPicture.asset(
'assets/svg/panels/large-panel-foreground.svg',
allowDrawingOutsideViewBox: true,
fit: BoxFit.fill,
clipBehavior: Clip.hardEdge)),
Padding(
padding: EdgeInsets.all(24),
child: Column(
Expand All @@ -48,7 +64,7 @@ class _LargePanelState extends State<LargePanel> {
children: [
Text(
widget.title,
style: SotTextStyles.mediumYellow,
style: SotTextStyles.smallYellow,
textAlign: TextAlign.left,
),
if (widget.description != null)
Expand All @@ -60,11 +76,12 @@ class _LargePanelState extends State<LargePanel> {
widget.child,
if (widget.actionText != null && widget.action != null)
Padding(
padding: EdgeInsets.only(top: 16),
child: SmallButton(
onPressed: widget.action!,
text: widget.actionText!,),
)
padding: EdgeInsets.only(top: 16),
child: SmallButton(
onPressed: widget.action!,
text: widget.actionText!,
),
)
],
))
]);
Expand Down
53 changes: 39 additions & 14 deletions sot_richpresence/lib/components/panels/small_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ class SmallPanel extends StatefulWidget {
final String title;
final String? description;

const SmallPanel({super.key, required this.image, required this.child, required this.title, this.description});
const SmallPanel(
{super.key,
required this.image,
required this.child,
required this.title,
this.description});

@override
State<SmallPanel> createState() => _SmallPanelState();
Expand All @@ -21,21 +26,41 @@ class _SmallPanelState extends State<SmallPanel> {
return IntrinsicHeight(
child: IntrinsicWidth(
child: Stack(fit: StackFit.expand, children: [
Padding(padding: EdgeInsets.all(6), child: Image(image: widget.image)),
Padding(padding: EdgeInsets.all(6), child: Opacity(opacity: 0.5, child: Container(color: SotColors.green,))),
Padding(padding: EdgeInsets.all(6), child: Image(image: widget.image)),
Padding(
padding: EdgeInsets.all(6),
child: Opacity(
opacity: 0.5,
child: Container(
color: SotColors.green,
))),
SvgPicture.asset('assets/svg/panels/small-panel-background.svg',
allowDrawingOutsideViewBox: true, fit: BoxFit.fill, clipBehavior: Clip.hardEdge),
allowDrawingOutsideViewBox: true,
fit: BoxFit.fill,
clipBehavior: Clip.hardEdge),
SvgPicture.asset('assets/svg/panels/small-panel-foreground.svg',
allowDrawingOutsideViewBox: true, fit: BoxFit.fill, clipBehavior: Clip.hardEdge),
Padding(padding: EdgeInsets.all(24), child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(widget.title, style: SotTextStyles.mediumYellow, textAlign: TextAlign.left,),
if (widget.description != null) Text(widget.description!, style: SotTextStyles.mediumWhite, textAlign: TextAlign.center,),
widget.child,
],
))

allowDrawingOutsideViewBox: true,
fit: BoxFit.fill,
clipBehavior: Clip.hardEdge),
Padding(
padding: EdgeInsets.all(24),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.title,
style: SotTextStyles.smallYellow,
textAlign: TextAlign.left,
),
if (widget.description != null)
Text(
widget.description!,
style: SotTextStyles.mediumWhite,
textAlign: TextAlign.center,
),
widget.child,
],
))
]),
));
}
Expand Down
4 changes: 3 additions & 1 deletion sot_richpresence/lib/components/texts/styles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class SotTextStyles {
static TextStyle smallWhite =
const TextStyle(fontSize: 16, color: Colors.white);

static TextStyle mediumYellow =
static TextStyle smallYellow =
const TextStyle(fontSize: 20, color: SotColors.yellow);
static TextStyle mediumYellow =
const TextStyle(fontSize: 26, color: SotColors.yellow);
}
56 changes: 33 additions & 23 deletions sot_richpresence/lib/pages/home/home_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:sot_richpresence/components/buttons/icon_button.dart';
import 'package:sot_richpresence/components/dialogs/credit_dialog.dart';
import 'package:sot_richpresence/components/navigation/naviagtion_view.dart';
import 'package:sot_richpresence/components/panels/large_panel.dart';
import 'package:sot_richpresence/components/separator/separator.dart';
Expand Down Expand Up @@ -66,37 +67,46 @@ class _HomePageState extends State<HomePage> {
}

Widget _buildBottomPanel() {
return SotIconButton(onPressed: () {}, icon: FluentIcons.heart);
return SotIconButton(
onPressed: () {
showDialog(context: context, builder: (context) => CreditDialog(), barrierDismissible: true);
},
icon: FluentIcons.heart);
}

Widget _buildShipPanel() {
DrivenShip? drivenShip = UserData().drivenShip;
return LargePanel(
image: AssetImage("assets/png/choose-ship.jpg"),
child: SizedBox(height: 200, width: 400),
title: tr("_ship"),
description: drivenShip == null
? tr("_no_ship_selected")
: tr("_${drivenShip.name}_name") +
" - " +
drivenShip.players.toString() +
" joueurs",
actionText: tr("_ship_select_button"),
action: () async {
DrivenShip? drivenShip =
await Navigator.pushNamed(context, "/choose_ship") as DrivenShip?;
if (drivenShip != null) {
controller.setDrivenShip(drivenShip);
setState(() {});
}
});
return SizedBox(
height:400,
child: LargePanel(
image: AssetImage("assets/png/choose-ship.jpg"),
child: Expanded(child:SizedBox(width: 400)),
title: tr("_ship"),
description: drivenShip == null
? tr("_no_ship_selected")
: tr("_${drivenShip.name}_name") +
" - " +
drivenShip.players.toString() +
" joueurs",
actionText: tr("_ship_select_button"),
action: () async {
DrivenShip? drivenShip =
await Navigator.pushNamed(context, "/choose_ship") as DrivenShip?;
if (drivenShip != null) {
controller.setDrivenShip(drivenShip);
setState(() {});
}
}),
);
}

Widget _buildActivityPanel() {
Activity? selectedActivity = UserData().activity;
return LargePanel(
return SizedBox(
height:400,
child: LargePanel(
image: AssetImage("assets/png/choose-activity.jpg"),
child: SizedBox(height: 200, width: 400),
child: Expanded(child:SizedBox(width: 400)),
title: tr("_activity"),
description: selectedActivity == null
? tr("_no_activity_selected")
Expand All @@ -110,6 +120,6 @@ class _HomePageState extends State<HomePage> {
controller.setActivity(selectedActivity);
setState(() {});
}
});
}));
}
}
4 changes: 4 additions & 0 deletions sot_richpresence/linux/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
#include "generated_plugin_registrant.h"

#include <dart_discord_rpc/dart_discord_rpc_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>

void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) dart_discord_rpc_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "DartDiscordRpcPlugin");
dart_discord_rpc_plugin_register_with_registrar(dart_discord_rpc_registrar);
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
}
1 change: 1 addition & 0 deletions sot_richpresence/linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

list(APPEND FLUTTER_PLUGIN_LIST
dart_discord_rpc
url_launcher_linux
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
Expand Down
2 changes: 1 addition & 1 deletion sot_richpresence/linux/my_application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static void my_application_activate(GApplication* application) {
gtk_window_set_title(window, "sot_richpresence");
}

gtk_window_set_default_size(window, 1280, 720);
gtk_window_set_default_size(window, 1280, 800);
gtk_widget_show(GTK_WIDGET(window));

g_autoptr(FlDartProject) project = fl_dart_project_new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import FlutterMacOS
import Foundation

import shared_preferences_foundation
import url_launcher_macos

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
}
Loading

0 comments on commit 4ef502b

Please sign in to comment.