Skip to content

Commit

Permalink
Dialog page
Browse files Browse the repository at this point in the history
  • Loading branch information
nbaklanov-issart committed Jun 18, 2021
1 parent a81cfea commit 1212013
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 36 deletions.
7 changes: 3 additions & 4 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Test needs</string>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
Expand All @@ -24,15 +22,16 @@
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Test needs</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
Expand Down
64 changes: 58 additions & 6 deletions example/lib/draw_options_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_colorpicker/flutter_colorpicker.dart';

class DrawOptionsDialog extends StatefulWidget {
const DrawOptionsDialog({ Key? key }) : super(key: key);
Expand All @@ -8,15 +9,66 @@ class DrawOptionsDialog extends StatefulWidget {
}

class _DrawOptionsDialogState extends State<DrawOptionsDialog> {
final TextEditingController _drawTextController = new TextEditingController();
final TextEditingController _fontSizeController = new TextEditingController();
Color _selectedColor = Colors.red;

@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: ListBody(
children: const <Widget>[
Text('This is a demo alert dialog.'),
Text('Would you like to approve of this message?'),
]
return Scaffold(
body: SafeArea(
child: SingleChildScrollView(
child: Column(
children: [
_buildTextInputField(),
_buildTextSizeField(),
_buildColorPicker()
]
)
),
),
);
}

Widget _buildTextInputField() {
return Padding(
padding: const EdgeInsets.all(20.0),
child: TextField(
controller: _drawTextController,
keyboardType: TextInputType.multiline,
maxLines: null,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Text to draw',
)
)
);
}

Widget _buildTextSizeField() {
return Padding(
padding: const EdgeInsets.all(20.0),
child: TextField(
controller: _fontSizeController,
keyboardType: TextInputType.number,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Font Size',
)
)
);
}

Widget _buildColorPicker() {
return ColorPicker(
pickerColor: _selectedColor,
onColorChanged: _onColorChange,
showLabel: true,
pickerAreaHeightPercent: 0.8,
);
}

void _onColorChange(Color newColor) {
_selectedColor = newColor;
}
}
52 changes: 26 additions & 26 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,26 @@ class _MyAppState extends State<MyApp> {
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: FutureBuilder<String>(
body: Container(
child: ElevatedButton(
onPressed: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => DrawOptionsDialog()
)
),
child: Container(
color: Colors.blue,
padding: const EdgeInsets.all(10.0),
child: const Text("Draw"),
)
),
)
),
);
}

/*
FutureBuilder<String>(
future: _initPlatformState(),
builder: (futureContext, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
Expand All @@ -61,9 +80,7 @@ class _MyAppState extends State<MyApp> {
}
}
)
),
);
}
*/

Widget _buildMainScreen(BuildContext context, String bytes) {
return Container(
Expand All @@ -72,7 +89,11 @@ class _MyAppState extends State<MyApp> {
children: [
Image.file(File(bytes)),
ElevatedButton(
onPressed: () => _showMyDialog(context),
onPressed: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => DrawOptionsDialog()
)
),
child: Container(
color: Colors.blue,
padding: const EdgeInsets.all(10.0),
Expand All @@ -83,25 +104,4 @@ class _MyAppState extends State<MyApp> {
)
);
}

Future<void> _showMyDialog(BuildContext context) async {
return showDialog<void>(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('Draw parameters'),
content: DrawOptionsDialog(),
actions: <Widget>[
TextButton(
child: const Text('Try to Draw'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
}
}
1 change: 1 addition & 0 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dependencies:
sdk: flutter

path_provider: ^2.0.2
flutter_colorpicker: ^0.4.0
draw_on_image_plugin:
# When depending on this package from a real application you should use:
# draw_on_image_plugin: ^x.y.z
Expand Down

0 comments on commit 1212013

Please sign in to comment.