update invoice
This commit is contained in:
90
lib/pages/widgets/image_file_picker.dart
Normal file
90
lib/pages/widgets/image_file_picker.dart
Normal file
@@ -0,0 +1,90 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_icons/flutter_icons.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'local_text.dart';
|
||||
|
||||
typedef OnFile = void Function(File);
|
||||
|
||||
modelBottomSheet(BuildContext context, {final OnFile onFile}) {
|
||||
showModalBottomSheet(
|
||||
elevation: 10,
|
||||
backgroundColor: Colors.white,
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ImageFile(onFile: onFile);
|
||||
});
|
||||
}
|
||||
|
||||
class ImageFile extends StatefulWidget {
|
||||
final OnFile onFile;
|
||||
|
||||
const ImageFile({Key key, this.onFile}) : super(key: key);
|
||||
@override
|
||||
_ImageFileState createState() => _ImageFileState();
|
||||
}
|
||||
|
||||
class _ImageFileState extends State<ImageFile> {
|
||||
File selectedFile;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.only(bottom: 20, top: 20),
|
||||
child: new Wrap(
|
||||
children: <Widget>[
|
||||
new ListTile(
|
||||
leading: CircleAvatar(
|
||||
radius: 20,
|
||||
backgroundColor: Colors.green,
|
||||
child: Icon(MaterialIcons.insert_photo, color: Colors.white),
|
||||
),
|
||||
title: LocalText(context, "profile.gallery",
|
||||
color: Colors.black87, fontSize: 15),
|
||||
onTap: () async {
|
||||
Navigator.pop(context);
|
||||
selectedFile = await pickImage(ImageSource.gallery);
|
||||
if (widget.onFile != null) widget.onFile(selectedFile);
|
||||
}),
|
||||
new ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Colors.blue,
|
||||
radius: 20,
|
||||
child: Center(child: Icon(AntDesign.camera, color: Colors.white)),
|
||||
),
|
||||
title: LocalText(context, "profile.camera",
|
||||
color: Colors.black87, fontSize: 15),
|
||||
onTap: () async {
|
||||
Navigator.pop(context);
|
||||
selectedFile = await pickImage(ImageSource.camera);
|
||||
|
||||
if (widget.onFile != null) widget.onFile(selectedFile);
|
||||
},
|
||||
),
|
||||
new ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Colors.red,
|
||||
radius: 20,
|
||||
child: Icon(Icons.delete, color: Colors.white),
|
||||
),
|
||||
title: LocalText(context, "profile.remove_photo",
|
||||
color: Colors.black87, fontSize: 15),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
setState(() {
|
||||
selectedFile = null;
|
||||
});
|
||||
|
||||
if (widget.onFile != null) widget.onFile(selectedFile);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
pickImage(ImageSource source) async {
|
||||
var tempImage = await ImagePicker.pickImage(source: source);
|
||||
return tempImage;
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,9 @@ class ShowImage extends StatefulWidget {
|
||||
final String url;
|
||||
final File imageFile;
|
||||
final String fileName;
|
||||
const ShowImage({Key key, this.imageFile, this.fileName, this.url})
|
||||
final String localImage;
|
||||
const ShowImage(
|
||||
{Key key, this.imageFile, this.fileName, this.url, this.localImage})
|
||||
: super(key: key);
|
||||
@override
|
||||
_ShowImageState createState() => _ShowImageState();
|
||||
@@ -20,16 +22,17 @@ class _ShowImageState extends State<ShowImage> {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: primaryColor,
|
||||
title: Text(widget.fileName),
|
||||
title: Text(widget.fileName, style: TextStyle(color: Colors.white)),
|
||||
iconTheme: new IconThemeData(color: Colors.white),
|
||||
),
|
||||
body: Center(
|
||||
child: widget.url != null || widget.imageFile != null
|
||||
? PhotoView(
|
||||
imageProvider: widget.url != null
|
||||
? NetworkImage(widget.url)
|
||||
: FileImage(widget.imageFile),
|
||||
minScale: PhotoViewComputedScale.contained * 1)
|
||||
: Container()),
|
||||
child: PhotoView(
|
||||
imageProvider: widget.url != null
|
||||
? NetworkImage(widget.url)
|
||||
: widget.imageFile != null
|
||||
? FileImage(widget.imageFile)
|
||||
: AssetImage(widget.localImage),
|
||||
minScale: PhotoViewComputedScale.contained * 1)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user