Skip to content

Commit

Permalink
Show Visual Cues
Browse files Browse the repository at this point in the history
  • Loading branch information
palmer-matthew committed Sep 7, 2020
1 parent 585ad2b commit fed16bc
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions lib/screens/scholarship_screen/scholarship_detailsview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:clipboard/clipboard.dart';
class ScholarshipDetailsView extends StatelessWidget {

final Scholarship current;
final Map<String, dynamic> theme = {'isDark': null, 'theme': null};
final Map<String, dynamic> theme = {'isDark': null, 'theme': null, 'context': null};

ScholarshipDetailsView({this.current});

Expand All @@ -21,7 +21,10 @@ class ScholarshipDetailsView extends StatelessWidget {
IconButton(
icon: Icon(Icons.content_copy),
onPressed: (){
FlutterClipboard.copy(current.toString()).then(( value ) => print('copied'));
FlutterClipboard.copy(current.toString()).then(
( value ) => _showDialog(false),
onError: (error) => _showDialog(true),
);
},
tooltip: "Copy to Clipboard",
)
Expand Down Expand Up @@ -243,9 +246,39 @@ class ScholarshipDetailsView extends StatelessWidget {
return result;
}

void _showDialog(bool error) {
showDialog(
context: theme['context'],
builder: (BuildContext context) {
return !error ? AlertDialog(
titlePadding: const EdgeInsets.all(5),
contentPadding: const EdgeInsets.all(0),
title: ListTile(
title: Text("Copied to Clipboard"),
trailing: Icon(
Icons.check,
color: Colors.green,
),
),
): AlertDialog(
titlePadding: const EdgeInsets.all(5),
contentPadding: const EdgeInsets.all(0),
title: ListTile(
title: Text("Not Copied to Clipboard"),
trailing: Icon(
Icons.clear,
color: Colors.red,
),
),
);
},
);
}


@override
Widget build(BuildContext context) {
theme['context'] = context;
ThemeModel themeModel = Provider.of<ThemeModel>(context, listen: false,);
theme['theme'] = Theme.of(context);
theme['isDark'] = themeModel.selectedTheme == ThemeMode.dark ||
Expand Down

0 comments on commit fed16bc

Please sign in to comment.