fix: float the pet over the messages and let it be dragged
The pet used to sit in the column above the composer, reserving a strip of its own: the message list ended there, which read as an opaque band cutting off the last row. It is now a layer over the message area, so the list keeps its full height and shows through around the sprite. Only the body of the sheet takes touches (contentBox, 4dp out); taps and drags on the transparent canvas still reach the messages underneath. Dragging the body moves the pet along the composer's top edge (or the activity cap's) with a small lift while held and the pack's drag reaction. The spot is stored as a fraction of the width in pet.x.v1, so a restart or a change in width puts it back in the same place. Taps now react on tap-up so a drag does not fire a left/right reaction. 0.4.1 (401).
This commit is contained in:
1 parent
d72af036a1
commit
d25167de58
8 files changed
+348
-58
No files matched your search
@@ -26,6 +26,7 @@ class PetLibrary extends ChangeNotifier {
|
||||
static const _activeKey = 'pet.active.v1';
|
||||
static const _enabledKey = 'pet.enabled.v1';
|
||||
static const _sizeKey = 'pet.size.v1';
|
||||
static const _positionKey = 'pet.x.v1';
|
||||
|
||||
/// The canvas width a pet is drawn at; the list offers these.
|
||||
static const sizes = <double>[40, 52, 64];
|
||||
@@ -34,6 +35,9 @@ class PetLibrary extends ChangeNotifier {
|
||||
bool enabled = false;
|
||||
double size = 52;
|
||||
|
||||
/// Where the pet stands along its edge, 0 = left end, 1 = right end.
|
||||
double position = 0.5;
|
||||
|
||||
String? _packDir;
|
||||
bool _loaded = false;
|
||||
|
||||
@@ -53,6 +57,7 @@ class PetLibrary extends ChangeNotifier {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
enabled = prefs.getBool(_enabledKey) ?? false;
|
||||
size = (prefs.getDouble(_sizeKey) ?? 52).clamp(32, 80);
|
||||
position = (prefs.getDouble(_positionKey) ?? 0.5).clamp(0.0, 1.0);
|
||||
final active = prefs.getString(_activeKey);
|
||||
if (active != null && active.isNotEmpty) {
|
||||
final root = await _petsRoot();
|
||||
@@ -93,6 +98,15 @@ class PetLibrary extends ChangeNotifier {
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
Future<void> setPosition(double value) async {
|
||||
position = value.clamp(0.0, 1.0);
|
||||
notifyListeners();
|
||||
try {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setDouble(_positionKey, position);
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
/// Unpacks and activates a pet package. [root] is for tests; the app uses
|
||||
/// the documents directory.
|
||||
Future<PetPack> importZip(List<int> bytes, {Directory? root}) async {
|
||||
|
||||
Reference in new issue
Block a user