Skip to content

Commit

Permalink
formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
nanthakumaran-s committed Apr 27, 2021
1 parent bfe1ef7 commit b214c9f
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 75 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
@@ -1,4 +1,7 @@
## [0.0.1 + 1] 27.04.2021

- Formatted and optimized the code

## [0.0.1] - 27.04.2021

- Initial release to the public.

3 changes: 1 addition & 2 deletions example/lib/main.dart
Expand Up @@ -7,7 +7,6 @@ void main() {
}

class MyApp extends StatelessWidget {

@override
Widget build(BuildContext context) {
return MaterialApp(
Expand Down Expand Up @@ -72,7 +71,7 @@ class _MyHomePageState extends State<MyHomePage> {
padding: 20,
fontWeight: 700,
onClick: () {
getcb("Heading 2 Nanthakumaran is a goat");
getcb("Heading 2");
},
),
H3(
Expand Down
1 change: 0 additions & 1 deletion lib/src/Table.dart
Expand Up @@ -2,7 +2,6 @@ import 'package:flutter/material.dart';

/// HTMLTABLE widget corresponds in creating table tag.
class HTMLTable extends StatelessWidget {

/// data of column of the table.
final List columns;

Expand Down
25 changes: 12 additions & 13 deletions lib/src/text/H2.dart
Expand Up @@ -3,7 +3,7 @@ import 'package:html_widgets/src/text/HeadingBuilder.dart';

/// Heading 2 widget corresponds in creating H2 tag like text.
class H2 extends StatelessWidget {
/// Text to be displayed.
/// Text to be displayed.
final String text;

/// Color of the text.
Expand Down Expand Up @@ -33,18 +33,17 @@ class H2 extends StatelessWidget {
/// On Click function that can be executed on tapping the text.
final Function() onClick;

H2({
this.color,
this.bgColor,
this.margin,
this.padding,
this.onClick,
this.fontSize,
this.fontWeight,
@required this.text,
this.isLoading = false,
this.textAlign
});
H2(
{this.color,
this.bgColor,
this.margin,
this.padding,
this.onClick,
this.fontSize,
this.fontWeight,
@required this.text,
this.isLoading = false,
this.textAlign});

@override
Widget build(BuildContext context) {
Expand Down
5 changes: 2 additions & 3 deletions lib/src/text/H3.dart
Expand Up @@ -3,7 +3,7 @@ import 'package:html_widgets/src/text/HeadingBuilder.dart';

/// Heading 3 widget corresponds in creating H3 tag like text.
class H3 extends StatelessWidget {
/// Text to be displayed.
/// Text to be displayed.
final String text;

/// Color of the text.
Expand Down Expand Up @@ -33,7 +33,6 @@ class H3 extends StatelessWidget {
/// On Click function that can be executed on tapping the text.
final Function() onClick;


H3({
this.color,
this.bgColor,
Expand All @@ -46,7 +45,7 @@ class H3 extends StatelessWidget {
this.textAlign,
@required this.text,
});

@override
Widget build(BuildContext context) {
return HeadingBuilder(
Expand Down
5 changes: 2 additions & 3 deletions lib/src/text/H4.dart
Expand Up @@ -3,7 +3,7 @@ import 'package:html_widgets/src/text/HeadingBuilder.dart';

/// Heading 4 widget corresponds in creating H4 tag like text.
class H4 extends StatelessWidget {
/// Text to be displayed.
/// Text to be displayed.
final String text;

/// Color of the text.
Expand Down Expand Up @@ -33,7 +33,6 @@ class H4 extends StatelessWidget {
/// On Click function that can be executed on tapping the text.
final Function() onClick;


H4({
this.color,
this.bgColor,
Expand All @@ -46,7 +45,7 @@ class H4 extends StatelessWidget {
this.textAlign,
@required this.text,
});

@override
Widget build(BuildContext context) {
return HeadingBuilder(
Expand Down
5 changes: 2 additions & 3 deletions lib/src/text/H5.dart
Expand Up @@ -3,7 +3,7 @@ import 'package:html_widgets/src/text/HeadingBuilder.dart';

/// Heading 5 widget corresponds in creating H5 tag like text.
class H5 extends StatelessWidget {
/// Text to be displayed.
/// Text to be displayed.
final String text;

/// Color of the text.
Expand Down Expand Up @@ -33,7 +33,6 @@ class H5 extends StatelessWidget {
/// On Click function that can be executed on tapping the text.
final Function() onClick;


H5({
this.color,
this.bgColor,
Expand All @@ -46,7 +45,7 @@ class H5 extends StatelessWidget {
this.textAlign,
@required this.text,
});

@override
Widget build(BuildContext context) {
return HeadingBuilder(
Expand Down
5 changes: 2 additions & 3 deletions lib/src/text/H6.dart
Expand Up @@ -3,7 +3,7 @@ import 'package:html_widgets/src/text/HeadingBuilder.dart';

/// Heading 6 widget corresponds in creating H6 tag like text.
class H6 extends StatelessWidget {
/// Text to be displayed.
/// Text to be displayed.
final String text;

/// Color of the text.
Expand Down Expand Up @@ -33,7 +33,6 @@ class H6 extends StatelessWidget {
/// On Click function that can be executed on tapping the text.
final Function() onClick;


H6({
this.color,
this.bgColor,
Expand All @@ -46,7 +45,7 @@ class H6 extends StatelessWidget {
this.textAlign,
@required this.text,
});

@override
Widget build(BuildContext context) {
return HeadingBuilder(
Expand Down
82 changes: 40 additions & 42 deletions lib/src/text/HeadingBuilder.dart
Expand Up @@ -2,11 +2,10 @@ import 'package:flutter/material.dart';
import 'package:shimmer/shimmer.dart';
import 'dart:math';


/// HeadingBuilder widget corresponds in creating Heading tag like text.
// ignore: must_be_immutable
class HeadingBuilder extends StatelessWidget {
/// Text to be displayed.
/// Text to be displayed.
final String text;

/// Color of the text.
Expand All @@ -15,15 +14,15 @@ class HeadingBuilder extends StatelessWidget {
/// Background Color of the text.
final Color bgColor;

/// Font Size of the text.
/// Font Size of the text.
final num fontSize;

/// Default value of 32.0 will be passed if fontSize not provided.
final num defaultFontSize;

/// Font Weight of the text.
final num fontWeight;

/// Default value of 600 will be passed if fontWeight not provided.
final num defaultFontWeight;

Expand All @@ -42,10 +41,6 @@ class HeadingBuilder extends StatelessWidget {
/// On Click function that can be executed on tapping the text.
final Function() callBack;





HeadingBuilder({
this.color,
this.bgColor,
Expand Down Expand Up @@ -75,61 +70,64 @@ class HeadingBuilder extends StatelessWidget {

final Map _textAlign = {
'center': TextAlign.center,
'left' :TextAlign.left,
'right' :TextAlign.right,
'start' :TextAlign.start,
'left': TextAlign.left,
'right': TextAlign.right,
'start': TextAlign.start,
'end': TextAlign.end,
'justify':TextAlign.justify,
'justify': TextAlign.justify,
};

double density = WidgetsBinding.instance.window.devicePixelRatio;

double randomWidth({double min = 0.30, double max = 0.80}){
return Random().nextDouble() * (max - min + 1) + min ;
double randomWidth({double min = 0.30, double max = 0.80}) {
return Random().nextDouble() * (max - min + 1) + min;
}

@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.all(margin != null ? margin.toDouble() : 5.0),
child:isLoading ? Shimmer.fromColors(
child: isLoading
? Shimmer.fromColors(
highlightColor: Colors.white,
baseColor: Colors.grey[300],
period: Duration(milliseconds: 800),
child: Container(
height: fontSize != null ? fontSize.toDouble() : defaultFontSize,
height:
fontSize != null ? fontSize.toDouble() : defaultFontSize,
width: MediaQuery.of(context).size.width * randomWidth(),
decoration: BoxDecoration(
color: Colors.grey,
borderRadius: BorderRadius.circular(20)
),
color: Colors.grey,
borderRadius: BorderRadius.circular(20)),
),
)
: Container(
width: MediaQuery.of(context).size.width * 1.0,
decoration: BoxDecoration(
color: bgColor,
),
child: Padding(
padding: EdgeInsets.all(padding != null ? padding.toDouble() : 0.0),
child: GestureDetector(
onTap: callBack,
child: Text(
text,
style: TextStyle(
color: color,
fontSize:
fontSize != null ? fontSize.toDouble() : defaultFontSize,
fontWeight: _fontWeight[fontWeight != null
? ((fontWeight ~/ 100) - 1)
: defaultFontWeight],
letterSpacing: 1.5,
: Container(
width: MediaQuery.of(context).size.width * 1.0,
decoration: BoxDecoration(
color: bgColor,
),
child: Padding(
padding:
EdgeInsets.all(padding != null ? padding.toDouble() : 0.0),
child: GestureDetector(
onTap: callBack,
child: Text(
text,
style: TextStyle(
color: color,
fontSize: fontSize != null
? fontSize.toDouble()
: defaultFontSize,
fontWeight: _fontWeight[fontWeight != null
? ((fontWeight ~/ 100) - 1)
: defaultFontWeight],
letterSpacing: 1.5,
),
textAlign: _textAlign[textAlign],
),
),
),
textAlign: _textAlign[textAlign],
),
),
),
),
);
}
}
5 changes: 2 additions & 3 deletions lib/src/text/P.dart
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:html_widgets/src/text/HeadingBuilder.dart';

class P extends StatelessWidget {
/// Text to be displayed.
/// Text to be displayed.
final String text;

/// Color of the text.
Expand Down Expand Up @@ -32,7 +32,6 @@ class P extends StatelessWidget {
/// On Click function that can be executed on tapping the text.
final Function() onClick;


P({
this.color,
this.bgColor,
Expand All @@ -45,7 +44,7 @@ class P extends StatelessWidget {
this.textAlign,
@required this.text,
});

@override
Widget build(BuildContext context) {
return HeadingBuilder(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
@@ -1,5 +1,5 @@
name: html_widgets
description: A Flutter Widget Approach for using HTML tags in your Apps.
description: A Flutter Widget Approach for using HTML tags & CSS styles in your upcoming Apps.
version: 0.0.1
homepage: https://github.com/XenonLabz/html_widgets

Expand Down

0 comments on commit b214c9f

Please sign in to comment.