Skip to content

Commit

Permalink
Merge branch 'shiosyakeyakini-info:develop' into buildappimage_3
Browse files Browse the repository at this point in the history
  • Loading branch information
Npepperlinux authored Oct 3, 2023
2 parents ea0eb83 + c30e96b commit bed46c6
Show file tree
Hide file tree
Showing 62 changed files with 3,958 additions and 1,455 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ app.*.map.json

# builder
**/node_modules/
**/build/

# Release
/private_keys/
83 changes: 69 additions & 14 deletions lib/extensions/text_editing_controller_extension.dart
Original file line number Diff line number Diff line change
@@ -1,25 +1,80 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:miria/model/input_completion_type.dart';

extension TextEditingControllerExtension on TextEditingController {
bool get isIncludeBeforeColon {
if (selection.base.offset == -1) return false;
return text.substring(0, selection.base.offset).contains(":");
String? get textBeforeSelection {
final baseOffset = selection.baseOffset;
if (baseOffset < 0) {
return null;
}
return text.substring(0, baseOffset);
}

bool get isEmojiScope {
final position = selection.base.offset;
final startPosition = text.substring(0, position).lastIndexOf(":") + 1;
String? get emojiQuery {
final textBeforeSelection = this.textBeforeSelection;
if (textBeforeSelection == null) {
return null;
}
final lastColonIndex = textBeforeSelection.lastIndexOf(":");
if (lastColonIndex < 0) {
return null;
}
if (RegExp(r':[a-zA-z_0-9]+?:$')
.hasMatch(text.substring(0, startPosition))) {
return true;
.hasMatch(text.substring(0, lastColonIndex + 1))) {
return null;
} else {
return textBeforeSelection.substring(lastColonIndex + 1);
}
}

String? get mfmFnQuery {
final textBeforeSelection = this.textBeforeSelection;
if (textBeforeSelection == null) {
return null;
}
final lastOpenTagIndex = textBeforeSelection.lastIndexOf(r"$[");
if (lastOpenTagIndex < 0) {
return null;
}
final query = textBeforeSelection.substring(lastOpenTagIndex + 2);
if (RegExp(r"^[a-z234]*$").hasMatch(query)) {
return query;
} else {
return null;
}
return false;
}

String get emojiSearchValue {
final position = selection.base.offset;
final startPosition = text.substring(0, position).lastIndexOf(":") + 1;
return text.substring(startPosition, position);
String? get hashtagQuery {
final textBeforeSelection = this.textBeforeSelection;
if (textBeforeSelection == null) {
return null;
}
final lastHashIndex = textBeforeSelection.lastIndexOf("#");
if (lastHashIndex < 0) {
return null;
}
final query = textBeforeSelection.substring(lastHashIndex + 1);
if (query.contains(RegExp(r"""[ \u3000\t.,!?'"#:/[\]【】()「」()<>]"""))) {
return null;
} else {
return query;
}
}

InputCompletionType get inputCompletionType {
final emojiQuery = this.emojiQuery;
if (emojiQuery != null) {
return Emoji(emojiQuery);
}
final mfmFnQuery = this.mfmFnQuery;
if (mfmFnQuery != null) {
return MfmFn(mfmFnQuery);
}
final hashtagQuery = this.hashtagQuery;
if (hashtagQuery != null) {
return Hashtag(hashtagQuery);
}
return Basic();
}

void insert(String insertText, {String? afterText}) {
Expand Down
36 changes: 36 additions & 0 deletions lib/model/antenna_settings.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:misskey_dart/misskey_dart.dart';

part 'antenna_settings.freezed.dart';

@freezed
class AntennaSettings with _$AntennaSettings {
const factory AntennaSettings({
@Default("") String name,
@Default(AntennaSource.all) AntennaSource src,
String? userListId,
@Default([]) List<List<String>> keywords,
@Default([]) List<List<String>> excludeKeywords,
@Default([]) List<String> users,
@Default(false) bool caseSensitive,
@Default(false) bool withReplies,
@Default(false) bool withFile,
@Default(false) bool notify,
}) = _AntennaSettings;
const AntennaSettings._();

factory AntennaSettings.fromAntenna(Antenna antenna) {
return AntennaSettings(
name: antenna.name,
src: antenna.src,
userListId: antenna.userListId,
keywords: antenna.keywords,
excludeKeywords: antenna.excludeKeywords,
users: antenna.users,
caseSensitive: antenna.caseSensitive,
withReplies: antenna.withReplies,
withFile: antenna.withFile,
notify: antenna.notify,
);
}
}
Loading

0 comments on commit bed46c6

Please sign in to comment.