mirror of
https://github.com/block/buzz.git
synced 2026-11-25 18:52:52 +00:00
Modernizes New Channel and New DM with full-height forms and X/Create or X/checkmark actions. iOS uses UIKit sheets throughout; Android uses the Flutter fallback. Channel menus default to Ongoing/Public, and native menu previews lift only the trailing value while labels stay fixed. Channel names disable automatic capitalization, autocorrect, and spellcheck; both platforms use descriptive placeholders. Preserves recipient search and limits, creation error retries, and navigation after native dismissal. Validation: 4,154 mobile tests passed (38 skipped), auxiliary suites and static checks passed; iOS device/simulator and Android builds passed. Exercised menus, dismissal, DM search and selection in the simulator and Android form behavior on Pixel; iPhone UI tested and approved by the author. | iOS native form (Simulator) | Android Flutter form (Pixel) | | --- | --- | |  |  | Native menu with the left label fixed:  --------- Signed-off-by: kenny lopez <klopez4212@gmail.com> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
56 lines
1.7 KiB
Dart
56 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
|
|
import '../../shared/theme/theme.dart';
|
|
import 'channel.dart';
|
|
|
|
/// Presents an entirely UIKit channel form; relay writes stay in Dart.
|
|
class IosCreateChannelSheet {
|
|
static const _channel = MethodChannel('buzz/create_channel_sheet');
|
|
static bool _open = false;
|
|
|
|
static Future<Channel?> present({
|
|
required BuildContext context,
|
|
required Future<Channel> Function({
|
|
required String name,
|
|
required String description,
|
|
required String visibility,
|
|
required int? ttlSeconds,
|
|
})
|
|
onCreate,
|
|
}) async {
|
|
if (_open) return null;
|
|
_open = true;
|
|
Channel? created;
|
|
final session = UniqueKey().toString();
|
|
final theme = utilitySurfaceThemeData(Theme.of(context));
|
|
_channel.setMethodCallHandler((call) async {
|
|
final data = Map<Object?, Object?>.from(call.arguments as Map);
|
|
if (call.method != 'create' || data['session'] != session) return null;
|
|
try {
|
|
created = await onCreate(
|
|
name: data['name'] as String,
|
|
description: data['description'] as String,
|
|
visibility: data['visibility'] as String,
|
|
ttlSeconds: data['ttlSeconds'] as int?,
|
|
);
|
|
return {'success': true};
|
|
} catch (error) {
|
|
return {'error': error.toString()};
|
|
}
|
|
});
|
|
try {
|
|
await _channel.invokeMethod<void>('present', {
|
|
'session': session,
|
|
'dark': theme.brightness == Brightness.dark,
|
|
'pageColor': theme.colorScheme.surface.toARGB32(),
|
|
'rowColor': theme.colorScheme.surfaceContainerHighest.toARGB32(),
|
|
});
|
|
return created;
|
|
} finally {
|
|
_channel.setMethodCallHandler(null);
|
|
_open = false;
|
|
}
|
|
}
|
|
}
|