Skip to content

Commit

Permalink
🚀 Stable 1.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
iqfareez committed Jan 24, 2021
1 parent 588dc1b commit aa33e00
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 58 deletions.
14 changes: 7 additions & 7 deletions .firebase/hosting.YnVpbGRcd2Vi.cache
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ assets/packages/fluttertoast/assets/toastify.css,1608261943000,83009481be3e03c0e
assets/packages/fluttertoast/assets/toastify.js,1608261943000,eb9fa401153f8cea1f7a5ce4d71a03b67c0cc27be706005948fc524886e85d47
icons/Icon-192.png,1610228500860,15e8005fbedd2118e1535a07ccee4fb62ec51269f475075b18f8a89ee187a922
icons/Icon-512.png,1610228500864,c0c8d5dc26090788fb0d8d6363a2ad6fdeb25b1249afab536b84cc8d16a2cc53
assets/AssetManifest.json,1611283331376,b12748ac8a5b5a7c13c911fba13b0e8e4830e46feeff8a146bcf6c5d267b9292
assets/FontManifest.json,1611283331376,638dde6f87e8796f3054f78065f73846fc5e170e081d2501d08e3ceaa300edb5
flutter_service_worker.js,1611283331949,4b8bf2b0f1292a27ce6566d67f7bd9c3174627f1ba2a92d99ace97e1735e2139
index.html,1611283331461,4b086880a62a21c25f818f418821bccfe60b18eaeb990d66434ffc45868b0b7b
version.json,1611283331229,2aed7b6ef6d8d244970b4ae6f169eca7cf5b1c03679fe6c234b84d44671c9a0b
assets/NOTICES,1611283331377,6aad774c3f66cc73699eeb39e42bf287b77f5f452b2980b6201e1baf3f9af498
main.dart.js,1611283330751,1f392c997177df9256f77a24c2d5f6d9f04692570d598eaae7083c7264eaaccb
index.html,1611512567843,11fb98333c15009463c63acf78fcccadc0bf836af6e6e3e4d58dee5b0883496f
flutter_service_worker.js,1611512568537,fc581f2f772f72570a18f2056212419eaed55f237509261636221ccfef0d9e66
version.json,1611512567619,2aed7b6ef6d8d244970b4ae6f169eca7cf5b1c03679fe6c234b84d44671c9a0b
assets/AssetManifest.json,1611512567760,b12748ac8a5b5a7c13c911fba13b0e8e4830e46feeff8a146bcf6c5d267b9292
assets/FontManifest.json,1611512567761,638dde6f87e8796f3054f78065f73846fc5e170e081d2501d08e3ceaa300edb5
assets/NOTICES,1611512567762,b9310665e7be96e373d09aef00048f7fc906f7ae22e6c082222bc3973f31e751
main.dart.js,1611512566865,64dce244748f1e9b4fc32c2cd5581f295eafa10cbc9357e7351c95e75b786bd6
4 changes: 2 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Pubspec to Readme (Beta)',
title: 'Pubspec to Readme',
theme: ThemeData(
primarySwatch: Colors.indigo,
),
Expand All @@ -26,7 +26,7 @@ class MyHome extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('PUBSPEC to README BETA'),
title: Text('PUBSPEC to README'),
),
body: EntryPoint(),
);
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/entry_point.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class EntryPoint extends StatelessWidget {
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
padding: const EdgeInsets.only(top: 16.0, left: 8.0, right: 8.0),
child: Text('Paste your external dependencies code below'),
),
MainScreen(),
Expand Down
100 changes: 73 additions & 27 deletions lib/screens/main_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:pubspec_to_md/utils/conversion_logic.dart';
import 'package:pubspec_to_md/utils/enums.dart';

var headerTextStyle = TextStyle(fontSize: 19, fontWeight: FontWeight.w800);

