Skip to content

Commit

Permalink
refactor(diec_routes): ♻️ extract wordUri method (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
albertms10 committed Feb 7, 2024
1 parent 32601b7 commit b2dd02d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/src/pages/word_page.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:el_meu_diec/src/routes/diec_routes.dart';
import 'package:el_meu_diec/src/widgets/autocomplete_entry_card.dart';
import 'package:el_meu_diec/src/widgets/bookmark_button.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -31,12 +32,7 @@ class WordPage extends StatelessWidget {
actions: [
BookmarkButton(word: word, isTonalFilled: true),
IconButton.filledTonal(
onPressed: () => Share.shareUri(
Uri.https('dlc.iec.cat', '/Results', {
'IdE': word.id,
'DecEntradaText': word.word,
}),
),
onPressed: () => Share.shareUri(const DIECRoutes().wordUri(word)),
icon: const Icon(Icons.ios_share_rounded),
),
const SizedBox(width: 4),
Expand Down
15 changes: 15 additions & 0 deletions lib/src/routes/diec_routes.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'package:flutter/foundation.dart';

import '../model/word.dart';

@immutable
final class DIECRoutes {
final String authority;

const DIECRoutes({this.authority = 'dlc.iec.cat'});

Uri wordUri(Word word) => Uri.https(authority, '/Results', {
'IdE': word.id,
'DecEntradaText': word.word,
});
}

0 comments on commit b2dd02d

Please sign in to comment.