Merge pull request #6 from Iconica-Development/feature/Icons_as_widget

Feature/icons as widget
This commit is contained in:
Jacques Doeleman 2022-09-26 13:44:50 +02:00 committed by GitHub
commit 324b2b791f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 163 additions and 61 deletions

View file

@ -1,6 +0,0 @@
# This is a generated file; do not edit or check into version control.
flutter_plugin_android_lifecycle=C:\\src\\flutter\\.pub-cache\\hosted\\pub.dartlang.org\\flutter_plugin_android_lifecycle-2.0.7\\
image_picker=C:\\src\\flutter\\.pub-cache\\hosted\\pub.dartlang.org\\image_picker-0.8.5+3\\
image_picker_android=C:\\src\\flutter\\.pub-cache\\hosted\\pub.dartlang.org\\image_picker_android-0.8.5+2\\
image_picker_for_web=C:\\src\\flutter\\.pub-cache\\hosted\\pub.dartlang.org\\image_picker_for_web-2.1.8\\
image_picker_ios=C:\\src\\flutter\\.pub-cache\\hosted\\pub.dartlang.org\\image_picker_ios-0.8.5+6\\

View file

@ -1 +0,0 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"image_picker_ios","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_ios-0.8.5+6\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"flutter_plugin_android_lifecycle","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-2.0.7\\\\","native_build":true,"dependencies":[]},{"name":"image_picker_android","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_android-0.8.5+2\\\\","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"]}],"macos":[],"linux":[],"windows":[],"web":[{"name":"image_picker_for_web","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_for_web-2.1.8\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"image_picker","dependencies":["image_picker_android","image_picker_for_web","image_picker_ios"]},{"name":"image_picker_android","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"image_picker_for_web","dependencies":[]},{"name":"image_picker_ios","dependencies":[]}],"date_created":"2022-09-05 15:20:35.995199","version":"3.3.0"}

2
.gitignore vendored
View file

@ -29,3 +29,5 @@ migrate_working_dir/
.packages
build/
coverage/
/.flutter-plugins
/.flutter-plugins-dependencies

View file

@ -9,9 +9,14 @@
## 0.0.3 - September 6th 2022
- More customization options for the Image Picker Dialog added:
- Font
- Text color
- Icon color
- Close Button background color
- Close Button text color
- Close Button text size
- Font
- Text color
- Icon color
- Close Button background color
- Close Button text color
- Close Button text size
## 1.0.0 - September 26th 2022
- Icons can be changed by Widgets instead of IconData.

View file

@ -1,4 +1,5 @@
# Flutter Image Picker
Flutter Image Picker is a package you can use to implement an Image Picker in your Flutter app.
![Gif](example/gif/ImagePickerGif.gif)
@ -19,30 +20,29 @@ You can add an optional `ImagePickerTheme()` to the `ImagePicker()` to change th
An example on how to add a parameter to the `ImagePickerTheme()` is: `ImagePickerTheme(imagePickerTheme: const ImagePickerTheme(title: "Image Picker"))`.
As a whole you get `ImagePicker(ImagePickerTheme(imagePickerTheme: const ImagePickerTheme(title: "Image Picker")))`
| Parameter | Explaination |
|-------------------|----------------|
| font | The font that is being used in the Image Picker Dialog. |
| title | The title displayed at the top of the Image Picker Dialog. |
| titleTextSize | The font size of the title mentioned above. |
| titleColor | The color of the title text. |
| titleBackgroundColor | The color of the title background. |
| titleAlignment | The alignment of the title text. |
| textColor | The color of the text that is displayed in the Image Picker Dialog. |
| iconColor | The color of the icons that are displayed in the Image Picker Dialog. |
| iconSize | The size of the icons that are visible in the Image Picker Dialog. |
| iconTextSize | The font size of the text underneath the icon buttons. |
| spaceBetweenIcons | The size of the space between the two icons in the Image Picker Dialog. |
| makePhotoIcon | The icon that is displayed for the 'Make Photo' functionality of the Image Picker Dialog. |
| makePhotoText | The text that is displayed underneath the 'Make Photo' icon. |
| selectImageIcon | The icon that is displayed for the 'Select Image From Gallery' functionality of the Image Picker Dialog. |
| selectImageText | The text that is displayed underneath the 'Select Image From Gallery' icon. |
| closeButtonText | The text that is shown on the 'Close Dialog' button at the bottom of the Image Picker Dialog. |
| closeButtonTextSize | The size of the text that is being displayed on the 'Close Dialog' button at the bottom of the Image Picker Dialog. |
| closeButtonTextColor | The color of the text that is being displayed on the 'Close Dialog' button at the bottom of the Image Picker Dialog. |
| closeButtonWidth | The width of the 'Close Dialog' button at the bottom of the Image Picker Dialog. |
| closeButtonHeight | The height of the 'Close Dialog' button at the bottom of the Image Picker Dialog. |
| closeButtonBackgroundColor | The background color of the 'Close Dialog' button at the bottom of the Image Picker Dialog. |
| Parameter | Explaination |
| -------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| font | The font that is being used in the Image Picker Dialog. |
| title | The title displayed at the top of the Image Picker Dialog. |
| titleTextSize | The font size of the title mentioned above. |
| titleColor | The color of the title text. |
| titleBackgroundColor | The color of the title background. |
| titleAlignment | The alignment of the title text. |
| textColor | The color of the text that is displayed in the Image Picker Dialog. |
| iconColor | The color of the icons that are displayed in the Image Picker Dialog. |
| iconSize | The size of the icons that are visible in the Image Picker Dialog. |
| iconTextSize | The font size of the text underneath the icon buttons. |
| spaceBetweenIcons | The size of the space between the two icons in the Image Picker Dialog. |
| makePhotoIcon | The widget that is displayed for the 'Make Photo' functionality of the Image Picker Dialog. |
| makePhotoText | The text that is displayed underneath the 'Make Photo' icon. |
| selectImageIcon | The widget that is displayed for the 'Select Image From Gallery' functionality of the Image Picker Dialog. |
| selectImageText | The text that is displayed underneath the 'Select Image From Gallery' icon. |
| closeButtonText | The text that is shown on the 'Close Dialog' button at the bottom of the Image Picker Dialog. |
| closeButtonTextSize | The size of the text that is being displayed on the 'Close Dialog' button at the bottom of the Image Picker Dialog. |
| closeButtonTextColor | The color of the text that is being displayed on the 'Close Dialog' button at the bottom of the Image Picker Dialog. |
| closeButtonWidth | The width of the 'Close Dialog' button at the bottom of the Image Picker Dialog. |
| closeButtonHeight | The height of the 'Close Dialog' button at the bottom of the Image Picker Dialog. |
| closeButtonBackgroundColor | The background color of the 'Close Dialog' button at the bottom of the Image Picker Dialog. |
## Issues

View file

@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"

View file

@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"

41
example/ios/Podfile Normal file
View file

@ -0,0 +1,41 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end

View file

@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig"

View file

@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig"

40
example/macos/Podfile Normal file
View file

@ -0,0 +1,40 @@
platform :osx, '10.11'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\""
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_macos_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_macos_build_settings(target)
end
end

View file

@ -68,7 +68,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.0.1"
version: "1.0.0"
flutter_lints:
dependency: "direct dev"
description:

View file

@ -15,9 +15,9 @@ class ImagePickerTheme {
this.iconSize = 125,
this.iconTextSize = 15,
this.spaceBetweenIcons = 30,
this.makePhotoIcon = Icons.camera_alt_rounded,
this.makePhotoIcon,
this.makePhotoText = "Take a Picture",
this.selectImageIcon = Icons.image,
this.selectImageIcon,
this.selectImageText = "Select File",
this.closeButtonText = "Close",
this.closeButtonTextSize = 15,
@ -61,13 +61,13 @@ class ImagePickerTheme {
final double spaceBetweenIcons;
/// The icon that is displayed for the 'Make Photo' functionality of the Image Picker Dialog.
final IconData makePhotoIcon;
final Widget? makePhotoIcon;
/// The text that is displayed underneath the 'Make Photo' icon.
final String makePhotoText;
/// The icon that is displayed for the 'Select Image From Gallery' functionality of the Image Picker Dialog.
final IconData selectImageIcon;
final Widget? selectImageIcon;
/// The text that is displayed underneath the 'Select Image From Gallery' icon.
final String selectImageText;

View file

@ -50,8 +50,9 @@ class ImagePicker extends StatelessWidget {
children: [
_generateIconButtonWithText(
context,
imagePickerTheme,
imagePickerTheme.selectImageIcon,
imagePickerTheme,
Icons.image,
ImageSource.gallery,
imagePickerTheme.selectImageText),
SizedBox(
@ -59,8 +60,9 @@ class ImagePicker extends StatelessWidget {
),
_generateIconButtonWithText(
context,
imagePickerTheme,
imagePickerTheme.makePhotoIcon,
imagePickerTheme,
Icons.camera_alt_rounded,
ImageSource.camera,
imagePickerTheme.makePhotoText),
],
@ -105,6 +107,7 @@ class ImagePicker extends StatelessWidget {
/// [bottomText] The text that's displayed underneath the icon.
Column _generateIconButtonWithText(
BuildContext context,
Widget? customIcon,
ImagePickerTheme imagePickerTheme,
IconData icon,
ImageSource imageSource,
@ -112,17 +115,20 @@ class ImagePicker extends StatelessWidget {
return Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
IconButton(
InkWell(
key: Key(bottomText),
icon: Icon(icon),
iconSize: imagePickerTheme.iconSize,
color: imagePickerTheme.iconColor,
onPressed: () async {
onTap: () async {
final navigator = Navigator.of(context);
var image = await (imagePickerService ?? ImagePickerService())
.pickImage(imageSource);
navigator.pop(image);
},
child: customIcon ??
Icon(
icon,
size: imagePickerTheme.iconSize,
color: imagePickerTheme.iconColor,
),
),
Text(
bottomText,

View file

@ -1,6 +1,6 @@
name: flutter_image_picker
description: A new Flutter package project.
version: 0.0.1
version: 1.0.0
homepage: https://github.com/Iconica-Development/flutter_image_picker
environment:

View file

@ -14,17 +14,20 @@ void main() {
Uint8List galleryImage = Uint8List(44);
testWidgets('Image Picker Shows With Normal Theme', (tester) async {
await tester.pumpWidget(const MaterialApp(
home: Material(child: iconica_image_picker.ImagePicker())));
await tester.pumpWidget(
const MaterialApp(
home: Material(
child: iconica_image_picker.ImagePicker(),
),
),
);
final titleFinder =
find.text(const iconica_image_picker.ImagePickerTheme().title);
final makePhotoIconFinder = find
.byIcon(const iconica_image_picker.ImagePickerTheme().makePhotoIcon);
final makePhotoIconFinder = find.byIcon(Icons.camera_alt_rounded);
final makePhotoTextFinder =
find.text(const iconica_image_picker.ImagePickerTheme().makePhotoText);
final selectImageIconFinder = find
.byIcon(const iconica_image_picker.ImagePickerTheme().selectImageIcon);
final selectImageIconFinder = find.byIcon(Icons.image);
final selectImageTextFinder = find
.text(const iconica_image_picker.ImagePickerTheme().selectImageText);
final closebuttonTextFinder = find
@ -84,9 +87,17 @@ void main() {
testWidgets('Image Picker Shows With Custom Theme', (tester) async {
String title = "title";
IconData makePhotoIcon = Icons.motorcycle;
Widget makePhotoIcon = Container(
height: 125,
width: 125,
color: Colors.red,
);
String makePhotoText = "taaaake image";
IconData selectImageIcon = Icons.chevron_left;
Widget selectImageIcon = Container(
height: 125,
width: 125,
color: Colors.blue,
);
String selectImageText = "seleeeeect image";
String closeButtonText = "Close Dialog!";
@ -102,9 +113,9 @@ void main() {
closeButtonText: closeButtonText)))));
final titleFinder = find.text(title);
final makePhotoIconFinder = find.byIcon(makePhotoIcon);
final makePhotoIconFinder = find.byWidget(makePhotoIcon);
final makePhotoTextFinder = find.text(makePhotoText);
final selectImageIconFinder = find.byIcon(selectImageIcon);
final selectImageIconFinder = find.byWidget(selectImageIcon);
final selectImageTextFinder = find.text(selectImageText);
final closebuttonTextFinder = find.text(closeButtonText);