Skip to content

Commit

Permalink
tweak appearence and definition list
Browse files Browse the repository at this point in the history
  • Loading branch information
dylandhall committed Jun 18, 2024
1 parent 5230574 commit 936c575
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 37 deletions.
76 changes: 43 additions & 33 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -258,35 +258,38 @@ class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateM
physics: const NeverScrollableScrollPhysics(),
itemCount: allWords.length,
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: 230,
maxCrossAxisExtent: 210,
mainAxisSpacing: 0,
childAspectRatio: 6,
crossAxisSpacing: 0,
),
itemBuilder: (context, index) {
var isFound = obtainedWords.contains(allWords[index]);
return
Align(
alignment: Alignment.centerLeft,
child: InkWell(
onTap: () => _lookupState.loadDefinition(allWords[index]),
//titleAlignment: ListTileTitleAlignment.top,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Icon(
isFound
? CupertinoIcons.checkmark_seal_fill
: CupertinoIcons.xmark_seal_fill,
color: isFound ? Colors.green : isDarkMode
? Colors.white30
: Colors.black38,
Padding(
padding: const EdgeInsets.only(left:8),
child: Align(
alignment: Alignment.centerLeft,
child: InkWell(
onTap: () => _lookupState.loadDefinition(allWords[index]),
//titleAlignment: ListTileTitleAlignment.top,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Icon(
isFound
? CupertinoIcons.checkmark_seal_fill
: CupertinoIcons.xmark_seal_fill,
color: isFound ? Colors.green : isDarkMode
? Colors.white30
: Colors.black38,
),
Padding(
padding: const EdgeInsets.only(left:8),
child: Text(allWords[index], textAlign: TextAlign.start)
)],
),
Padding(
padding: const EdgeInsets.only(left:8),
child: Text(allWords[index], textAlign: TextAlign.start)
)],
),
),
);
Expand All @@ -295,6 +298,7 @@ class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateM
);
}

static const String _gameKey = 'game-panel';

Iterable<Widget> getAllPlayingWidgets(ThemeData theme, GameStateManager gameState) sync* {
if (gameState.isLoading) {
Expand Down Expand Up @@ -324,20 +328,26 @@ class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateM
? ' (Practice)'
: '';

yield Padding(
padding: const EdgeInsets.all(8.0),
child: Text('Score: ${gameState.score} of a possible ${(gameState.possibleScore)} $info', style: boldStyle)
yield RepaintBoundary(
key: const ValueKey(_gameKey),
child: Column(
children:[
Padding(
padding: const EdgeInsets.all(8.0),
child: Text('Score: ${gameState.score} of a possible ${(gameState.possibleScore)} $info', style: boldStyle)
),
Padding(
padding: edgeInsets,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: getLetterButtonWidgets(theme, gameState).toList(),
)
)]
),
);

yield Padding(
padding: edgeInsets,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: getLetterButtonWidgets(theme, gameState).toList(),
));

var buttonColor = theme.floatingActionButtonTheme.foregroundColor ??
theme.colorScheme.primary;
var disabledButtonColor = (theme.floatingActionButtonTheme
Expand Down
10 changes: 7 additions & 3 deletions lib/wiktionary.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ class DefinitionLookupState extends ChangeNotifier {
Future<void> _openInNewTab(String url) async {
final uri = Uri.parse(url);
if (await canLaunchUrl(uri)){
await launchUrl(uri, webOnlyWindowName: '_blank',);
final res = await launchUrl(uri, webOnlyWindowName: '_blank',);
if (!res){
print('problem launching url $url');
}
}
dismissDefinition();
}
Expand Down Expand Up @@ -83,8 +86,9 @@ class DefinitionLookupState extends ChangeNotifier {
}
}

static String _getUrl(String word) => 'https://en.wiktionary.org/w/api.php?action=query&format=json&prop=extracts&titles=$word&formatversion=latest&exchars=500&explaintext=1';
static String _getWebUrl(String word) => 'https://en.wiktionary.org/wiki/$word';
static String _getUrl(String word) => 'https://en.wiktionary.org/w/api.php?action=query&format=json&prop=extracts&titles=$word&formatversion=latest&exchars=1000&explaintext=1';
// using mobile view as it's much cleaner, even on desktop
static String _getWebUrl(String word) => 'https://en.m.wiktionary.org/wiki/$word';

void dismissDefinition() {
if (isRunning) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.19+1
version: 1.0.20+1

environment:
sdk: '>=3.4.1 <4.0.0'
Expand Down

0 comments on commit 936c575

Please sign in to comment.