Skip to content
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

UI CHANGES #29

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/Utils/constants.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';

const primaryColor = Colors.purple;
const primaryColor = Color.fromRGBO(114, 5, 210, 1);
const secondaryColor = Color.fromRGBO(227, 4, 37, 1);
const textStyle = TextStyle(color: Colors.white);
const pdfPathAndroid = "storage/emulated/0/Easy Scan";
1 change: 1 addition & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'EasyScan',
theme: ThemeData(
appBarTheme: const AppBarTheme(color: primaryColor),
Expand Down
76 changes: 49 additions & 27 deletions lib/screens/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,57 @@ class _HomeScreenState extends State<HomeScreen> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Easy Scan"),
backgroundColor: primaryColor,
title: const Text(
"Easy Scan",
style: TextStyle(
fontSize: 24, fontWeight: FontWeight.bold, color: Colors.white),
),
centerTitle: true,
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
HomeCard(
onTap: () => Navigator.push(
context, MaterialPageRoute(builder: (_) => ScanAndConvert())),
iconData: Icons.image_search,
color: Colors.red,
text: 'Scan and convert',
),
HomeCard(
onTap: () => Navigator.push(
context, MaterialPageRoute(builder: (_) => ImageToPdf())),
iconData: Icons.picture_as_pdf_outlined,
color: Colors.green,
text: 'Images to Pdf',
),
HomeCard(
onTap: () => Navigator.push(
context, MaterialPageRoute(builder: (_) => SavedPdfScreen())),
iconData: Icons.save_rounded,
color: Colors.amber,
text: 'History',
),
],
),
body: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
SizedBox(
height: MediaQuery.of(context).size.longestSide * 0.2,
),
HomeCard(
onTap: () => Navigator.push(
context, MaterialPageRoute(builder: (_) => ScanAndConvert())),
iconData: Icons.image_search,
text: 'Scan and Convert',
),
HomeCard(
onTap: () => Navigator.push(
context, MaterialPageRoute(builder: (_) => ImageToPdf())),
iconData: Icons.picture_as_pdf_outlined,
text: 'Pick and Export',
),
// This widget is needed to be implemented for recent projects
// Expanded(
// child: Container(
// padding: const EdgeInsets.only(top: 10, left: 10, right: 10),
// margin: const EdgeInsets.only(top: 20),
// decoration: BoxDecoration(
// color: Colors.grey.shade300,
// borderRadius: const BorderRadius.only(
// topLeft: Radius.circular(50),
// topRight: Radius.circular(50))),
// child: GridView.builder(
// gridDelegate:
// const SliverGridDelegateWithFixedCrossAxisCount(
// crossAxisCount: 2,
// mainAxisSpacing: 1,
// crossAxisSpacing: 1),
// itemBuilder: (context, index) {
// return Container(
// margin: const EdgeInsets.symmetric(horizontal: 10),
// child: Center(
// child: Text(
// index.toString(),
// ),
// ));
// })))
]),

);
}
}
107 changes: 69 additions & 38 deletions lib/screens/images_to_pdf.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import 'dart:io';

import 'package:EasyScan/Utils/constants.dart';
import 'package:EasyScan/Utils/methods.dart';

