Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
4b048c0
Merge pull request #1 from jonataslaw/master
unger1984 Nov 29, 2020
a73f13b
Null-safety prepare
unger1984 Nov 29, 2020
5af0389
fix Changelog && readme
unger1984 Nov 29, 2020
f113525
update versions
unger1984 Dec 10, 2020
b920ebf
nullsafety
unger1984 Mar 2, 2021
40f09c1
nullsafety
unger1984 Mar 2, 2021
049eb9e
nullsafety
unger1984 Mar 2, 2021
68c2a4b
'nullOk'. nullOk: nullOk - flutter 2.0
epynic Mar 4, 2021
0bae789
Update readmore.dart
epynic Mar 5, 2021
ce0d078
Merge pull request #15 from epynic/patch-1
jonataslaw Mar 31, 2021
01a888b
Merge branch 'master' into master
jonataslaw Mar 31, 2021
a5ae6de
Merge pull request #9 from unger1984/master
jonataslaw Mar 31, 2021
75ffea9
update to 2.0
jonataslaw Mar 31, 2021
e52e402
Supported RTL texts
amereii May 1, 2021
13a1ee6
Merge pull request #17 from RooyeKhat-Media/RTL
jonataslaw May 31, 2021
f587f6b
update to 2.1.0
jonataslaw Jun 1, 2021
07e395f
read less showing "...read less" fix!
govindmaheshwari2 Jun 1, 2021
9d45eca
Merge pull request #19 from govindmaheshwari2/patch-1
jonataslaw Jun 10, 2021
48ec226
Added pretext and posttext with their own styles
Siqlain-Hanif Sep 8, 2021
562f8b5
Added pretext and posttext with their own styles
Siqlain-Hanif Sep 8, 2021
98f9577
Added pretext and posttext with data and style
Siqlain-Hanif Sep 8, 2021
0daf276
Update README.md
olisaemekaejiofor Jun 9, 2022
6713460
Merge pull request #22 from Siqlain-Hanif/dev/siq/pretext
jonataslaw Jun 20, 2022
f7cf0fe
Merge pull request #31 from olisaemekaejiofor/patch-1
jonataslaw Jun 20, 2022
9234c53
update to 2.2.0
jonataslaw Jun 20, 2022
2b458cc
Merge pull request #32 from jonataslaw/2.2.0
jonataslaw Jun 20, 2022
e475c79
Url links highlighting added.
webdastur Oct 19, 2022
4b43b2d
Url links highlighting added.
webdastur Oct 19, 2022
e95d008
Merge pull request #40 from webdastur/master
jonataslaw Oct 27, 2022
c6bc6ff
Upgrade to Flutter 3
maRci002 Mar 26, 2024
ee71378
Allow to control / listen to isCollapsed state
maRci002 Mar 26, 2024
1eeabc4
Add Custom Styling and Interactions for Mentions, Hashtags, and URLs
maRci002 Mar 27, 2024
f62402c
Update code to comply with strict analyzer
maRci002 Mar 27, 2024
23aff66
update interactive example
maRci002 Mar 27, 2024
caf24ee
Example use snack bar instead of print
maRci002 Mar 27, 2024
8cd1b67
Merge pull request #54 from maRci002/master
jonataslaw Mar 27, 2024
e5d8ce9
Update CHANGELOG to 3.0.0
maRci002 Mar 27, 2024
d689aba
merge #35
jonataslaw Mar 27, 2024
bbb7d0f
merge #47
jonataslaw Mar 27, 2024
8db21cb
Merge pull request #55 from maRci002/master
jonataslaw Mar 27, 2024
5ca1aad
Merge pull request #56 from jonataslaw/merge-old
jonataslaw Mar 27, 2024
d1a88f3
add preview
jonataslaw Mar 27, 2024
5927e68
Merge pull request #57 from jonataslaw/fix-preview
jonataslaw Mar 27, 2024
a341ea5
release 3.0.0
jonataslaw Mar 27, 2024
d6c6c5f
Merge pull request #58 from jonataslaw/3.0.0
jonataslaw Mar 27, 2024
3497ebf
Add ReadMoreText.rich constructor
maRci002 Mar 30, 2024
ae854a4
apply colorClickableText
maRci002 Mar 30, 2024
68b749f
Merge pull request #59 from maRci002/feat/rich_data
jonataslaw Mar 31, 2024
f1cf64d
Chores before the 3.1.0 release
maRci002 Mar 31, 2024
60c2e0a
Merge pull request #60 from maRci002/chore/3.1.0
jonataslaw Apr 1, 2024
e1d8fb9
add screenshots
maRci002 Apr 1, 2024
d86aaed
Merge pull request #61 from maRci002/chore/3.1.0
jonataslaw Apr 5, 2024
36a3e6b
fix #39
takinok Apr 6, 2024
29f6a81
Change example and additional fix for #39
takinok Apr 9, 2024
0528bdd
Merge pull request #62 from takinok/master
jonataslaw Apr 13, 2024
7541543
Fix excess lines in TrimMode.Line with correct emoji handling
maRci002 Apr 13, 2024
a29db31
Merge pull request #64 from maRci002/fix-emoji-trim
jonataslaw Apr 14, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
.pub/
/build/
build/
pubspec.lock

# Web related
lib/generated_plugin_registrant.dart
Expand Down
42 changes: 39 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,43 @@
## [1.0.1]
- Remove debug statements
## [3.1.0]

