Skip to content

Commit

Permalink
Merge pull request mehdizarepour#8 from mehdizarepour/dev
Browse files Browse the repository at this point in the history
Add `minFontSize` and `maxFontSize` props
  • Loading branch information
mehdizarepour authored Jun 17, 2021
2 parents 686d4ff + 0bb4049 commit 98969f0
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.4.1

* Add `minFontSize` and `maxFontSize` props
* Fix issue #7

## 0.4.0+1

* Edit docs.
Expand Down
1 change: 1 addition & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class _MyHomePageState extends State<MyHomePage> {
text: text,
textStyle: textStyle,
textAlingment: textAlign,
minFontSize: 10,
// paletteColors: [
// Colors.black,
// Colors.white,
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.4.0+1"
version: "0.4.1"
typed_data:
dependency: transitive
description:
Expand Down
13 changes: 9 additions & 4 deletions lib/src/widget/font_size.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@ import 'package:provider/provider.dart';
import 'package:text_editor/src/text_style_model.dart';

class FontSize extends StatelessWidget {
final double minFontSize;
final double maxFontSize;

FontSize({required this.minFontSize, required this.maxFontSize});

@override
Widget build(BuildContext context) {
return Consumer<TextStyleModel>(
builder: (context, model, child) => RotatedBox(
quarterTurns: 3,
child: Slider(
value: model.textStyle?.fontSize ?? 1,
min: 0,
max: 100,
divisions: 100,
value: model.textStyle?.fontSize ?? minFontSize,
min: minFontSize,
max: maxFontSize,
divisions: ((maxFontSize - minFontSize) * 10).toInt(),
activeColor: Colors.white,
inactiveColor: Colors.white,
onChanged: (double value) => model.editFontSize(value),
Expand Down
10 changes: 9 additions & 1 deletion lib/text_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class TextEditor extends StatefulWidget {
/// Decoration to customize the editor
final EditorDecoration? decoration;

final double? minFontSize;
final double? maxFontSize;

/// Create a [TextEditor] widget
///
/// [fonts] list of font families that you want to use in editor.
Expand All @@ -63,6 +66,8 @@ class TextEditor extends StatefulWidget {
this.text = '',
this.textStyle,
this.textAlingment,
this.minFontSize = 1,
this.maxFontSize = 100,
this.onTextAlignChanged,
this.onTextStyleChanged,
this.onTextChanged,
Expand Down Expand Up @@ -156,7 +161,10 @@ class _TextEditorState extends State<TextEditor> {
Expanded(
child: Row(
children: [
FontSize(),
FontSize(
minFontSize: widget.minFontSize!,
maxFontSize: widget.maxFontSize!,
),
Expanded(
child: Container(
child: Center(
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: text_editor
description: An Instagram like text editor Flutter widget that helps you to change your text style.
version: 0.4.0+1
version: 0.4.1
author: Mehdi Zarepour<[email protected]>
homepage: https://github.com/mehdizarepour/text_editor.git

Expand Down

0 comments on commit 98969f0

Please sign in to comment.