diff --git a/lib/src/pages/word_page.dart b/lib/src/pages/word_page.dart new file mode 100644 index 0000000..4e505b8 --- /dev/null +++ b/lib/src/pages/word_page.dart @@ -0,0 +1,36 @@ +import 'package:el_meu_diec/src/widgets/autocomplete_entry_card.dart'; +import 'package:flutter/material.dart'; + +import '../model/word.dart'; + +class WordPage extends StatelessWidget { + final Word word; + + const WordPage({super.key, required this.word}); + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + + return Scaffold( + backgroundColor: Colors.transparent, + body: SingleChildScrollView( + child: Padding( + padding: const EdgeInsetsDirectional.all(20), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + word.word, + style: theme.textTheme.displaySmall, + textAlign: TextAlign.start, + ), + const SizedBox(height: 24), + DefinitionEntrySenses(word: word), + ], + ), + ), + ), + ); + } +} diff --git a/lib/src/widgets/autocomplete_entry_card.dart b/lib/src/widgets/autocomplete_entry_card.dart index 79b34c8..4de6bb7 100644 --- a/lib/src/widgets/autocomplete_entry_card.dart +++ b/lib/src/widgets/autocomplete_entry_card.dart @@ -1,12 +1,10 @@ -import 'dart:io'; - import 'package:el_meu_diec/model.dart'; import 'package:el_meu_diec/src/constants.dart'; +import 'package:el_meu_diec/src/pages/word_page.dart'; import 'package:el_meu_diec/src/theme.dart'; import 'package:el_meu_diec/src/widgets/definition_entry_sense_line.dart'; import 'package:el_meu_diec/src/widgets/equipped_card.dart'; import 'package:flutter/material.dart'; -import 'package:modal_bottom_sheet/modal_bottom_sheet.dart'; import 'package:provider/provider.dart'; class AutocompleteEntryCard extends StatelessWidget { @@ -31,25 +29,10 @@ class AutocompleteEntryCard extends StatelessWidget { return EquippedCard( height: autocompleteEntryCardHeight, isLoading: isLoading, - onTap: () => (Platform.isAndroid - ? showBarModalBottomSheet - : showCupertinoModalBottomSheet)( + onTap: () => showModalBottomSheet( context: context, builder: (context) { - return Align( - alignment: Alignment.topCenter, - child: SingleChildScrollView( - child: Padding( - padding: const EdgeInsetsDirectional.all(20), - child: Column( - children: [ - Text(word.word), - _DefinitionEntrySenses(word: word), - ], - ), - ), - ), - ); + return WordPage(word: word); }, ), child: Column( @@ -77,7 +60,8 @@ class AutocompleteEntryCard extends StatelessWidget { _BookmarkButton(word: word), ], ), - if (word.senses != null) _DefinitionEntrySenses(word: word), + if (word.senses != null) + DefinitionEntrySenses(word: word, isInteractive: false), ], ), ); @@ -98,7 +82,7 @@ class _BookmarkButton extends StatelessWidget { TextSpan( children: [ TextSpan( - text: bookmarked ? 'S’ha afegit ' : 'S’ha eliminat ', + text: bookmarked ? 'S’ha afegit ' : 'S’ha tret ', ), TextSpan( text: word.word, @@ -127,17 +111,21 @@ class _BookmarkButton extends StatelessWidget { isBookmarked ? Icons.bookmark : Icons.bookmark_outline, ), enableFeedback: true, - tooltip: - isBookmarked ? 'Elimina de la coŀlecció' : 'Afegeix a la coŀlecció', + tooltip: isBookmarked ? 'Treu de la coŀlecció' : 'Afegeix a la coŀlecció', onPressed: () => _onPressed(context), ); } } -class _DefinitionEntrySenses extends StatelessWidget { +class DefinitionEntrySenses extends StatelessWidget { final Word word; + final bool isInteractive; - const _DefinitionEntrySenses({super.key, required this.word}); + const DefinitionEntrySenses({ + super.key, + required this.word, + this.isInteractive = true, + }); @override Widget build(BuildContext context) { @@ -148,7 +136,7 @@ class _DefinitionEntrySenses extends StatelessWidget { for (var i = 0; i < word.senses!.length; i++) DefinitionEntrySenseLine( sense: word.senses![i], - interactive: false, + isInteractive: isInteractive, isFirstNumber: i == 0 || word.senses![i - 1].number != word.senses![i].number, ), diff --git a/lib/src/widgets/autocomplete_entry_future_card.dart b/lib/src/widgets/autocomplete_entry_future_card.dart index 1952b21..0178873 100644 --- a/lib/src/widgets/autocomplete_entry_future_card.dart +++ b/lib/src/widgets/autocomplete_entry_future_card.dart @@ -1,5 +1,6 @@ import 'package:el_meu_diec/model.dart'; -import 'package:el_meu_diec/src/widgets/autocomplete_entry_card.dart'; +import 'package:el_meu_diec/src/widgets/autocomplete_entry_card.dart' + hide DefinitionEntrySenses; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; diff --git a/lib/src/widgets/definition_entry_sense_line.dart b/lib/src/widgets/definition_entry_sense_line.dart index a275fb3..b500a16 100644 --- a/lib/src/widgets/definition_entry_sense_line.dart +++ b/lib/src/widgets/definition_entry_sense_line.dart @@ -8,13 +8,13 @@ import 'package:flutter/material.dart'; class DefinitionEntrySenseLine extends StatelessWidget { final DefinitionEntrySense sense; final bool isFirstNumber; - final bool interactive; + final bool isInteractive; const DefinitionEntrySenseLine({ super.key, required this.sense, this.isFirstNumber = true, - this.interactive = true, + this.isInteractive = true, }); @override @@ -74,7 +74,7 @@ class DefinitionEntrySenseLine extends StatelessWidget { padding: const EdgeInsetsDirectional.only(end: 4), child: ScopeChip( scope: scope, - interactive: interactive, + isInteractive: isInteractive, ), ), ), diff --git a/lib/src/widgets/scope_chip.dart b/lib/src/widgets/scope_chip.dart index c640d9c..42c171c 100644 --- a/lib/src/widgets/scope_chip.dart +++ b/lib/src/widgets/scope_chip.dart @@ -3,9 +3,9 @@ import 'package:flutter/material.dart'; class ScopeChip extends StatelessWidget { final Scope scope; - final bool interactive; + final bool isInteractive; - const ScopeChip({super.key, required this.scope, this.interactive = true}); + const ScopeChip({super.key, required this.scope, this.isInteractive = true}); void _onTap(BuildContext context) { ScaffoldMessenger.of(context).showSnackBar( @@ -26,20 +26,23 @@ class ScopeChip extends StatelessWidget { borderRadius: BorderRadius.all(Radius.circular(4)), side: BorderSide(color: Color(0xFFE0E0E0)), ), - child: InkWell( - onTap: interactive ? () => _onTap(context) : null, - child: Padding( - padding: const EdgeInsetsDirectional.only( - start: 6, - end: 6, - top: 3, - bottom: 4, - ), - child: Text( - scope.name, - style: const TextStyle( - color: Colors.black, - fontSize: 12, + child: Tooltip( + message: 'Mostra l’abreviatura', + child: InkWell( + onTap: isInteractive ? () => _onTap(context) : null, + child: Padding( + padding: const EdgeInsetsDirectional.only( + start: 6, + end: 6, + top: 3, + bottom: 4, + ), + child: Text( + scope.name, + style: const TextStyle( + color: Colors.black, + fontSize: 12, + ), ), ), ),