Skip to content

Commit 0b1e5d5

Browse files
committed
initial commit
0 parents  commit 0b1e5d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+3266
-0
lines changed

Diff for: .gitignore

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
12+
# IntelliJ related
13+
*.iml
14+
*.ipr
15+
*.iws
16+
.idea/
17+
18+
# The .vscode folder contains launch configuration and tasks you configure in
19+
# VS Code which you may wish to be included in version control, so this line
20+
# is commented out by default.
21+
#.vscode/
22+
23+
# Flutter/Dart/Pub related
24+
**/doc/api/
25+
.dart_tool/
26+
.flutter-plugins
27+
.flutter-plugins-dependencies
28+
.packages
29+
.pub-cache/
30+
.pub/
31+
build/
32+
33+
# Android related
34+
**/android/**/gradle-wrapper.jar
35+
**/android/.gradle
36+
**/android/captures/
37+
**/android/gradlew
38+
**/android/gradlew.bat
39+
**/android/local.properties
40+
**/android/**/GeneratedPluginRegistrant.java
41+
42+
# iOS/XCode related
43+
**/ios/**/*.mode1v3
44+
**/ios/**/*.mode2v3
45+
**/ios/**/*.moved-aside
46+
**/ios/**/*.pbxuser
47+
**/ios/**/*.perspectivev3
48+
**/ios/**/*sync/
49+
**/ios/**/.sconsign.dblite
50+
**/ios/**/.tags*
51+
**/ios/**/.vagrant/
52+
**/ios/**/DerivedData/
53+
**/ios/**/Icon?
54+
**/ios/**/Pods/
55+
**/ios/**/.symlinks/
56+
**/ios/**/profile
57+
**/ios/**/xcuserdata
58+
**/ios/.generated/
59+
**/ios/Flutter/App.framework
60+
**/ios/Flutter/Flutter.framework
61+
**/ios/Flutter/Flutter.podspec
62+
**/ios/Flutter/Generated.xcconfig
63+
**/ios/Flutter/app.flx
64+
**/ios/Flutter/app.zip
65+
**/ios/Flutter/flutter_assets/
66+
**/ios/Flutter/flutter_export_environment.sh
67+
**/ios/ServiceDefinitions.json
68+
**/ios/Runner/GeneratedPluginRegistrant.*
69+
70+
# Exceptions to above rules.
71+
!**/ios/**/default.mode1v3
72+
!**/ios/**/default.mode2v3
73+
!**/ios/**/default.pbxuser
74+
!**/ios/**/default.perspectivev3
75+
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

Diff for: .metadata

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: f139b11009aeb8ed2a3a3aa8b0066e482709dde3
8+
channel: stable
9+
10+
project_type: package

Diff for: CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## [1.0.0] - April 24th, 2020
2+
3+
* Initial release of the forked project.
4+
* Added support for a few more html tags
5+
* Added support for a few more css properties
6+
* Added support for global style overriding

Diff for: LICENSE

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Copyright 2020 Ali Ahamed Thowfeek
2+
Copyright 2019 Ashraff Hathibelagal
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.

