Skip to content

Commit

Permalink
Merge pull request #1 from AlexisL61/dev
Browse files Browse the repository at this point in the history
0.4.0
  • Loading branch information
AlexisL61 authored Nov 24, 2024
2 parents b9066a0 + 24290b3 commit 7023279
Show file tree
Hide file tree
Showing 17 changed files with 446 additions and 39 deletions.
1 change: 1 addition & 0 deletions rpc_express/assets/common/icons/discord.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions rpc_express/assets/translations/en.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"_app_title": "Sea of Thieves Rich Presence",
"_app_description": "An open-source rich presence app for Sea of Thieves",
"_app_title": "RPC Express",
"_app_description": "Manual Discord rich presence for Sea of Thieves, Helldivers 2 and The Finals",
"_app_developer": "Made by {developer}",

"_app_rich_presence": "Rich Presence",
"_app_rich_presence_unknown": "Select an activity to start displaying your rich presence",

"_sot_ship":"Ship",
"_no_ship_selected":"No ship selected",
"_sot_ship_select_button":"Select a ship",
Expand Down
7 changes: 5 additions & 2 deletions rpc_express/assets/translations/fr.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"_app_title":"Sea of Thieves Rich Presence",
"_app_description":"Une application open-source pour afficher votre activité Sea of Thieves sur Discord.",
"_app_title":"RPC Express",
"_app_description":"Manual Discord rich presence for Sea of Thieves, Helldivers 2 and The Finals",
"_app_developer":"Créé par {developer}",

"_app_rich_presence": "Rich Presence",
"_app_rich_presence_unknown": "Sélectionnez une activité pour montrer votre Rich Presence",

"_activity":"Activité",
"_no_activity_selected":"Aucune activité sélectionnée",
"_activity_select_button":"Sélectionner une activité",
Expand Down
36 changes: 36 additions & 0 deletions rpc_express/lib/components/common/atoms/colored_container.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

import '../../../model/class/games/game_object.dart';

class ColoredContainer extends StatefulWidget {
final GameObject game;
final Widget child;
final EdgeInsets padding;
const ColoredContainer({super.key, required this.game, required this.child, required this.padding});

@override
State<ColoredContainer> createState() => _ColoredContainerState();
}

class _ColoredContainerState extends State<ColoredContainer> {
@override
Widget build(BuildContext context) {
return Container(
padding: widget.padding,
decoration: BoxDecoration(
color: widget.game.gameSelectionBackgroundColor,
borderRadius: BorderRadius.circular(25),
border: Border.all(color: Colors.white.withOpacity(0.2), width: 2),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.2),
spreadRadius: 0,
blurRadius: 4,
offset: const Offset(0, 4),
),
]),
child: widget.child,
);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:rpc_express/components/common/atoms/colored_container.dart';
import 'package:rpc_express/model/class/games/game_object.dart';

class GameSelectionContainer extends StatefulWidget {
Expand All @@ -16,39 +17,68 @@ class GameSelectionContainer extends StatefulWidget {
}

class _GameSelectionContainerState extends State<GameSelectionContainer> {
bool hovered = false;

@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 10),
height: 50,
decoration: BoxDecoration(
color: widget.game.gameSelectionBackgroundColor,
borderRadius: BorderRadius.circular(50),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.2),
spreadRadius: 0,
blurRadius: 4,
offset: const Offset(0, 4),
),
]),
child: _buildGamesRow(),
);
return MouseRegion(
onEnter: (event) => setState(() => hovered = true),
onExit: (event) => setState(() => hovered = false),
child: ColoredContainer(
game: widget.game,
padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 10),
child: _buildGamesRow(),
));
}

Widget _buildGamesRow() {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: GameObject.values.map((GameObject gameObject) {
return GestureDetector(
onTap: () => widget.onTap(gameObject),
child: Row(
children: [
Container(
child: Image.asset(gameObject.icon),
return MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
onTap: () => widget.onTap(gameObject),
child: AnimatedSize(
duration: const Duration(milliseconds: 400),
child: Row(
children: [
Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
height: 30,
child: Image.asset(
gameObject.icon,
fit: BoxFit.cover,
)),
AnimatedSize(
clipBehavior: Clip.hardEdge,
curve: hovered ? Curves.easeOutBack : Curves.ease,
duration: const Duration(milliseconds: 400),
child: ConstrainedBox(
constraints: const BoxConstraints(minWidth: 30),
child: hovered
? Column(
children: [
const SizedBox(height: 6),
Text(
gameObject.name,
style: const TextStyle(
color: Colors.white,
fontSize: 12,
),
),
],
)
: Container(),
)),
],
),
if (gameObject != GameObject.values.last) const SizedBox(width: 20),
],
),
if (gameObject != GameObject.values.last) SizedBox(width: 10),
],
),
),
);
}).toList(),
Expand Down
104 changes: 104 additions & 0 deletions rpc_express/lib/components/common/molecules/information_container.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:rpc_express/components/common/atoms/colored_container.dart';
import 'package:rpc_express/components/common/molecules/information_container_view_model.dart';
import 'package:rpc_express/model/class/games/game_object.dart';
import 'package:rpc_express/model/mvvm/widget_event_observer.dart';

class InformationContainer extends StatefulWidget {
final GameObject game;

const InformationContainer({super.key, required this.game});

@override
State<InformationContainer> createState() => _InformationContainerState();
}

class _InformationContainerState extends WidgetEventObserver<InformationContainer> {
bool hovered = false;
InformationContainerViewModel viewModel = InformationContainerViewModel();

@override
void initState() {
super.initState();
viewModel.subscribe(this);
}

@override
Widget build(BuildContext context) {
return MouseRegion(
onEnter: (event) => setState(() => hovered = true),
onExit: (event) => setState(() => hovered = false),
child: ColoredContainer(
game: widget.game,
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
child: AnimatedCrossFade(
sizeCurve: hovered ? Curves.easeOutBack : Curves.ease,
crossFadeState: hovered ? CrossFadeState.showSecond : CrossFadeState.showFirst,
duration: hovered ? Duration(milliseconds: 400) : Duration(milliseconds: 300),
firstChild: _buildDefault(),
secondChild: Padding(padding: const EdgeInsets.symmetric(horizontal: 16.0), child: _buildExpanded())),
),
);
}

Widget _buildDefault() {
return SizedBox(width: 30, height: 30, child: Icon(Icons.info, color: Colors.white, size: 30));
}

Widget _buildExpanded() {
return SizedBox(
width: 200,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
tr("_app_title"),
style: TextStyle(color: Colors.white, fontSize: 20),
),
const SizedBox(width: 10),
Text(
viewModel.packageVersion,
style: TextStyle(color: Colors.grey.shade400, fontSize: 14),
),
],
),
const SizedBox(height: 10),
Text(tr("_app_description"), style: TextStyle(color: Colors.grey.shade200, fontSize: 14)),
const SizedBox(height: 10),
Text(
tr("_app_developer", namedArgs: {
"developer": "AlexisL61",
}),
style: TextStyle(color: Colors.grey.shade200, fontSize: 14)),
const SizedBox(height: 10),
Row(
children: [
MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
onTap: () {
viewModel.openUrl("https://github.com/AlexisL61/RPC_Express");
},
child: Icon(Icons.code, color: Colors.grey.shade200, size: 30)),
),
const SizedBox(width: 5),
MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
onTap: () {
viewModel.openUrl("https://github.com/sponsors/AlexisL61");
},
child: Icon(Icons.favorite, color: Colors.grey.shade200, size: 30)),
),
],
)
],
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'package:get_it/get_it.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:rpc_express/model/mvvm/view_model.dart';
import 'package:url_launcher/url_launcher_string.dart';

class InformationContainerViewModel extends EventViewModel {
GetIt getIt = GetIt.instance;

String packageVersion = "...";

InformationContainerViewModel() {
Future<PackageInfo> info = PackageInfo.fromPlatform();
info.then((value) {
packageVersion = value.version;
notify();
});
}

void openUrl(String url) {
launchUrlString(url);
}
}
Loading

0 comments on commit 7023279

Please sign in to comment.