Skip to content

Commit 11cdb31

Browse files
tmaxxddxJac0b
andauthored
Release/0.2.0 (#5)
* Updated highlights for Android * Updated highlights for ios * Fixed param name error in swift and code style * Updated dependencies * Migrated package to snipme.dev * Updated changelog and version * Corrected dependencies version for pub.dev * Added equals, hashcode and unit test for base models * Removed dummy test * Improved readme * fix: add namespace to build.gradle --------- Co-authored-by: xJac0b <85969059+xJac0b@users.noreply.github.com>
1 parent d097e3c commit 11cdb31

46 files changed

Lines changed: 8141 additions & 11479 deletions

File tree

Some content is hidden

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

.fvm/flutter_sdk

Lines changed: 0 additions & 1 deletion
This file was deleted.

.fvm/fvm_config.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ migrate_working_dir/
2727
**/doc/api/
2828
.dart_tool/
2929
.packages
30-
build/
30+
build/

.pubignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.DS_Store
2+
.idea
3+
.pub/
4+
.dart_tool/
5+
.settings/
6+
build/
7+
packages
8+
.packages
9+
pubspec.lock
10+
package-lock.json

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
## 0.2.0
2+
3+
### Added
4+
- pub.dev setup
5+
- unit tests
6+
7+
### Changed
8+
- Flutter sdk version to 3.24.0
9+
- dependencies to newer
10+
- Highlights library to 1.0.0
11+
- `getHighlights` to `getHighlightsAsync` in plugins
12+
13+
## 0.1.0
14+
15+
### Added
16+
- emphasis (bold) phrase parts
17+
- bold option on selected text in example
18+
119
## 0.0.1
220

321
### Added

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,35 @@
11
# highlights_plugin
22

3-
Dart implementation of highlights KMM engine:
3+
Dart implementation of highlights KMP engine:
44
https://github.com/SnipMeDev/Highlights
55

66
<img width="250" src="https://github.com/user-attachments/assets/e28639c1-e1a5-47d2-9a39-d1a3f2973651"/>
77
<img width="250" src="https://github.com/user-attachments/assets/2a0239b5-bacd-4173-9d8b-697ef37fba05"/>
88

9+
## Installation
10+
```sh
11+
flutter pub add highlights_plugin
12+
```
13+
14+
## Usage
15+
```dart
16+
final plugin = HighlightsPlugin(debug: true);
17+
18+
// ['kotlin', 'dart', 'swift', 'php', 'java', ...]
19+
final languages = await plugin.getLanguages();
20+
// ['monokai', 'darcula', 'notepad', ...]
21+
final themes = await plugin.getThemes();
22+
// Bold Hello
23+
final emphasis = PhraseLocation(start: 3, length: 8);
24+
// List with ColorHighlight or BoldHighlight
25+
final result = await plugin.getHighlights(
26+
'// Hello, World!',
27+
languages.first,
28+
themes.first,
29+
[emphasis],
30+
);
31+
```
32+
933
## Features
1034
- 17 supported languages (Kotlin, Dart, Swift, PHP, etc)
1135
- Light / dark mode

android/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
group 'pl.tkadziolka.highlights_plugin'
1+
group 'dev.snipme.highlights_plugin'
22
version '1.0-SNAPSHOT'
33

44
buildscript {
@@ -26,6 +26,7 @@ apply plugin: 'kotlin-android'
2626

2727
android {
2828
compileSdkVersion 31
29+
namespace 'dev.snipme.highlights_plugin'
2930

3031
compileOptions {
3132
sourceCompatibility JavaVersion.VERSION_1_8
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="pl.tkadziolka.highlights_plugin">
3-
</manifest>
1+
<manifest package="dev.snipme.highlights_plugin" />

android/src/main/kotlin/pl/tkadziolka/highlights_plugin/HighlightsPlugin.kt renamed to android/src/main/kotlin/dev/snipme/highlights_plugin/HighlightsPlugin.kt

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package pl.tkadziolka.highlights_plugin
1+
package dev.snipme.highlights_plugin
22

33
import dev.snipme.highlights.DefaultHighlightsResultListener
44
import dev.snipme.highlights.Highlights
@@ -15,12 +15,7 @@ import io.flutter.plugin.common.MethodChannel
1515
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
1616
import io.flutter.plugin.common.MethodChannel.Result
1717

18-
/** HighlightsPlugin */
1918
class HighlightsPlugin : FlutterPlugin, MethodCallHandler {
20-
/// The MethodChannel that will the communication between Flutter and native Android
21-
///
22-
/// This local reference serves to register the plugin with the Flutter Engine and unregister it
23-
/// when the Flutter Engine is detached from the Activity
2419
private lateinit var channel: MethodChannel
2520
private lateinit var highlights: Highlights
2621
private var useDarkMode = false
@@ -35,8 +30,6 @@ class HighlightsPlugin : FlutterPlugin, MethodCallHandler {
3530
channel.setMethodCallHandler(null)
3631
}
3732

38-
// TODO Implement EventChannel
39-
4033
override fun onMethodCall(call: MethodCall, result: Result) {
4134
when (call.method) {
4235
"getHighlights" -> {
@@ -49,8 +42,8 @@ class HighlightsPlugin : FlutterPlugin, MethodCallHandler {
4942

5043
highlights.getHighlightsAsync(
5144
object: DefaultHighlightsResultListener() {
52-
override fun onComplete(highlightList: List<CodeHighlight>) {
53-
result.success(highlightList.toJson())
45+
override fun onSuccess(highlights: List<CodeHighlight>) {
46+
result.success(highlights.toJson())
5447
}
5548

5649
override fun onCancel() {
@@ -81,11 +74,7 @@ class HighlightsPlugin : FlutterPlugin, MethodCallHandler {
8174
theme: SyntaxTheme?,
8275
emphasisLocations: List<PhraseLocation>?,
8376
) {
84-
println("Update instance $code $language $theme $emphasisLocations")
85-
8677
if (highlights.getLanguage() == language && highlights.getTheme() == theme) {
87-
println("Only change code $code")
88-
println("Only change emphasis $emphasisLocations")
8978
code?.let { highlights.setCode(it) }
9079
emphasisLocations?.let { locations -> locations.forEach { highlights.setEmphasis(it) } }
9180
} else {

example/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ android {
4444

4545
defaultConfig {
4646
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
47-
applicationId "pl.tkadziolka.highlights_plugin_example"
47+
applicationId "dev.snipme.highlights_plugin_example"
4848
// You can update the following values to match your application needs.
4949
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
5050
minSdkVersion flutter.minSdkVersion

0 commit comments

Comments
 (0)