Diff for: README.md

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# Simple Html CSS
2+
3+
This is a fork of [css_text_for_flutter](https://github.com/hathibelagal-dev/css_text_for_flutter)
4+
5+
This package makes it easy for you to convert HTML and CSS text content
6+
into `RichText` widgets. It supports most CSS properties that are
7+
relevant to **text** content, except for a few. Also gives the ability to
8+
override the styles of the content passed in.
9+
10+
>NOTE: This is not an alternative to webview packages. This package only deals with text.
11+
12+
Here's a sample HTML content with inline CSS styles:
13+
14+
```html
15+
<body>
16+
<h1 style='color: white; font-size:50px; font-style:italic; background-color: rgb(0,122,255); font-weight:100;)'> Hello word! </h1>
17+
<h1 style=''>Convert your <span style='color:lightseagreen;'>HTML</span> and <span style='color:dodgerblue'>CSS</span> easily into RichText</h1>
18+
<p>Lorem ipsum dolor sit, consectetur adipiscing elit. Pellentesque in leo id dui bibendum fringilla in et arcu. In vehicula vel est sed mattis.</p>
19+
<p><a href="https://google.com">Need more? click this link</a></p>
20+
<p>We all spell <span style='color:crimson; text-decoration: underline wavy;'>recieve</span> wrong.<br />Some times we delete <del>stuff</del></p>
21+
<div style='font-size:17px'>We write things that are <span style='font-size:1.5em;'>Big,</span> <b>bold</b>&nbsp; or <span style='color:brown'>colorful</span></div>
22+
<p style='font-family:times;'>Some different FONT with <span style='background-color:lightcyan;'>this part highlighted</span></p>
23+
<div style='line-height:2; font-size:17px;'><b style='color: rgb(0,122,255); font-weight:500;'>Finally some line heights.</b> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque in leo id dui bibendum fringilla in et arcu. In vehicula vel est sed mattis. Duis varius, sem non mattis.</div>
24+
</body>
25+
```
26+
27+
This package can automatically convert all the HTML content above into
28+
`TextSpan` objects or a `RichText` widget. Here's what the render will look like:
29+
30+
![](sample.png)
31+
32+
## Getting Started
33+
34+
Using `simple_html_css` is extremely easy. First import the library in
35+
your Dart code:
36+
37+
```
38+
import 'package:simple_html_css/simple_html_css.dart';
39+
```
40+
41+
You can then create `TextSpan` from any HTML content by calling the `HTML.toTextSpan()` method. Which you can use to create a `RichText` widget.
42+
43+
```dart
44+
String htmlContent = """
45+
<p style="font-size:1.5em;">Hello World</p>
46+
""";
47+
48+
RichText(
49+
text: HTML.toTextSpan(context, htmlContent),
50+
maxLines: 4,
51+
//...
52+
);
53+
```
54+
55+
As a shortcut, you can also use the `HTML.toRichText()` method.
56+
57+
```dart
58+
var myRichText = HTML.toRichText(context, htmlContent);
59+
60+
Container(
61+
child: myRichText,
62+
);
63+
```
64+
65+
## Handling Links
66+
67+
Your HTML content can have links. To handle them, you must use the
68+
`linksCallback` optional parameter.
69+
70+
```dart
71+
String htmlContent = """<span style="font-size:2em">
72+
Please click <a href="https://pub.dartlang.org">here</a> or
73+
<a href="https://old.reddit.com">here</a>.<br/>
74+
<br/>
75+
Go ahead! Try it.
76+
</span>""";
77+
78+
var myRichText = HTML.toRichText(context, htmlContent, linksCallback: (link) {
79+
// You can now use the url_launcher library to open the link.
80+
// Or you can handle the link in your app itself. This gives you
81+
// complete control over your links.
82+
// For now, let's just print it
83+
print(link);
84+
});
85+
```
86+
87+
## Overriding styles
88+
89+
You can override the inline styles and apply global styles for all the
90+
HTML tags in your HTML content.
91+
92+
```dart
93+
String htmlContent =
94+
"""
95+
<p>This has no font size css property, but global style will be applied</p>
96+
<a style='color: orange;'>The inline color for this is orange, but it will get overridden by global style defined below</a>
97+
""";
98+
99+
HTML.toTextSpan(
100+
context,
101+
htmlContent,
102+
overrideStyle: {
103+
"p": TextStyle(fontSize: 17.3),
104+
"a": TextStyle(color: Colors.red),
105+
// specify any tag not just the supported ones,
106+
// and apply TextStyles to them and/override them
107+
},
108+
);
109+
```
110+
111+
## Supported HTML Tags
112+
113+
Supports all tags which prints text normally like `p`, `div`, `span`, `body` etc.
114+
And the following special tags which change the text appearance
115+
* `h1 - h5`
116+
* `b` `strong`
117+
* `i` `em`
118+
* `u`
119+
* `strike` `del` `s`
120+
* `a` - anchor tags with link `callback`
121+
122+
## Supported CSS properties (text related)
123+
124+
| supported Css property | supported value(s) |
125+
|:-----------------------|:-----------------------------------------------------------------------------------------------------------------------------|
126+
| font-weight | `100 to 900`, `normal`, `medium`, `bold` |
127+
| color | css color name like: `red`, `orangered` etc. or `rgb(0, 0, 255)` or `rga(0, 0, 50, 0.5)` or Hex `#eee`/`#ff00ff`/`#ff005522` |
128+
| background-color | same as above |
129+
| font-style | `italic` and `normal` |
130+
| font-family | any valid font family. eg: `times` |
131+
| font-size | eg: `18px` or `1.5em` |
132+
| text-decoration | `underline`, `overline`, `none`, `line`, `dotted`, `dashed`, `wavy` |
133+
| line-height | any valid value. eg: `1.5` |

Diff for: example/.gitignore

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
12+
# IntelliJ related
13+
*.iml
14+
*.ipr
15+
*.iws
16+
.idea/
17+
18+
# The .vscode folder contains launch configuration and tasks you configure in
19+
# VS Code which you may wish to be included in version control, so this line
20+
# is commented out by default.
21+
#.vscode/
22+
23+
# Flutter/Dart/Pub related
24+
**/doc/api/
25+
.dart_tool/
26+
.flutter-plugins
27+
.flutter-plugins-dependencies
28+
.packages
29+
.pub-cache/
30+
.pub/
31+
/build/
32+
33+
# Web related
34+
lib/generated_plugin_registrant.dart
35+
36+
# Exceptions to above rules.
37+
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

Diff for: example/.metadata

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: f139b11009aeb8ed2a3a3aa8b0066e482709dde3
8+
channel: stable
9+
10+
project_type: app

Diff for: example/README.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# example
2+
3+
A new Flutter project.
4+
5+
## Getting Started
6+
7+
This project is a starting point for a Flutter application.
8+
9+
A few resources to get you started if this is your first Flutter project:
10+
11+
- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
12+
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
13+
14+
For help getting started with Flutter, view our
15+
[online documentation](https://flutter.dev/docs), which offers tutorials,
16+
samples, guidance on mobile development, and a full API reference.

Diff for: example/android/.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
gradle-wrapper.jar
2+
/.gradle
3+
/captures/
4+
/gradlew
5+
/gradlew.bat
6+
/local.properties
7+
GeneratedPluginRegistrant.java

Diff for: example/android/app/build.gradle

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
def localProperties = new Properties()
2+
def localPropertiesFile = rootProject.file('local.properties')
3+
if (localPropertiesFile.exists()) {
4+
localPropertiesFile.withReader('UTF-8') { reader ->
5+
localProperties.load(reader)
6+
}
7+
}
8+
9+
def flutterRoot = localProperties.getProperty('flutter.sdk')
10+
if (flutterRoot == null) {
11+
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12+
}
13+
14+
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15+
if (flutterVersionCode == null) {
16+
flutterVersionCode = '1'
17+
}
18+
19+
def flutterVersionName = localProperties.getProperty('flutter.versionName')
20+
if (flutterVersionName == null) {
21+
flutterVersionName = '1.0'
22+
}
23+
24+
apply plugin: 'com.android.application'
25+
apply plugin: 'kotlin-android'
26+
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27+
28+
android {
29+
compileSdkVersion 28
30+
31+
sourceSets {
32+
main.java.srcDirs += 'src/main/kotlin'
33+
}
34+
35+
lintOptions {
36+
disable 'InvalidPackage'
37+
}
38+
39+
defaultConfig {
40+
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
41+
applicationId "com.example.example"
42+
minSdkVersion 16
43+
targetSdkVersion 28
44+
versionCode flutterVersionCode.toInteger()
45+
versionName flutterVersionName
46+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
47+
}
48+
49+
buildTypes {
50+
release {
51+
// TODO: Add your own signing config for the release build.
52+
// Signing with the debug keys for now, so `flutter run --release` works.
53+
signingConfig signingConfigs.debug
54+
}
55+
}
56+
}
57+
58+
flutter {
59+
source '../..'
60+
}
61+
62+
dependencies {
63+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
64+
testImplementation 'junit:junit:4.12'
65+
androidTestImplementation 'androidx.test:runner:1.1.1'
66+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
67+
}

Diff for: example/android/app/src/debug/AndroidManifest.xml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.example.example">
3+
<!-- Flutter needs it to communicate with the running application
4+
to allow setting breakpoints, to provide hot reload, etc.
5+
-->
6+
<uses-permission android:name="android.permission.INTERNET"/>
7+
</manifest>

0 commit comments

Comments
 (0)