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(#60) : share and copy unique code implement #73

Merged
merged 1 commit into from
Jun 4, 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
35 changes: 31 additions & 4 deletions lib/app/pages/child_details_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:async';

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:parental_control/app/helpers/parsing_extension.dart';
import 'package:parental_control/common_widgets/bar_chart.dart';
import 'package:parental_control/common_widgets/custom_raised_button.dart';
Expand All @@ -12,6 +13,7 @@ import 'package:parental_control/models/child_model.dart';
import 'package:parental_control/models/notification_model.dart';
import 'package:parental_control/services/database.dart';
import 'package:provider/provider.dart';
import 'package:share_plus/share_plus.dart';

class ChildDetailsPage extends StatefulWidget {
const ChildDetailsPage({required this.database, required this.childModel});
Expand Down Expand Up @@ -106,11 +108,36 @@ class _ChildDetailsPageState extends State<ChildDetailsPage> {
),
SizedBox(height: 4),
Text(
model.id,
'Long press to copy or double tap to share',
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
color: Colors.deepOrangeAccent),
fontSize: 11, color: Colors.black.withOpacity(0.35)),
),
SizedBox(height: 8),
GestureDetector(
onLongPress: () {
Clipboard.setData(
ClipboardData(text: model.id.toString()))
.then((value) {
final snackBar = SnackBar(
content: const Text('Code Copied!'),
);

// Find the ScaffoldMessenger in the widget tree
// and use it to show a SnackBar.
ScaffoldMessenger.of(context).showSnackBar(snackBar);
});
},
onDoubleTap: () async {
await Share.share(
"Enter this code on child's device:\n${model.id}");
},
child: Text(
model.id,
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
color: Colors.deepOrangeAccent),
),
),
],
),
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ dependencies:
mockito: ^5.0.0
flutter_local_notifications: ^14.0.0-dev.2
auto_size_text: ^3.0.0
share_plus: ^6.3.0

test: any

Expand Down