From 362dea6b08ea4ce980eaecadd386aeab161f4b83 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Sat, 22 Feb 2025 15:19:43 +0100 Subject: [PATCH] Design polish --- lib/widgets/game_card.dart | 97 +++++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 43 deletions(-) diff --git a/lib/widgets/game_card.dart b/lib/widgets/game_card.dart index 0e9cb7b..5fbd5ee 100644 --- a/lib/widgets/game_card.dart +++ b/lib/widgets/game_card.dart @@ -41,10 +41,12 @@ class _GameCardState extends State vsync: this, ); _nameController = TextEditingController(text: widget.game.name); - _versionRegexController = TextEditingController(text: widget.game.versionRegex); + _versionRegexController = TextEditingController( + text: widget.game.versionRegex, + ); _rssFeedUrlController = TextEditingController(text: widget.game.rssFeedUrl); _lastPlayedController = TextEditingController(text: widget.game.lastPlayed); - + _nameFocus = FocusNode(); _versionRegexFocus = FocusNode(); _rssFeedUrlFocus = FocusNode(); @@ -55,14 +57,20 @@ class _GameCardState extends State void _setupFocusListeners() { void updateGame() { - widget.onGameUpdated(Game( - name: widget.isNameEditable ? _nameController.text : widget.game.name, - versionRegex: _versionRegexController.text, - lastPlayed: _lastPlayedController.text, - rssFeedUrl: _rssFeedUrlController.text, - actualVersion: widget.game.actualVersion, - lastUpdated: widget.game.lastUpdated, - )); + var name = + widget.isNameEditable ? _nameController.text : widget.game.name; + if (name.isNotEmpty) { + widget.onGameUpdated( + Game( + name: name, + versionRegex: _versionRegexController.text, + lastPlayed: _lastPlayedController.text, + rssFeedUrl: _rssFeedUrlController.text, + actualVersion: widget.game.actualVersion, + lastUpdated: widget.game.lastUpdated, + ), + ); + } } _nameFocus.addListener(() { @@ -133,43 +141,46 @@ class _GameCardState extends State child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: TextField( - controller: _nameController, - focusNode: _nameFocus, - style: Theme.of(context).textTheme.titleLarge, - enabled: widget.isNameEditable, - decoration: const InputDecoration.collapsed( - hintText: 'New Game', + SizedBox( + height: 40, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: TextField( + controller: _nameController, + focusNode: _nameFocus, + style: Theme.of(context).textTheme.titleLarge, + enabled: widget.isNameEditable, + decoration: const InputDecoration.collapsed( + hintText: 'New Game', + ), + onSubmitted: (_) => _nameFocus.unfocus(), ), - onSubmitted: (_) => _nameFocus.unfocus(), ), - ), - Row( - mainAxisSize: MainAxisSize.min, - children: [ - if (widget.onDelete != null) - IconButton( - icon: Icon( - Icons.delete, - color: _deleteClickCount > 0 ? Colors.red : null, + Row( + mainAxisSize: MainAxisSize.min, + children: [ + if (widget.onDelete != null) + IconButton( + icon: Icon( + Icons.delete, + color: _deleteClickCount > 0 ? Colors.red : null, + ), + onPressed: _handleDeleteClick, ), - onPressed: _handleDeleteClick, - ), - if (!widget.isNameEditable) - RotationTransition( - turns: _controller, - child: IconButton( - icon: const Icon(Icons.refresh), - onPressed: _isLoading ? null : _refreshVersion, + if (!widget.isNameEditable) + RotationTransition( + turns: _controller, + child: IconButton( + icon: const Icon(Icons.refresh), + onPressed: _isLoading ? null : _refreshVersion, + ), ), - ), - ], - ), - ], + ], + ), + ], + ), ), const SizedBox(height: 8), Row(