-
Notifications
You must be signed in to change notification settings - Fork 103
PAINTROID-787: "Tip of the day" for Paintroid features #115
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,187 @@ | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:paintroid/ui/shared/images/animated_light_bulb.dart'; | ||
| import 'package:paintroid/ui/theme/theme.dart'; | ||
| import 'package:shared_preferences/shared_preferences.dart'; | ||
|
|
||
| Future<void> showTipDialog(BuildContext context) => showGeneralDialog( | ||
| context: context, | ||
| barrierDismissible: false, | ||
| barrierLabel: 'Tip of the Day', | ||
| pageBuilder: (_, __, ___) => const TipOfTheDayDialog(), | ||
| ); | ||
|
|
||
| Future<void> showTipIfEnabled(BuildContext context) async { | ||
| final prefs = await SharedPreferences.getInstance(); | ||
| final showTip = prefs.getBool('showTip') ?? true; | ||
| if (showTip && context.mounted) { | ||
| await showTipDialog(context); | ||
| } | ||
| } | ||
|
|
||
| final List<Map<String, String>> tips = [ | ||
| { | ||
| 'title': 'Layer menu', | ||
| 'content': | ||
| 'Shows the current layers, you can add new, delete, show and hide layers and set transparency of the layer.', | ||
| }, | ||
| { | ||
| 'title': 'Antialiasing', | ||
| 'content': | ||
| 'Antialiasing is the reduction of unwanted effects that can arise from the limited pixel grid. You can turn antialiasing on and off in the Advanced Settings.', | ||
| }, | ||
| { | ||
| 'title': 'Smoothing', | ||
| 'content': | ||
| 'The idea is that the smaller details in the image are smoothed out. You can turn smoothing on and off in the Advanced Settings.', | ||
| }, | ||
| { | ||
| 'title': 'Zoom window settings', | ||
| 'content': 'The zoom window can be turned on or off and the zoom can be changed here.', | ||
| }, | ||
| { | ||
| 'title': 'Export', | ||
| 'content': | ||
| 'The created image can be saved in various image formats (png, jpg, ...). It is also possible to save it as a catrobat-image in order to continue editing later.', | ||
| }, | ||
| { | ||
| 'title': 'Load image', | ||
| 'content': | ||
| 'Upload an image or a catrobat-image. The uploaded image can replace the current one or be added to the current layer.', | ||
| }, | ||
| { | ||
| 'title': 'Color Picker', | ||
| 'content': | ||
| 'The color picker can be used to set the color and transparency for the tool. Use a predefined standard color or define a color yourself with RGB values and HEX codes. With the pipette you can choose an already existing color on the canvas.', | ||
| }, | ||
| { | ||
| 'title': 'Hide Buttons', | ||
| 'content': | ||
| 'You can hide the header and the toolbar. You can display them again using the back button on your phone.', | ||
| }, | ||
| { | ||
| 'title': 'Share image', | ||
| 'content': 'You can share your picture via messaging apps or email.', | ||
| }, | ||
| { | ||
| 'title': 'Help', | ||
| 'content': | ||
| 'You can use \'Help\' in the menu to start the Paintroid tutorial, where the tools and functions are explained.', | ||
| }, | ||
| { | ||
| 'title': 'Calligraphy', | ||
| 'content': | ||
| 'The calligraphy pen and chalk pen can be selected in the brush tool. The inclination of the pen can be adjusted. There are also templates for practicing calligraphy, which can be found under Import Image.', | ||
| }, | ||
| ]; | ||
|
|
||
| class TipOfTheDayDialog extends StatefulWidget { | ||
| const TipOfTheDayDialog({super.key}); | ||
|
|
||
| @override | ||
| State<TipOfTheDayDialog> createState() => _TipOfTheDayDialogState(); | ||
| } | ||
|
|
||
| class _TipOfTheDayDialogState extends State<TipOfTheDayDialog> { | ||
| int currentTipIndex = 0; | ||
|
|
||
| @override | ||
| void initState() { | ||
| super.initState(); | ||
| _loadTipIndex(); | ||
| } | ||
|
|
||
| Future<void> _loadTipIndex() async { | ||
| final prefs = await SharedPreferences.getInstance(); | ||
| final tipIndex = prefs.getInt('tipIndex') ?? 0; | ||
| setState(() { | ||
| currentTipIndex = tipIndex; | ||
| }); | ||
| } | ||
|
|
||
| Future<void> _incrementTipIndex() async { | ||
| final prefs = await SharedPreferences.getInstance(); | ||
| final tipIndex = prefs.getInt('tipIndex') ?? 0; | ||
| prefs.setInt('tipIndex', (tipIndex + 1) % tips.length); | ||
| currentTipIndex = (tipIndex + 1) % tips.length; | ||
| } | ||
|
|
||
| Future<void> _closeTipDialog(BuildContext context) async { | ||
| Navigator.of(context).pop(); | ||
| await _incrementTipIndex(); | ||
| } | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| final currentTip = tips[currentTipIndex]; | ||
| return AlertDialog( | ||
| contentPadding: EdgeInsets.zero, | ||
| backgroundColor: PaintroidTheme.of(context).onSurfaceColor, | ||
| titlePadding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12), | ||
| title: Row( | ||
| mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
| children: [ | ||
| Text( | ||
| 'Tip of the Day', | ||
| style: PaintroidTheme.of(context).titleTheme.titleMedium, | ||
| ), | ||
| IconButton( | ||
| icon: const Icon(Icons.close), | ||
| onPressed: () async { | ||
| await _closeTipDialog(context); | ||
| }, | ||
| ), | ||
| ], | ||
| ), | ||
| content: Column( | ||
| mainAxisSize: MainAxisSize.min, | ||
| crossAxisAlignment: CrossAxisAlignment.center, | ||
| children: [ | ||
| const Divider(height: 1, thickness: 1), | ||
| Padding( | ||
| padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 16.0), | ||
| child: Column( | ||
| children: [ | ||
| const SizedBox(height: 100, child: AnimatedLightBulb()), | ||
| const SizedBox(height: 16), | ||
| Text( | ||
| currentTip['title']!, | ||
| textAlign: TextAlign.center, | ||
| style: PaintroidTheme.of(context).textTheme.bodyMedium!.apply(fontWeightDelta: 2), | ||
| ), | ||
| const SizedBox(height: 8), | ||
| Text( | ||
| currentTip['content']!, | ||
| textAlign: TextAlign.center, | ||
| style: PaintroidTheme.of(context).textTheme.bodyMedium, | ||
| ), | ||
| ], | ||
| ), | ||
| ), | ||
| const Divider(height: 1, thickness: 1), | ||
| ], | ||
| ), | ||
| actionsPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), | ||
| actions: [ | ||
| TextButton( | ||
| onPressed: () async { | ||
| await _closeTipDialog(context); | ||
| }, | ||
| child: Text( | ||
| 'Close', | ||
| style: TextStyle(color: PaintroidTheme.of(context).primaryColor), | ||
| ), | ||
| ), | ||
| TextButton( | ||
| onPressed: () async { | ||
| await _incrementTipIndex(); | ||
| setState(() {}); | ||
| }, | ||
| child: Text( | ||
| 'Next', | ||
| style: TextStyle(color: PaintroidTheme.of(context).primaryColor), | ||
| ), | ||
| ), | ||
| ], | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import 'package:flutter/material.dart'; | ||
|
|
||
| class AnimatedLightBulb extends StatelessWidget { | ||
| const AnimatedLightBulb({super.key}); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return SizedBox( | ||
| child: Image.asset( | ||
| 'assets/img/animated_light_bulb.gif', | ||
| repeat: ImageRepeat.repeat, | ||
| cacheWidth: 50, | ||
| cacheHeight: 50, | ||
| filterQuality: FilterQuality.none, | ||
| ), | ||
| ); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the default 80 character limit.