mirror of
https://github.com/block/buzz.git
synced 2026-10-29 05:21:31 +00:00
## Summary - invert mobile utility surfaces so pages and sheets use the softer page background with raised containers - rebuild the community theme picker around swipeable Home/Chat previews, accent and appearance controls, and native iOS glass interactions - align shared sheet/profile spacing and radii, and move Theme into the Community settings card ### Related issue None found. ### Testing - `just mobile-check` - `just mobile-test` (1,871 tests) - signed iOS Release build installed on a physical iPhone --------- Signed-off-by: kenny lopez <klopez4212@gmail.com> Signed-off-by: Kenny Lopez <klopez4212@gmail.com> Signed-off-by: Princess Donut <b238ea756dee4d98afa5883fc7f1de61eeabe65bf700e3a5a5a80db5e42e2c2b@buzz.block.builderlab.xyz> Co-authored-by: Princess Donut <b238ea756dee4d98afa5883fc7f1de61eeabe65bf700e3a5a5a80db5e42e2c2b@buzz.block.builderlab.xyz>
79 lines
2.5 KiB
Dart
79 lines
2.5 KiB
Dart
import 'package:flutter/services.dart';
|
|
|
|
import '../../shared/theme/theme.dart';
|
|
|
|
/// Opens the native iOS form used to edit a single profile text field.
|
|
class IosProfileTextEditor {
|
|
IosProfileTextEditor._();
|
|
|
|
static const _channel = MethodChannel('buzz/profile_text_editor');
|
|
|
|
/// Presents the native editor and returns its submitted value, or null when
|
|
/// the user cancels.
|
|
static Future<String?> present({
|
|
required String title,
|
|
required String initialValue,
|
|
required String placeholder,
|
|
required bool multiline,
|
|
required Brightness brightness,
|
|
required Color pageBackgroundColor,
|
|
required Color containerBackgroundColor,
|
|
bool allowUnchangedSubmission = false,
|
|
}) => _channel.invokeMethod<String>('present', {
|
|
'title': title,
|
|
'initialValue': initialValue,
|
|
'placeholder': placeholder,
|
|
'multiline': multiline,
|
|
'brightness': brightness.name,
|
|
'pageBackgroundArgb': pageBackgroundColor.toARGB32(),
|
|
'containerBackgroundArgb': containerBackgroundColor.toARGB32(),
|
|
'containerCornerRadius': Radii.container,
|
|
'allowUnchangedSubmission': allowUnchangedSubmission,
|
|
});
|
|
|
|
/// Keeps the native editor's latest value available until it saves or the
|
|
/// user cancels, so a transient publish failure never discards their text.
|
|
static Future<void> presentUntilSaved({
|
|
required String title,
|
|
required String initialValue,
|
|
required String placeholder,
|
|
required bool multiline,
|
|
required Brightness brightness,
|
|
required Color pageBackgroundColor,
|
|
required Color containerBackgroundColor,
|
|
required Future<void> Function(String value) onSave,
|
|
required void Function() onSaveError,
|
|
bool Function(Object error)? shouldRetryOnError,
|
|
bool Function()? canPresent,
|
|
}) async {
|
|
var draft = initialValue;
|
|
var isRetry = false;
|
|
while (true) {
|
|
if (canPresent?.call() == false) return;
|
|
final value = await present(
|
|
title: title,
|
|
initialValue: draft,
|
|
placeholder: placeholder,
|
|
multiline: multiline,
|
|
brightness: brightness,
|
|
pageBackgroundColor: pageBackgroundColor,
|
|
containerBackgroundColor: containerBackgroundColor,
|
|
allowUnchangedSubmission: isRetry,
|
|
);
|
|
if (value == null) return;
|
|
try {
|
|
await onSave(value);
|
|
return;
|
|
} catch (error) {
|
|
if (shouldRetryOnError?.call(error) == false ||
|
|
canPresent?.call() == false) {
|
|
return;
|
|
}
|
|
draft = value;
|
|
isRetry = true;
|
|
onSaveError();
|
|
}
|
|
}
|
|
}
|
|
}
|