Skip to content

Commit

Permalink
Pub dev setup (#6)
Browse files Browse the repository at this point in the history
* Extended readme

* Filled CHANGELOG

* Improved example

* Update README.md
  • Loading branch information
tmaxxdd authored Nov 19, 2024
1 parent 7c35723 commit 1de0066
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"highlights_plugin","path":"/Users/tkadziolka/.pub-cache/hosted/pub.dev/highlights_plugin-0.2.0/","native_build":true,"dependencies":[]}],"android":[{"name":"highlights_plugin","path":"/Users/tkadziolka/.pub-cache/hosted/pub.dev/highlights_plugin-0.2.0/","native_build":true,"dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"highlights_plugin","dependencies":[]}],"date_created":"2024-11-18 20:15:47.325704","version":"3.24.0","swift_package_manager_enabled":false}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"highlights_plugin","path":"/Users/tkadziolka/.pub-cache/hosted/pub.dev/highlights_plugin-0.2.0/","native_build":true,"dependencies":[]}],"android":[{"name":"highlights_plugin","path":"/Users/tkadziolka/.pub-cache/hosted/pub.dev/highlights_plugin-0.2.0/","native_build":true,"dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"highlights_plugin","dependencies":[]}],"date_created":"2024-11-18 21:40:21.617016","version":"3.24.0","swift_package_manager_enabled":false}
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## 0.1.0

### Added

- highlights_plugin 0.2.0
- extensions unit tests
- CodeEditText
- CodeTextView

## 0.0.1

* TODO: Describe initial release.
### Added

- initial setup
79 changes: 79 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,85 @@

Flutter syntax highlighting widgets based on [Highlights](https://github.com/SnipMeDev/Highlights) library.

<img width="1358" alt="iShot_2024-11-18_21 55 36" src="https://github.com/user-attachments/assets/066a248b-facc-40d1-b518-03ff92c8c847">

## Installation

```dart
flutter pub add kode_view
```

## Usage

### CodeTextView

```dart
import 'package:flutter/material.dart';
import 'package:kode_view/kode_view.dart';
@override
Widget build(BuildContext context) {
final codeSnippet = "class HelloWorld {}";
return MaterialApp(
home: Scaffold(
appBar: ...,
body: CodeTextView(
code: codeSnippet,
language: "Java",
theme: "darcula",
options: ...,
),
),
);
}
```

### CodeEditText

```dart
import 'package:flutter/material.dart';
import 'package:kode_view/kode_view.dart';
class _MyAppState extends State<MyApp> {
final SyntaxHighlightingController controller =
SyntaxHighlightingController(text: codeSnippet);
@override
Widget build(BuildContext context) {
final codeSnippet = "class HelloWorld {}";
return MaterialApp(
home: Scaffold(
appBar: ...,
body: CodeEditText(
code: codeSnippet,
controller: controller,
showCursor: true,
),
),
);
}
}
```

## Features
- 17 supported languages (Kotlin, Dart, Swift, PHP, etc)
- Light / dark mode
- 6 built-in themes
- Phrase bolding (emphasis)
- Result caching and support for incremental changes

## Support

- Android ✅
- iOS ✅
- macOS 🔴 (Not yet)
- Linux 🔴 (Not yet)
- Windows 🔴 (Not yet)
- Web 🔴 (Not yet)

License 🖋️
=======

Expand Down
59 changes: 34 additions & 25 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class MyApp extends StatefulWidget {
class _MyAppState extends State<MyApp> {
final SyntaxHighlightingController controller =
SyntaxHighlightingController(text: codeSnippet);

@override
Widget build(BuildContext context) {
return MaterialApp(
Expand All @@ -26,32 +27,40 @@ class _MyAppState extends State<MyApp> {
title: const Text('Kode View example'),
),
body: Center(
child: Column(
children: [
const Text("CodeTextView"),
const SizedBox(
height: 12,
),
CodeTextView(
code: codeSnippet,
language: "Java",
theme: "darcula",
options: TextSelectionOptions(
copy: true,
selectAll: true,
share: true,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Text("CodeTextView"),
const SizedBox(
height: 12,
),
Padding(
padding: const EdgeInsets.all(16.0),
child: CodeTextView(
code: codeSnippet,
language: "Java",
theme: "darcula",
options: TextSelectionOptions(
copy: true,
selectAll: true,
share: true,
),
),
),
),
const SizedBox(height: 24),
const Text("CodeEditText"),
const SizedBox(height: 12),
CodeEditText(
code: codeSnippet,
controller: controller,
showCursor: true,
),
],
)),
const SizedBox(height: 24),
const Text("CodeEditText"),
const SizedBox(height: 12),
Padding(
padding: const EdgeInsets.all(16.0),
child: CodeEditText(
code: codeSnippet,
controller: controller,
showCursor: true,
),
),
],
),
),
),
);
}
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.0.1"
version: "0.1.0"
leak_tracker:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion lib/src/presentation/styles/text_styles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class TextStyles extends Text {
key: key,
style: const TextStyle(
fontSize: 16,
fontStyle: FontStyle.italic,
fontStyle: FontStyle.normal,
),
);

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: kode_view
description: Flutter syntax highlighting widgets based on Highlights
version: 0.0.1
version: 0.1.0
homepage: https://github.com/SnipMeDev/kode_view

environment:
Expand Down

0 comments on commit 1de0066

Please sign in to comment.