import 'package:flutter/material.dart';
import 'package:EasyScan/Utils/methods.dart';
import 'package:image_picker/image_picker.dart';
Expand Down Expand Up @@ -32,46 +36,73 @@ class _ImageToPdfState extends State<ImageToPdf> {
@override
Widget build(BuildContext context) {
return Scaffold(
floatingActionButton: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
if (_images.isNotEmpty)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: FloatingActionButton.extended(
heroTag: 'export',
onPressed: () => exportPdf(_images),
icon: const Icon(Icons.upload_file),
label: const Text('Export'),
backgroundColor: Colors.green,
),

floatingActionButton: Padding(
padding: const EdgeInsets.all(16.0),
child: FloatingActionButton.extended(
onPressed: () {
(_images.isNotEmpty)
? exportPdf(_images)
: showDialog(
context: context,
builder: (BuildContext context) {
return SimpleDialog(
title: const Text("Please select some images first."),
children: [
SimpleDialogOption(
onPressed: () {
Navigator.of(context).pop();
},
child: const Text("OK"),
)
],
);
});
},
backgroundColor: primaryColor,
splashColor: secondaryColor,
elevation: 8.0,
icon: const Icon(Icons.upload_file),
label: const Text(
'Export',
style: TextStyle(
color: Colors.white,
fontSize: 12,
fontWeight: FontWeight.w700),
),
FloatingActionButton.extended(
heroTag: 'addimg',
onPressed: getImageFromGallery,
icon: const Icon(Icons.add),
label: const Text('Add image'),
),
],
),
appBar: AppBar(
title: const Text('Images to Pdf'),
),
body: Column(
children: [
CheckboxListTile(
title: const Text('Crop Image'),
value: _cropImage,
onChanged: (crop) {
setState(() {
_cropImage = crop;
});
}),
Expanded(child: _buildImageList(context)),
//TODO:make ui better
],
),
);
),
appBar: AppBar(
title: const Text(
'Choose Image',
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
),
actions: [
IconButton(
icon: const Icon(Icons.add), onPressed: getImageFromGallery)
],
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
CheckboxListTile(
checkColor: secondaryColor,
title: const Text('Crop Image',
style:
TextStyle(fontSize: 20, fontWeight: FontWeight.w500)),
value: _cropImage,
onChanged: (crop) {
setState(() {
_cropImage = crop;
});
}),
Expanded(child: _buildImageList(context)),
//TODO:make ui better
],
),
));

}

Widget _buildImageList(BuildContext context) {
Expand Down
15 changes: 13 additions & 2 deletions lib/screens/scan_and_convert.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import 'dart:io';

import 'package:EasyScan/Utils/constants.dart';
import 'package:EasyScan/Utils/methods.dart';

import 'package:flutter/material.dart';
import 'package:EasyScan/Utils/methods.dart';
import 'package:image_picker/image_picker.dart';
Expand All @@ -21,7 +25,10 @@ class _ScanAndConvertState extends State<ScanAndConvert> {
);
}
if (_imageFile == null) {
return const Center(child: CircularProgressIndicator());
return const Center(
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(primaryColor),
));
} else {
return Image.file(_imageFile);
}
Expand Down Expand Up @@ -53,7 +60,11 @@ class _ScanAndConvertState extends State<ScanAndConvert> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Image to convert'),
backgroundColor: primaryColor,
title: const Text(
'Image to convert',
style: TextStyle(color: Colors.white),
),
),
body: getBody,
);
Expand Down
46 changes: 24 additions & 22 deletions lib/widgets/home_card.dart
Original file line number Diff line number Diff line change
@@ -1,42 +1,44 @@
import 'package:EasyScan/Utils/constants.dart';
import 'package:flutter/material.dart';

class HomeCard extends StatelessWidget {
final Color color;
final String text;
final IconData iconData;
final Function onTap;
const HomeCard(
{Key key, @required this.text, this.color, this.iconData, this.onTap})
const HomeCard({Key key, @required this.text, this.iconData, this.onTap})
: super(key: key);
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: Container(
margin: const EdgeInsets.symmetric(horizontal: 15, vertical: 5),
padding: const EdgeInsets.symmetric(horizontal: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20), color: Colors.grey[200]),
alignment: Alignment.center,
height: MediaQuery.of(context).size.height / 6,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Icon(
iconData,
color: color,
size: 50,
),
Expanded(
child: Text(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
margin: const EdgeInsets.symmetric(horizontal: 15, vertical: 5),
padding: const EdgeInsets.symmetric(horizontal: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20), color: primaryColor),
alignment: Alignment.center,
height: MediaQuery.of(context).size.height / 6,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Icon(
iconData,
color: Colors.white,
size: 50,
),
Text(
text,
textAlign: TextAlign.center,
style: const TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 25,
),
),
),
],
],
),
),
),
);
Expand Down