Skip to content

controller: support for non-English user. #114

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
18 changes: 10 additions & 8 deletions controller/lib/data/stories.dart
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
import 'package:flutter/foundation.dart';
import 'package:monarch_definitions/monarch_definitions.dart';

final notAscii = RegExp(r'[^ -~]');

class StoryGroup {
final String groupName;
final String _groupName;
final List<StoryId> stories;
final String groupKey;

String get groupName => notAscii.hasMatch(_groupName) ? _groupName.replaceFirst('_stories', '') : _groupName;

StoryGroup({
required this.groupName,
required String groupName,
required this.stories,
required this.groupKey,
});
}) : _groupName = groupName;

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is StoryGroup &&
groupName == other.groupName &&
listEquals(stories, other.stories);
other is StoryGroup && _groupName == other._groupName && listEquals(stories, other.stories);

@override
int get hashCode => groupName.hashCode ^ stories.hashCode;
int get hashCode => _groupName.hashCode ^ stories.hashCode;

StoryGroup copyWith({List<StoryId>? stories}) {
return StoryGroup(
groupName: groupName,
groupName: _groupName,
stories: stories ?? this.stories,
groupKey: groupKey,
);
Expand Down
9 changes: 7 additions & 2 deletions packages/monarch/lib/src/builders/meta_stories_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ class MetaStoriesBuilder implements Builder {
continue;
}

String? metaName;
var pragma = declaration.metadata.where((annotation) => annotation.name.name == 'pragma');
if (pragma.isNotEmpty) {
metaName = pragma.first.arguments?.arguments.first.toString();
}
var functionName = declaration.name.lexeme;
var returnType = declaration.returnType;
var parameters = declaration.functionExpression.parameters;
Expand Down Expand Up @@ -73,8 +78,8 @@ class MetaStoriesBuilder implements Builder {
var storyNameInSingleQuotes = "'$storyName'";
log.fine('Found potential story `$returnTypeName $storyName()`.');

storiesNames.add(storyNameInSingleQuotes);
storiesMap[storyNameInSingleQuotes] = storyName;
storiesNames.add(metaName ?? storyNameInSingleQuotes);
storiesMap[metaName ?? storyNameInSingleQuotes] = storyName;
}

final pathToStoriesFile = getImportUriOrRelativePath(buildStep.inputId);
Expand Down