mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-06-22 10:24:28 +10:00
updated ui added new features
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import '../models/contact.dart';
|
||||
|
||||
bool matchesContactQuery(Contact contact, String query) {
|
||||
final normalizedQuery = query.trim().toLowerCase();
|
||||
if (normalizedQuery.isEmpty) return true;
|
||||
|
||||
if (contact.name.toLowerCase().contains(normalizedQuery)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final hexPrefix = _extractHexPrefix(normalizedQuery);
|
||||
if (hexPrefix == null) return false;
|
||||
|
||||
return contact.publicKeyHex.toLowerCase().startsWith(hexPrefix);
|
||||
}
|
||||
|
||||
String? _extractHexPrefix(String query) {
|
||||
var cleaned = query;
|
||||
if (cleaned.startsWith('0x')) {
|
||||
cleaned = cleaned.substring(2);
|
||||
}
|
||||
cleaned = cleaned.replaceAll(' ', '');
|
||||
if (cleaned.length < 2) return null;
|
||||
if (!RegExp(r'^[0-9a-f]+$').hasMatch(cleaned)) return null;
|
||||
return cleaned;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Route<T> buildQuickSwitchRoute<T>(Widget page) {
|
||||
return PageRouteBuilder<T>(
|
||||
pageBuilder: (context, animation, secondaryAnimation) => page,
|
||||
transitionDuration: const Duration(milliseconds: 220),
|
||||
reverseTransitionDuration: const Duration(milliseconds: 200),
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
||||
final curved = CurvedAnimation(
|
||||
parent: animation,
|
||||
curve: Curves.easeOutCubic,
|
||||
reverseCurve: Curves.easeInCubic,
|
||||
);
|
||||
return FadeTransition(
|
||||
opacity: curved,
|
||||
child: SlideTransition(
|
||||
position: Tween<Offset>(
|
||||
begin: const Offset(0.02, 0),
|
||||
end: Offset.zero,
|
||||
).animate(curved),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user