mirror of
https://github.com/m5stack/StackChan.git
synced 2026-04-28 03:22:39 +00:00
6314188835
- align Android/iOS native bridge implementations and audio handling paths - improve Bluetooth provisioning/verification flow and related error handling - refactor WebSocket, music, and device utility logic for more stable behavior - clean up noisy debug logs and normalize comments across Flutter and native code - update AR view, dance/agent/device pages, and platform integration details
139 lines
4.3 KiB
Dart
139 lines
4.3 KiB
Dart
/*
|
|
SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
|
|
SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
//====================== devicename(completed) ======================
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:stack_chan/view/popup/XiaoZhi_welcome_page.dart';
|
|
|
|
import '../../app_state.dart';
|
|
import 'device_wifi_config.dart';
|
|
|
|
class DeviceNamePage extends StatefulWidget {
|
|
const DeviceNamePage({super.key});
|
|
|
|
@override
|
|
State<StatefulWidget> createState() => _DeviceNamePageState();
|
|
}
|
|
|
|
class _DeviceNamePageState extends State<DeviceNamePage> {
|
|
late TextEditingController _nameController;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_nameController = TextEditingController(text: "My StackChan");
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_nameController.dispose();
|
|
if (mounted) {
|
|
FocusScope.of(context).unfocus();
|
|
}
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return CupertinoPageScaffold(
|
|
backgroundColor: CupertinoColors.systemGroupedBackground.resolveFrom(
|
|
context,
|
|
),
|
|
child: Column(
|
|
children: [
|
|
Expanded(
|
|
child: CustomScrollView(
|
|
slivers: [
|
|
CupertinoSliverNavigationBar(largeTitle: Text("Device Name")),
|
|
SliverList.list(
|
|
children: [
|
|
Image.asset(
|
|
"assets/lateral_image.png",
|
|
width: double.infinity,
|
|
height: 120,
|
|
fit: BoxFit.contain,
|
|
),
|
|
SizedBox(height: 15),
|
|
CupertinoListSection.insetGrouped(
|
|
header: Text("Give this StackChan a name"),
|
|
children: [
|
|
CupertinoListTile(
|
|
padding: .all(15),
|
|
title: CupertinoTextField(
|
|
decoration: BoxDecoration(),
|
|
controller: _nameController,
|
|
placeholder: "Enter device name",
|
|
clearButtonMode: OverlayVisibilityMode.editing,
|
|
autofocus: true,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Padding(
|
|
padding: .only(
|
|
left: 15,
|
|
right: 15,
|
|
top: 15,
|
|
bottom: MediaQuery.paddingOf(context).bottom + 15,
|
|
),
|
|
child: Row(
|
|
spacing: 15,
|
|
children: [
|
|
Expanded(
|
|
child: CupertinoButton.tinted(
|
|
child: Text("Skip"),
|
|
onPressed: () {
|
|
if (mounted) {
|
|
FocusScope.of(context).unfocus();
|
|
}
|
|
Navigator.of(context).push(
|
|
CupertinoPageRoute(
|
|
builder: (context) {
|
|
return DeviceWifiConfig();
|
|
},
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
Expanded(
|
|
child: CupertinoButton.filled(
|
|
child: Text("Continue"),
|
|
onPressed: () async {
|
|
if (mounted) {
|
|
FocusScope.of(context).unfocus();
|
|
}
|
|
if (_nameController.text.trim().isEmpty) {
|
|
AppState.shared.showToast("Please enter device name");
|
|
return;
|
|
}
|
|
AppState.shared.deviceInfo.value?.name = _nameController
|
|
.text
|
|
.trim();
|
|
AppState.shared.updateDeviceInfo();
|
|
Navigator.of(context).push(
|
|
CupertinoPageRoute(
|
|
builder: (context) {
|
|
return XiaoZhiWelcomePage(isWelCome: true);
|
|
},
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|