Skip to content

Commit

Permalink
feat!: Restructure library
Browse files Browse the repository at this point in the history
Moves all files into `lib/src` and selectively exports classes and
functions from `lib/stroke_order_animator.dart`. This provides a cleaner
public API.
  • Loading branch information
Mr-Pepe committed Jan 12, 2024
1 parent 1bbacfb commit e0a1333
Show file tree
Hide file tree
Showing 12 changed files with 371 additions and 367 deletions.
3 changes: 0 additions & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:http/http.dart' as http;
import 'package:provider/provider.dart';
import 'package:stroke_order_animator/download_stroke_order.dart';
import 'package:stroke_order_animator/stroke_order.dart';
import 'package:stroke_order_animator/stroke_order_animation_controller.dart';
import 'package:stroke_order_animator/stroke_order_animator.dart';

void main() {
Expand Down
6 changes: 6 additions & 0 deletions lib/src/distance_2_d.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import 'dart:math';
import 'dart:ui';

double distance2D(Offset p, Offset q) {
return sqrt(pow(p.dx - q.dx, 2) + pow(p.dy - q.dy, 2));
}
File renamed without changes.
20 changes: 20 additions & 0 deletions lib/src/quiz_summary.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'dart:ui';

class QuizSummary {
QuizSummary(this._nStrokes) {
reset();
}
final int _nStrokes;
int get nStrokes => _nStrokes;

late List<int> mistakes;
late List<List<Offset>> correctStrokePaths;

int get nTotalMistakes =>
mistakes.fold(0, (previous, current) => previous + current);

void reset() {
mistakes = List.generate(nStrokes, (index) => 0);
correctStrokePaths = List.generate(nStrokes, (index) => []);
}
}
2 changes: 1 addition & 1 deletion lib/stroke_order.dart → lib/src/stroke_order.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:convert';

import 'package:flutter/rendering.dart';
import 'package:stroke_order_animator/download_stroke_order.dart';
import 'package:stroke_order_animator/stroke_order_animator.dart';
import 'package:svg_path_parser/svg_path_parser.dart';

/// Represents the stroke order of a character.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:stroke_order_animator/stroke_order.dart';
import 'package:stroke_order_animator/src/distance_2_d.dart';
import 'package:stroke_order_animator/stroke_order_animator.dart';

/// A ChangeNotifier that controls the behavior of a stroke order diagram.
Expand Down Expand Up @@ -555,22 +555,3 @@ class StrokeOrderAnimationController extends ChangeNotifier {
notifyListeners();
}
}

class QuizSummary {
QuizSummary(this._nStrokes) {
reset();
}
final int _nStrokes;
int get nStrokes => _nStrokes;

late List<int> mistakes;
late List<List<Offset>> correctStrokePaths;

int get nTotalMistakes =>
mistakes.fold(0, (previous, current) => previous + current);

void reset() {
mistakes = List.generate(nStrokes, (index) => 0);
correctStrokePaths = List.generate(nStrokes, (index) => []);
}
}
Loading

0 comments on commit e0a1333

Please sign in to comment.