Seat the path sheet header with the other sheets
The sheet background was taller than its content, leaving an empty band above the drag handle. Use the shared sheet header, and rank the share sheet's own contact with the same name and hash matcher. Co-authored-by: zjs81 <zjs81@users.noreply.github.com>
This commit is contained in:
6 files changed
+203
-89
No files matched your search
@@ -9,19 +9,54 @@ enum ContactQueryRank { namePrefix, nameContains, keyPrefix }
|
||||
///
|
||||
/// Names that start with the query come before other substring matches.
|
||||
/// A public-key / hop-hash prefix matches only when the name does not.
|
||||
/// Name-only half of [rankContactQuery], for a label that is not itself a
|
||||
/// contact (for example the "my contact" alias on the share sheet).
|
||||
ContactQueryRank? rankNameQuery(String name, String query) {
|
||||
final normalized = query.trim().toLowerCase();
|
||||
if (normalized.isEmpty) return ContactQueryRank.namePrefix;
|
||||
final label = name.toLowerCase();
|
||||
if (label.startsWith(normalized)) return ContactQueryRank.namePrefix;
|
||||
if (label.contains(normalized)) return ContactQueryRank.nameContains;
|
||||
return null;
|
||||
}
|
||||
|
||||
ContactQueryRank? rankContactQuery(Contact contact, String query) {
|
||||
final normalized = query.trim().toLowerCase();
|
||||
if (normalized.isEmpty) return ContactQueryRank.namePrefix;
|
||||
|
||||
final name = contact.name.toLowerCase();
|
||||
if (name.startsWith(normalized)) return ContactQueryRank.namePrefix;
|
||||
if (name.contains(normalized)) return ContactQueryRank.nameContains;
|
||||
final byName = rankNameQuery(contact.name, normalized);
|
||||
if (byName != null) return byName;
|
||||
if (_publicKeyPrefixMatches(contact, normalized)) {
|
||||
return ContactQueryRank.keyPrefix;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Whether [name], any [aliases], or [publicKeyHex] matches [query] with the
|
||||
/// same prefix, substring, then hash order as [rankContactQuery].
|
||||
ContactQueryRank? rankLabeledKeyQuery({
|
||||
required String name,
|
||||
required String publicKeyHex,
|
||||
required String query,
|
||||
List<String> aliases = const [],
|
||||
}) {
|
||||
final normalized = query.trim().toLowerCase();
|
||||
if (normalized.isEmpty) return ContactQueryRank.namePrefix;
|
||||
ContactQueryRank? best = rankNameQuery(name, normalized);
|
||||
for (final alias in aliases) {
|
||||
final rank = rankNameQuery(alias, normalized);
|
||||
if (rank != null && (best == null || rank.index < best.index)) {
|
||||
best = rank;
|
||||
}
|
||||
}
|
||||
if (best != null) return best;
|
||||
final hexPrefix = _extractHexPrefix(normalized);
|
||||
if (hexPrefix != null && publicKeyHex.toLowerCase().startsWith(hexPrefix)) {
|
||||
return ContactQueryRank.keyPrefix;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
bool matchesContactQuery(Contact contact, String query) {
|
||||
return rankContactQuery(contact, query) != null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user