Files
buzz/mobile/lib/features/channels/ios_create_channel_sheet.dart
klopez4212 a66cb5f7ab Modernize mobile channel and DM creation sheets (#8942)
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 iOS channel
form](https://github.com/user-attachments/assets/a3ee78c9-510d-488c-979e-64fa3bded686)
| ![Android channel
form](https://github.com/user-attachments/assets/a2d65f1c-752c-4cef-b659-2b396cbbbcc9)
|

Native menu with the left label fixed:

![Native value-only menu
preview](https://github.com/user-attachments/assets/c4fe8659-e46c-409f-b866-c9568b26ccc1)

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
2026-11-03 18:11:15 +00:00

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;
}
}
}