Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding a snackbar for feedback on the share button #1520

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/app_center/lib/src/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"snapPagePublishedLabel": "Published",
"snapPageSummaryLabel": "Summary",
"snapPageVersionLabel": "Version",
"snapPageShareLinkCopiedMessage": "Link copied to clipboard",
"explorePageLabel": "Explore",
"explorePageCategoriesLabel": "Categories",
"managePageCheckForUpdates": "Check for updates",
Expand Down
17 changes: 14 additions & 3 deletions packages/app_center/lib/src/snapd/snap_page.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';

import 'package:app_center/src/store/store_app.dart';
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand Down Expand Up @@ -546,14 +547,16 @@ class _Section extends YaruExpandable {
);
}

class _Header extends StatelessWidget {
class _Header extends ConsumerWidget {
const _Header({required this.snapModel});

final SnapModel snapModel;

@override
Widget build(BuildContext context) {
Widget build(BuildContext context, WidgetRef ref) {
final snap = snapModel.storeSnap ?? snapModel.localSnap!;
final l10n = AppLocalizations.of(context);

return Column(
children: [
Row(
Expand All @@ -564,7 +567,15 @@ class _Header extends StatelessWidget {
YaruIconButton(
icon: const Icon(YaruIcons.share),
onPressed: () {
// TODO show snackbar
final navigationKey =
ref.watch(materialAppNavigatorKeyProvider);

ScaffoldMessenger.of(navigationKey.currentContext!)
.showSnackBar(
SnackBar(
content: Text(l10n.snapPageShareLinkCopiedMessage),
),
);
Clipboard.setData(ClipboardData(text: snap.website!));
},
),
Expand Down
5 changes: 5 additions & 0 deletions packages/app_center/lib/src/store/store_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import 'store_pages.dart';
import 'store_providers.dart';
import 'store_routes.dart';

// Making a provider to provide navigatorKeyTwo
final materialAppNavigatorKeyProvider =
Provider((ref) => GlobalKey<NavigatorState>());

class StoreApp extends ConsumerStatefulWidget {
const StoreApp({super.key});

Expand All @@ -38,6 +42,7 @@ class _StoreAppState extends ConsumerState<StoreApp> {
darkTheme: yaru.darkTheme,
debugShowCheckedModeBanner: false,
localizationsDelegates: localizationsDelegates,
navigatorKey: ref.watch(materialAppNavigatorKeyProvider),
supportedLocales: supportedLocales,
home: Scaffold(
appBar: YaruWindowTitleBar(
Expand Down