-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
445 additions
and
38 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
rpc_express/lib/components/common/atoms/colored_container.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
rpc_express/lib/components/common/molecules/information_container.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)), | ||
), | ||
], | ||
) | ||
], | ||
), | ||
); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
rpc_express/lib/components/common/molecules/information_container_view_model.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.