main
dart 118 lines 3.75 KB
Raw
1 import 'package:flutter/material.dart';
2 import 'package:hugeicons/hugeicons.dart';
3 import 'package:url_launcher/url_launcher.dart';
4 import 'package:localmind/core/theme/colors.dart';
5
6 import '../../../l10n/app_localizations.dart';
7
8 class GitHubRepoCard extends StatelessWidget {
9 const GitHubRepoCard({super.key});
10
11 static final Uri _repoUri = Uri.parse(
12 'https://github.com/abdulmominsakib/localmind',
13 );
14
15 Future<void> _launchUrl(BuildContext context) async {
16 final messenger = ScaffoldMessenger.maybeOf(context);
17 final l10n = AppLocalizations.of(context);
18 try {
19 final launched = await launchUrl(
20 _repoUri,
21 mode: LaunchMode.externalApplication,
22 );
23 if (!launched && messenger != null) {
24 messenger.showSnackBar(
25 SnackBar(
26 content: Text(
27 l10n?.could_not_open_github ?? 'Could not open GitHub.',
28 ),
29 ),
30 );
31 }
32 } catch (_) {
33 if (messenger != null) {
34 messenger.showSnackBar(
35 SnackBar(
36 content: Text(
37 l10n?.could_not_open_github ?? 'Could not open GitHub.',
38 ),
39 ),
40 );
41 }
42 }
43 }
44
45 @override
46 Widget build(BuildContext context) {
47 final l10n = AppLocalizations.of(context)!;
48 final isDark = Theme.of(context).brightness == Brightness.dark;
49
50 return Padding(
51 padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
52 child: Container(
53 decoration: BoxDecoration(
54 color: isDark ? AppColors.darkSurfaceCard : AppColors.lightSurface,
55 border: Border.all(
56 color: isDark ? AppColors.darkBorder : AppColors.lightBorder,
57 ),
58 borderRadius: BorderRadius.circular(8),
59 ),
60 child: InkWell(
61 onTap: () => _launchUrl(context),
62 borderRadius: BorderRadius.circular(8),
63 child: Padding(
64 padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
65 child: Row(
66 children: [
67 HugeIcon(
68 icon: HugeIcons.strokeRoundedGithub,
69 size: 20,
70 color: isDark
71 ? AppColors.darkPrimaryText
72 : AppColors.lightPrimaryText,
73 ),
74 const SizedBox(width: 10),
75 Expanded(
76 child: Column(
77 crossAxisAlignment: CrossAxisAlignment.start,
78 mainAxisSize: MainAxisSize.min,
79 children: [
80 Text(
81 l10n.open_source,
82 style: TextStyle(
83 fontSize: 13,
84 fontWeight: FontWeight.w600,
85 color: isDark
86 ? AppColors.darkPrimaryText
87 : AppColors.lightPrimaryText,
88 ),
89 ),
90 const SizedBox(height: 2),
91 Text(
92 l10n.star_on_github,
93 style: TextStyle(
94 fontSize: 11,
95 fontWeight: FontWeight.w500,
96 color: isDark
97 ? AppColors.darkAccent
98 : AppColors.lightAccent,
99 ),
100 ),
101 ],
102 ),
103 ),
104 HugeIcon(
105 icon: HugeIcons.strokeRoundedShare01,
106 size: 14,
107 color: isDark
108 ? AppColors.darkMutedText
109 : AppColors.lightMutedText,
110 ),
111 ],
112 ),
113 ),
114 ),
115 ),
116 );
117 }
118 }