Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document public members, where it is necessary #13

Merged
merged 5 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
3 changes: 3 additions & 0 deletions lib/domain/language_check_service.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import 'package:languagetool_textfield/domain/mistake.dart';

/// Base language check service.
Luxorum marked this conversation as resolved.
Show resolved Hide resolved
abstract class LanguageCheckService {
/// Creates a new instance of the [LanguageCheckService] class.
const LanguageCheckService();

/// Returns found mistakes in the given [text].
Future<List<Mistake>> findMistakes(String text);
}
13 changes: 13 additions & 0 deletions lib/domain/mistake.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
/// A data model class that stores information about a single writing mistake.
class Mistake {
/// A brief description of the mistake.
final String message;

/// A type of this mistake.
final String type;

/// A position of the beginning of this mistake.
final int offset;

/// Length of this mistake after the offset.
Luxorum marked this conversation as resolved.
Show resolved Hide resolved
final int length;

/// A list of suggestions for replacing this mistake.
///
/// Sorted by probability.
final List<String> replacements;

/// Creates a new instance of the [Mistake] class
Luxorum marked this conversation as resolved.
Show resolved Hide resolved
const Mistake({
required this.message,
required this.type,
Expand Down
5 changes: 5 additions & 0 deletions lib/implementations/debounce_lang_tool_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ import 'package:languagetool_textfield/domain/language_check_service.dart';
import 'package:languagetool_textfield/domain/mistake.dart';
import 'package:throttling/throttling.dart';

/// Implementation of language check service with debouncing.
Luxorum marked this conversation as resolved.
Show resolved Hide resolved
class DebounceLangToolService extends LanguageCheckService {
/// Base language check service.
Luxorum marked this conversation as resolved.
Show resolved Hide resolved
final LanguageCheckService baseService;

/// A debouncing used to debounce the API calls.
final Debouncing debouncing;

/// Implementation of language check service with debouncing.
Luxorum marked this conversation as resolved.
Show resolved Hide resolved
DebounceLangToolService(
this.baseService,
Duration debouncingDuration,
Expand Down
3 changes: 3 additions & 0 deletions lib/implementations/lang_tool_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import 'package:language_tool/language_tool.dart';
import 'package:languagetool_textfield/domain/language_check_service.dart';
import 'package:languagetool_textfield/domain/mistake.dart';

/// Implementation of language check service with language tool service.
Luxorum marked this conversation as resolved.
Show resolved Hide resolved
class LangToolService extends LanguageCheckService {
/// Objects of this class are used to interact with LanguageTool API.
Luxorum marked this conversation as resolved.
Show resolved Hide resolved
final LanguageTool languageTool;

/// Implementation of language check service with language tool service.
Luxorum marked this conversation as resolved.
Show resolved Hide resolved
const LangToolService(this.languageTool);

@override
Expand Down
5 changes: 5 additions & 0 deletions lib/implementations/throttling_lang_tool_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ import 'package:languagetool_textfield/domain/language_check_service.dart';
import 'package:languagetool_textfield/domain/mistake.dart';
import 'package:throttling/throttling.dart';

/// Implementation of language check service with throttling.
Luxorum marked this conversation as resolved.
Show resolved Hide resolved
class ThrottlingLangToolService extends LanguageCheckService {
/// Base language check service.
Luxorum marked this conversation as resolved.
Show resolved Hide resolved
final LanguageCheckService baseService;

/// A throttling used to throttle the API calls.
final Throttling throttling;

/// Implementation of LanguageCheckService with throttling.
Luxorum marked this conversation as resolved.
Show resolved Hide resolved
ThrottlingLangToolService(
this.baseService,
Duration throttlingDuration,
Expand Down
10 changes: 9 additions & 1 deletion lib/presentation/language_tool_text_field.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import 'package:flutter/material.dart';
import 'package:languagetool_textfield/domain/language_check_service.dart';

/// Widget for checking grammar errors.
Luxorum marked this conversation as resolved.
Show resolved Hide resolved
class LanguageToolTextField extends StatefulWidget {
/// Service for checking errors.
Luxorum marked this conversation as resolved.
Show resolved Hide resolved
final LanguageCheckService langService;

/// The style to use for the text being edited.
Luxorum marked this conversation as resolved.
Show resolved Hide resolved
final TextStyle style;

/// Decoration of widget
Luxorum marked this conversation as resolved.
Show resolved Hide resolved
final InputDecoration decoration;

/// Will build custom errors based on state.
Luxorum marked this conversation as resolved.
Show resolved Hide resolved
final Widget Function()? mistakeBuilder;

/// Creates a widget that checks grammar errors.
const LanguageToolTextField({
Key? key,
required this.langService,
Expand All @@ -20,7 +29,6 @@ class LanguageToolTextField extends StatefulWidget {
}

class _LanguageToolTextFieldState extends State<LanguageToolTextField> {

@override
Widget build(BuildContext context) {
return const Placeholder();
Expand Down