class MainScreen extends StatefulWidget {
@override
Expand Down Expand Up @@ -32,7 +35,6 @@ class _MainScreenState extends State<MainScreen> {
void dispose() {
codeEditController.dispose();
previewTextController.dispose();
print('DISPOSE');
super.dispose();
}

Expand Down Expand Up @@ -87,7 +89,10 @@ class _PreviewBoxWidgetState extends State<PreviewBoxWidget> {
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Text('Preview'),
Text(
'Preview',
style: headerTextStyle,
),
SizedBox(height: 20),
TextField(
maxLines: null,
Expand All @@ -97,24 +102,20 @@ class _PreviewBoxWidgetState extends State<PreviewBoxWidget> {
border: OutlineInputBorder(),
hintText: 'Formatted will show here\n\n'),
),
SizedBox(
height: 15,
),
CupertinoSlidingSegmentedControl(
children: <int, Widget>{
0: Text('Raw'),
1: Text('Rendered'),
},
groupValue: currentSegment,
onValueChanged: (newValue) {
setState(() {
currentSegment = newValue;
print('newValue is $newValue');
});
}),
SizedBox(
height: 10,
),
SizedBox(height: 15),
// CupertinoSlidingSegmentedControl(
// children: <int, Widget>{
// 0: Text('Raw'),
// 1: Text('Rendered'),
// },
// groupValue: currentSegment,
// onValueChanged: (newValue) {
// setState(() {
// currentSegment = newValue;
// print('newValue is $newValue');
// });
// }),
// SizedBox(height: 10),
CupertinoButton.filled(
disabledColor: CupertinoColors.systemGrey3,
child: Text(
Expand Down Expand Up @@ -157,6 +158,8 @@ class CodeBoxWidget extends StatefulWidget {
}

class _CodeBoxWidgetState extends State<CodeBoxWidget> {
int currentFormatTypeSegment = 0;
int currentVersionSegment = 0;
bool isTextEmpty;

void initState() {
Expand All @@ -170,7 +173,10 @@ class _CodeBoxWidgetState extends State<CodeBoxWidget> {
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Text('Code'),
Text(
'Code',
style: headerTextStyle,
),
SizedBox(height: 20),
//https://www.developerlibs.com/2019/04/flutter-important-aspects-properties-textfield.html
TextField(
Expand All @@ -189,9 +195,35 @@ class _CodeBoxWidgetState extends State<CodeBoxWidget> {
});
},
),
SizedBox(
height: 15,
),
SizedBox(height: 15),
CupertinoSlidingSegmentedControl(
children: <int, Widget>{
FormatType.url.index: Text('URL'),
FormatType.name.index: Text('Name hyperlink'),
// FormatType.simple.index: Text('Simple'),
// FormatType.table.index: Text('Table'),
},
groupValue: currentFormatTypeSegment,
onValueChanged: (newValue) {
setState(() {
currentFormatTypeSegment = newValue;
print('newValue is ${FormatType.values[newValue]}');
});
}),
SizedBox(height: 15),
CupertinoSegmentedControl(
children: <int, Widget>{
0: Text(' Without version '),
1: Text(' With version '),
},
groupValue: currentVersionSegment,
onValueChanged: (newValue) {
setState(() {
currentVersionSegment = newValue;
print('newValue is $newValue');
});
}),
SizedBox(height: 15),
CupertinoButton.filled(
disabledColor: CupertinoColors.systemGrey3,
child: Text(
Expand All @@ -202,7 +234,10 @@ class _CodeBoxWidgetState extends State<CodeBoxWidget> {
? () {
try {
widget.previewTextController.text = widget.convert
.convertFormattedMd(widget.codeEditController.text);
.convertFormattedMd(
widget.codeEditController.text,
FormatType.values[currentFormatTypeSegment],
currentVersionSegment);
} on RangeError catch (e) {
print('Error caught: $e');
Fluttertoast.showToast(
Expand All @@ -216,8 +251,19 @@ class _CodeBoxWidgetState extends State<CodeBoxWidget> {
}
}
: null,
)
//TODO: Add clear button
),
CupertinoButton(
child: Text('Clear all'),
onPressed: !isTextEmpty
? () {
Fluttertoast.showToast(msg: 'Cleared');
setState(() {
widget.codeEditController.clear();
widget.previewTextController.clear();
isTextEmpty = true;
});
}
: null),
],
),
);
Expand Down
37 changes: 31 additions & 6 deletions lib/utils/conversion_logic.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import 'package:pubspec_to_md/utils/enums.dart';

class Conversion {
// readme generator
var baseUrl = 'https://pub.dev/packages/';

String convertFormattedMd(String input) {
String convertFormattedMd(
String input, FormatType formatType, int withVersion) {
var trimmedUrl = input.trim(); //remove any unwanted lines
var splittedUrl = trimmedUrl.split('\n'); //transform into a list
var output = '';

bool isWithVersion = withVersion == 0 ? false : true;

//parallel array
List packageName = [];
List packageVersion = [];
Expand All @@ -17,11 +22,31 @@ class Conversion {
packageName.add(item.substring(0, idx).trim());
packageVersion.add(item.substring(idx + 1).trim());
}
for (var item in packageName) {
var fullUrl = baseUrl + item;
output = output + fullUrl + '\n';
}

return output.trim(); //trim to remove extra line
switch (formatType) {
case FormatType.url:
for (int i = 0; i < packageName.length; i++) {
var fullUrl = baseUrl + packageName[i];
output = output + fullUrl;
output = isWithVersion
? output + ' **(' + packageVersion[i] + ')**' + '\n'
: output + '\n';
}
return output.trim(); //trim to remove extra line
break;
case FormatType.name:
for (int i = 0; i < packageName.length; i++) {
var fullUrl = baseUrl + packageName[i];

output = output + '[' + packageName[i] + ']' + '(' + fullUrl + ')';
output = isWithVersion
? output + ' (' + packageVersion[i] + ')' + '\n'
: output + '\n';
}
return output.trim();
break;
default:
return 'oops';
}
}
}
1 change: 1 addition & 0 deletions lib/utils/enums.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enum FormatType { url, name, simple, table }
14 changes: 0 additions & 14 deletions pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.0"
async:
dependency: transitive
description:
Expand Down Expand Up @@ -93,13 +86,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3-nullsafety.3"
markdown:
dependency: "direct main"
description:
name: markdown
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
matcher:
dependency: transitive
description:
Expand Down
1 change: 0 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ dependencies:
cupertino_icons: ^1.0.1
url_launcher: ^5.7.10
fluttertoast: ^7.1.6
markdown: ^3.0.0

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit aa33e00

Please sign in to comment.