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 1 commit
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
2 changes: 2 additions & 0 deletions lib/domain/language_check_service.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: public_member_api_docs
Luxorum marked this conversation as resolved.
Show resolved Hide resolved

import 'package:languagetool_textfield/domain/mistake.dart';

abstract class LanguageCheckService {
Expand Down
13 changes: 13 additions & 0 deletions lib/domain/mistake.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
/// Object that stores information about a single writing mistake.
Luxorum marked this conversation as resolved.
Show resolved Hide resolved
class Mistake {
/// A brief description of the mistake.
final String message;

/// The type of mistake.
Luxorum marked this conversation as resolved.
Show resolved Hide resolved
final String type;

/// Position of the beginning of the mistake.
Luxorum marked this conversation as resolved.
Show resolved Hide resolved
final int offset;

/// Length of the mistake after the offset.
final int length;

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

/// Object that stores information about a single writing mistake.
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;

/// Debouncing.
Luxorum marked this conversation as resolved.
Show resolved Hide resolved
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 {
/// Object that will be used to interact with LanguageTool API.
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;

/// Throttling.
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