Contributed by [@maRci002](https://github.com/maRci002) - see PR [#59](https://github.com/jonataslaw/readmore/pull/59).

- Added `ReadMoreText.rich` constructor for rich text formatting and interactivity, enhancing text presentation with customizable styles and interactive elements.

## [3.0.0]

Contributed by [@maRci002](https://github.com/maRci002) - see PR [#54](https://github.com/jonataslaw/readmore/pull/54).

**Breaking Changes**:

- Upgraded to **Dart 3.0.0**
- **`textScaleFactor`** replaced with **`textScaler`**
- Removed **`callback`** in favor of the **`isCollapsed`** controller

**Features**:

- Introduced **`Annotation`** functionality for custom styling and interactions with text patterns like hashtags, URLs, and mentions, enhancing text interactivity and usability.

- This version also has minor contributions from the following users: (@zeeshanhussain), (@sm2017), (@andreaselia), (@amereii), (@govindmaheshwari2),(@olisaemekaejiofor), (@epynic), (@webdastur), (@Siqlain-Hanif), (@unger1984),

## [2.2.0]

- Update to Flutter 3.

## [2.1.0]

- add RTL support

## [2.0.0]

- nullsafety

## [1.0.1]

- Remove debug statements
- Add delimiter span && style for trimExpandedText & trimCollapsedText
- Fix linkSize on ListView

## [1.0.0]
## [1.0.0]

- initial release
86 changes: 78 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,100 @@
# readmore

A Flutter plugin than allow expand and collapse text.
A Flutter plugin that allows for expanding and collapsing text with the added capability to style and interact with specific patterns in the text like hashtags, URLs, and mentions using the `Annotation` feature.

![](read-more-text-view-flutter.gif)

## usage:
add to your pubspec
## Usage:

Add the package to your pubspec.yaml:

```yaml
readmore: ^3.0.0
```
readmore: ^1.0.0
```
and import:
```

Then, import it in your Dart code:

```dart
import 'package:readmore/readmore.dart';
```

### Basic Example

```dart
ReadMoreText(
'Flutter is Google’s mobile UI open source framework to build high-quality native (super fast) interfaces for iOS and Android apps with the unified codebase.',
trimMode: TrimMode.Line,
trimLines: 2,
colorClickableText: Colors.pink,
trimMode: TrimMode.Line,
trimCollapsedText: 'Show more',
trimExpandedText: 'Show less',
moreStyle: TextStyle(fontSize: 14, fontWeight: FontWeight.bold),
);
```

### Rich Text Example

With the `ReadMoreText.rich` constructor, you can create text with rich formatting, including different colors, decorations, letter spacing, and interactive elements within a single widget.

```dart
ReadMoreText.rich(
TextSpan(
style: const TextStyle(color: Colors.black),
children: [
const TextSpan(text: 'Rich '),
const TextSpan(
text: 'Text',
style: TextStyle(
color: Colors.blue,
decoration: TextDecoration.underline,
letterSpacing: 5,
recognizer: TapGestureRecognizer()..onTap = () {
// Handle tap
},
),
),
],
),
trimMode: TrimMode.Line,
trimLines: 2,
colorClickableText: Colors.pink,
trimCollapsedText: '...Read more',
trimExpandedText: ' Less',
);
```

### Using Annotations

The `Annotation` feature enhances the interactivity and functionality of the text content. You can define custom styles and interactions for patterns like hashtags, URLs, and mentions.

```dart
ReadMoreText(
'This is a sample text with a #hashtag, a mention <@123>, and a URL: https://example.com.',
trimMode: TrimMode.Line,
trimLines: 2,
colorClickableText: Colors.pink,
annotations: [
Annotation(
regExp: RegExp(r'#([a-zA-Z0-9_]+)'),
spanBuilder: ({required String text, required TextStyle textStyle}) => TextSpan(
text: text,
style: textStyle.copyWith(color: Colors.blue),
),
),
Annotation(
regExp: RegExp(r'<@(\d+)>'),
spanBuilder: ({required String text, required TextStyle textStyle}) => TextSpan(
text: 'User123',
style: textStyle.copyWith(color: Colors.green),
recognizer: TapGestureRecognizer()..onTap = () {
// Handle tap, e.g., navigate to a user profile
},
),
),
// Additional annotations for URLs...
],
moreStyle: TextStyle(fontSize: 14, fontWeight: FontWeight.bold),
);
```

_Note: This feature is not available with the `ReadMoreText.rich` constructor, as `TextSpan` gives you total control over styling and adding interactions to parts of the text._
47 changes: 47 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/
pubspec.lock

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
10 changes: 10 additions & 0 deletions example/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: f4abaa0735eba4dfd8f33f73363911d63931fe03
channel: stable

project_type: app
16 changes: 16 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# example

A new Flutter project.

## Getting Started

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)

For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
11 changes: 11 additions & 0 deletions example/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java

# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
59 changes: 59 additions & 0 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 31

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.example"
minSdkVersion flutter.minSdkVersion
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}

flutter {
source '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
7 changes: 7 additions & 0 deletions example/android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.example">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
41 changes: 41 additions & 0 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.example">
<application
android:label="example"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.example.example

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="?android:colorBackground" />

<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>
12 changes: 12 additions & 0 deletions example/android/app/src/main/res/drawable/launch_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />

<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading