Skip to content

Commit 7023279

Browse files
authored
Merge pull request #1 from AlexisL61/dev
0.4.0
2 parents b9066a0 + 24290b3 commit 7023279

File tree

17 files changed

+446
-39
lines changed

17 files changed

+446
-39
lines changed
Lines changed: 1 addition & 0 deletions
Loading

rpc_express/assets/translations/en.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
{
2-
"_app_title": "Sea of Thieves Rich Presence",
3-
"_app_description": "An open-source rich presence app for Sea of Thieves",
2+
"_app_title": "RPC Express",
3+
"_app_description": "Manual Discord rich presence for Sea of Thieves, Helldivers 2 and The Finals",
44
"_app_developer": "Made by {developer}",
55

6+
"_app_rich_presence": "Rich Presence",
7+
"_app_rich_presence_unknown": "Select an activity to start displaying your rich presence",
8+
69
"_sot_ship":"Ship",
710
"_no_ship_selected":"No ship selected",
811
"_sot_ship_select_button":"Select a ship",

rpc_express/assets/translations/fr.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
{
2-
"_app_title":"Sea of Thieves Rich Presence",
3-
"_app_description":"Une application open-source pour afficher votre activité Sea of Thieves sur Discord.",
2+
"_app_title":"RPC Express",
3+
"_app_description":"Manual Discord rich presence for Sea of Thieves, Helldivers 2 and The Finals",
44
"_app_developer":"Créé par {developer}",
55

6+
"_app_rich_presence": "Rich Presence",
7+
"_app_rich_presence_unknown": "Sélectionnez une activité pour montrer votre Rich Presence",
8+
69
"_activity":"Activité",
710
"_no_activity_selected":"Aucune activité sélectionnée",
811
"_activity_select_button":"Sélectionner une activité",
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter/widgets.dart';
3+
4+
import '../../../model/class/games/game_object.dart';
5+
6+
class ColoredContainer extends StatefulWidget {
7+
final GameObject game;
8+
final Widget child;
9+
final EdgeInsets padding;
10+
const ColoredContainer({super.key, required this.game, required this.child, required this.padding});
11+
12+
@override
13+
State<ColoredContainer> createState() => _ColoredContainerState();
14+
}
15+
16+
class _ColoredContainerState extends State<ColoredContainer> {
17+
@override
18+
Widget build(BuildContext context) {
19+
return Container(
20+
padding: widget.padding,
21+
decoration: BoxDecoration(
22+
color: widget.game.gameSelectionBackgroundColor,
23+
borderRadius: BorderRadius.circular(25),
24+
border: Border.all(color: Colors.white.withOpacity(0.2), width: 2),
25+
boxShadow: [
26+
BoxShadow(
27+
color: Colors.black.withOpacity(0.2),
28+
spreadRadius: 0,
29+
blurRadius: 4,
30+
offset: const Offset(0, 4),
31+
),
32+
]),
33+
child: widget.child,
34+
);
35+
}
36+
}

rpc_express/lib/components/common/molecules/game_selection_container.dart

Lines changed: 54 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:rpc_express/components/common/atoms/colored_container.dart';
23
import 'package:rpc_express/model/class/games/game_object.dart';
34

45
class GameSelectionContainer extends StatefulWidget {
@@ -16,39 +17,68 @@ class GameSelectionContainer extends StatefulWidget {
1617
}
1718

1819
class _GameSelectionContainerState extends State<GameSelectionContainer> {
20+
bool hovered = false;
21+
1922
@override
2023
Widget build(BuildContext context) {
21-
return Container(
22-
padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 10),
23-
height: 50,
24-
decoration: BoxDecoration(
25-
color: widget.game.gameSelectionBackgroundColor,
26-
borderRadius: BorderRadius.circular(50),
27-
boxShadow: [
28-
BoxShadow(
29-
color: Colors.black.withOpacity(0.2),
30-
spreadRadius: 0,
31-
blurRadius: 4,
32-
offset: const Offset(0, 4),
33-
),
34-
]),
35-
child: _buildGamesRow(),
36-
);
24+
return MouseRegion(
25+
onEnter: (event) => setState(() => hovered = true),
26+
onExit: (event) => setState(() => hovered = false),
27+
child: ColoredContainer(
28+
game: widget.game,
29+
padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 10),
30+
child: _buildGamesRow(),
31+
));
3732
}
3833

3934
Widget _buildGamesRow() {
4035
return Row(
4136
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
4237
children: GameObject.values.map((GameObject gameObject) {
43-
return GestureDetector(
44-
onTap: () => widget.onTap(gameObject),
45-
child: Row(
46-
children: [
47-
Container(
48-
child: Image.asset(gameObject.icon),
38+
return MouseRegion(
39+
cursor: SystemMouseCursors.click,
40+
child: GestureDetector(
41+
onTap: () => widget.onTap(gameObject),
42+
child: AnimatedSize(
43+
duration: const Duration(milliseconds: 400),
44+
child: Row(
45+
children: [
46+
Column(
47+
mainAxisSize: MainAxisSize.min,
48+
children: [
49+
SizedBox(
50+
height: 30,
51+
child: Image.asset(
52+
gameObject.icon,
53+
fit: BoxFit.cover,
54+
)),
55+
AnimatedSize(
56+
clipBehavior: Clip.hardEdge,
57+
curve: hovered ? Curves.easeOutBack : Curves.ease,
58+
duration: const Duration(milliseconds: 400),
59+
child: ConstrainedBox(
60+
constraints: const BoxConstraints(minWidth: 30),
61+
child: hovered
62+
? Column(
63+
children: [
64+
const SizedBox(height: 6),
65+
Text(
66+
gameObject.name,
67+
style: const TextStyle(
68+
color: Colors.white,
69+
fontSize: 12,
70+
),
71+
),
72+
],
73+
)
74+
: Container(),
75+
)),
76+
],
77+
),
78+
if (gameObject != GameObject.values.last) const SizedBox(width: 20),
79+
],
4980
),
50-
if (gameObject != GameObject.values.last) SizedBox(width: 10),
51-
],
81+
),
5282
),
5383
);
5484
}).toList(),
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import 'package:easy_localization/easy_localization.dart';
2+
import 'package:flutter/material.dart';
3+
import 'package:flutter/widgets.dart';
4+
import 'package:rpc_express/components/common/atoms/colored_container.dart';
5+
import 'package:rpc_express/components/common/molecules/information_container_view_model.dart';
6+
import 'package:rpc_express/model/class/games/game_object.dart';
7+
import 'package:rpc_express/model/mvvm/widget_event_observer.dart';
8+
9+
class InformationContainer extends StatefulWidget {
10+
final GameObject game;
11+
12+
const InformationContainer({super.key, required this.game});
13+
14+
@override
15+
State<InformationContainer> createState() => _InformationContainerState();
16+
}
17+
18+
class _InformationContainerState extends WidgetEventObserver<InformationContainer> {
19+
bool hovered = false;
20+
InformationContainerViewModel viewModel = InformationContainerViewModel();
21+
22+
@override
23+
void initState() {
24+
super.initState();
25+
viewModel.subscribe(this);
26+
}
27+
28+
@override
29+
Widget build(BuildContext context) {
30+
return MouseRegion(
31+
onEnter: (event) => setState(() => hovered = true),
32+
onExit: (event) => setState(() => hovered = false),
33+
child: ColoredContainer(
34+
game: widget.game,
35+
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
36+
child: AnimatedCrossFade(
37+
sizeCurve: hovered ? Curves.easeOutBack : Curves.ease,
38+
crossFadeState: hovered ? CrossFadeState.showSecond : CrossFadeState.showFirst,
39+
duration: hovered ? Duration(milliseconds: 400) : Duration(milliseconds: 300),
40+
firstChild: _buildDefault(),
41+
secondChild: Padding(padding: const EdgeInsets.symmetric(horizontal: 16.0), child: _buildExpanded())),
42+
),
43+
);
44+
}
45+
46+
Widget _buildDefault() {
47+
return SizedBox(width: 30, height: 30, child: Icon(Icons.info, color: Colors.white, size: 30));
48+
}
49+
50+
Widget _buildExpanded() {
51+
return SizedBox(
52+
width: 200,
53+
child: Column(
54+
crossAxisAlignment: CrossAxisAlignment.start,
55+
children: [
56+
Row(
57+
crossAxisAlignment: CrossAxisAlignment.end,
58+
children: [
59+
Text(
60+
tr("_app_title"),
61+
style: TextStyle(color: Colors.white, fontSize: 20),
62+
),
63+
const SizedBox(width: 10),
64+
Text(
65+
viewModel.packageVersion,
66+
style: TextStyle(color: Colors.grey.shade400, fontSize: 14),
67+
),
68+
],
69+
),
70+
const SizedBox(height: 10),
71+
Text(tr("_app_description"), style: TextStyle(color: Colors.grey.shade200, fontSize: 14)),
72+
const SizedBox(height: 10),
73+
Text(
74+
tr("_app_developer", namedArgs: {
75+
"developer": "AlexisL61",
76+
}),
77+
style: TextStyle(color: Colors.grey.shade200, fontSize: 14)),
78+
const SizedBox(height: 10),
79+
Row(
80+
children: [
81+
MouseRegion(
82+
cursor: SystemMouseCursors.click,
83+
child: GestureDetector(
84+
onTap: () {
85+
viewModel.openUrl("https://github.com/AlexisL61/RPC_Express");
86+
},
87+
child: Icon(Icons.code, color: Colors.grey.shade200, size: 30)),
88+
),
89+
const SizedBox(width: 5),
90+
MouseRegion(
91+
cursor: SystemMouseCursors.click,
92+
child: GestureDetector(
93+
onTap: () {
94+
viewModel.openUrl("https://github.com/sponsors/AlexisL61");
95+
},
96+
child: Icon(Icons.favorite, color: Colors.grey.shade200, size: 30)),
97+
),
98+
],
99+
)
100+
],
101+
),
102+
);
103+
}
104+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import 'package:get_it/get_it.dart';
2+
import 'package:package_info_plus/package_info_plus.dart';
3+
import 'package:rpc_express/model/mvvm/view_model.dart';
4+
import 'package:url_launcher/url_launcher_string.dart';
5+
6+
class InformationContainerViewModel extends EventViewModel {
7+
GetIt getIt = GetIt.instance;
8+
9+
String packageVersion = "...";
10+
11+
InformationContainerViewModel() {
12+
Future<PackageInfo> info = PackageInfo.fromPlatform();
13+
info.then((value) {
14+
packageVersion = value.version;
15+
notify();
16+
});
17+
}
18+
19+
void openUrl(String url) {
20+
launchUrlString(url);
21+
}
22+
}

0 commit comments

Comments
 (0)