update for new microcontroller
Some checks failed
xiao_pet_tracker / semantic-pull-request (push) Failing after 0s
xiao_pet_tracker / build (push) Failing after 0s
xiao_pet_tracker / spell-check (push) Failing after 0s

This commit is contained in:
2025-06-27 16:37:38 +02:00
parent fe07da70f5
commit a16145e48c
14 changed files with 292 additions and 139 deletions

View File

@@ -7,7 +7,7 @@ import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:forui/forui.dart';
import 'package:xiao_pet_tracker/app_router/app_router.dart';
import 'package:xiao_pet_tracker/bootstrap.dart';
import 'package:xiao_pet_tracker/l10n/l10n.dart';
import 'package:xiao_pet_tracker/l10n/arb/app_localizations.dart';
class AppView extends StatefulWidget {
const AppView({super.key});

View File

@@ -19,7 +19,7 @@ class AppRouter extends RootStackRouter {
),
AutoRoute(
page: RecordingsRoute.page,
children: [],
children: const [],
),
],
),
@@ -72,14 +72,14 @@ class MainPage extends StatelessWidget {
return FBottomNavigationBar(
index: tabsRouter.activeIndex,
onChange: tabsRouter.setActiveIndex,
children: [
children: const [
FBottomNavigationBarItem(
label: const Text('Xiao Connector'),
icon: FIcon(FAssets.icons.microchip),
label: Text('Xiao Connector'),
icon: Icon(FIcons.microchip),
),
FBottomNavigationBarItem(
label: const Text('Recordings'),
icon: FIcon(FAssets.icons.disc3),
label: Text('Recordings'),
icon: Icon(FIcons.disc3),
),
],
);

View File

@@ -0,0 +1,139 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:intl/intl.dart' as intl;
import 'app_localizations_en.dart';
import 'app_localizations_es.dart';
// ignore_for_file: type=lint
/// Callers can lookup localized strings with an instance of AppLocalizations
/// returned by `AppLocalizations.of(context)`.
///
/// Applications need to include `AppLocalizations.delegate()` in their app's
/// `localizationDelegates` list, and the locales they support in the app's
/// `supportedLocales` list. For example:
///
/// ```dart
/// import 'arb/app_localizations.dart';
///
/// return MaterialApp(
/// localizationsDelegates: AppLocalizations.localizationsDelegates,
/// supportedLocales: AppLocalizations.supportedLocales,
/// home: MyApplicationHome(),
/// );
/// ```
///
/// ## Update pubspec.yaml
///
/// Please make sure to update your pubspec.yaml to include the following
/// packages:
///
/// ```yaml
/// dependencies:
/// # Internationalization support.
/// flutter_localizations:
/// sdk: flutter
/// intl: any # Use the pinned version from flutter_localizations
///
/// # Rest of dependencies
/// ```
///
/// ## iOS Applications
///
/// iOS applications define key application metadata, including supported
/// locales, in an Info.plist file that is built into the application bundle.
/// To configure the locales supported by your app, youll need to edit this
/// file.
///
/// First, open your projects ios/Runner.xcworkspace Xcode workspace file.
/// Then, in the Project Navigator, open the Info.plist file under the Runner
/// projects Runner folder.
///
/// Next, select the Information Property List item, select Add Item from the
/// Editor menu, then select Localizations from the pop-up menu.
///
/// Select and expand the newly-created Localizations item then, for each
/// locale your application supports, add a new item and select the locale
/// you wish to add from the pop-up menu in the Value field. This list should
/// be consistent with the languages listed in the AppLocalizations.supportedLocales
/// property.
abstract class AppLocalizations {
AppLocalizations(String locale)
: localeName = intl.Intl.canonicalizedLocale(locale.toString());
final String localeName;
static AppLocalizations of(BuildContext context) {
return Localizations.of<AppLocalizations>(context, AppLocalizations)!;
}
static const LocalizationsDelegate<AppLocalizations> delegate =
_AppLocalizationsDelegate();
/// A list of this localizations delegate along with the default localizations
/// delegates.
///
/// Returns a list of localizations delegates containing this delegate along with
/// GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate,
/// and GlobalWidgetsLocalizations.delegate.
///
/// Additional delegates can be added by appending to this list in
/// MaterialApp. This list does not have to be used at all if a custom list
/// of delegates is preferred or required.
static const List<LocalizationsDelegate<dynamic>> localizationsDelegates =
<LocalizationsDelegate<dynamic>>[
delegate,
GlobalMaterialLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
];
/// A list of this localizations delegate's supported locales.
static const List<Locale> supportedLocales = <Locale>[
Locale('en'),
Locale('es')
];
/// Text shown in the AppBar of the Counter Page
///
/// In en, this message translates to:
/// **'Counter'**
String get counterAppBarTitle;
}
class _AppLocalizationsDelegate
extends LocalizationsDelegate<AppLocalizations> {
const _AppLocalizationsDelegate();
@override
Future<AppLocalizations> load(Locale locale) {
return SynchronousFuture<AppLocalizations>(lookupAppLocalizations(locale));
}
@override
bool isSupported(Locale locale) =>
<String>['en', 'es'].contains(locale.languageCode);
@override
bool shouldReload(_AppLocalizationsDelegate old) => false;
}
AppLocalizations lookupAppLocalizations(Locale locale) {
// Lookup logic when only language code is specified.
switch (locale.languageCode) {
case 'en':
return AppLocalizationsEn();
case 'es':
return AppLocalizationsEs();
}
throw FlutterError(
'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
'an issue with the localizations generation tool. Please file an issue '
'on GitHub with a reproducible sample app and the gen-l10n configuration '
'that was used.');
}

View File

@@ -0,0 +1,13 @@
// ignore: unused_import
import 'package:intl/intl.dart' as intl;
import 'app_localizations.dart';
// ignore_for_file: type=lint
/// The translations for English (`en`).
class AppLocalizationsEn extends AppLocalizations {
AppLocalizationsEn([String locale = 'en']) : super(locale);
@override
String get counterAppBarTitle => 'Counter';
}

View File

@@ -0,0 +1,13 @@
// ignore: unused_import
import 'package:intl/intl.dart' as intl;
import 'app_localizations.dart';
// ignore_for_file: type=lint
/// The translations for Spanish Castilian (`es`).
class AppLocalizationsEs extends AppLocalizations {
AppLocalizationsEs([String locale = 'es']) : super(locale);
@override
String get counterAppBarTitle => 'Contador';
}

View File

@@ -1,7 +1,5 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
export 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:xiao_pet_tracker/l10n/arb/app_localizations.dart';
extension AppLocalizationsX on BuildContext {
AppLocalizations get l10n => AppLocalizations.of(this);

View File

@@ -46,7 +46,7 @@ class _SettingsViewState extends State<RecordingsView> {
itemCount: _captureBoxes.length,
itemBuilder: (context, i) {
return ListTile(
leading: FIcon(FAssets.icons.pawPrint),
leading: const Icon(FIcons.pawPrint),
title: Text('Collection Type: ${_captureBoxes[i].type}'),
subtitle: Text(f.format(_captureBoxes[i].startTime)),
onTap: () {

View File

@@ -67,7 +67,7 @@ class XiaoConnectorCubit extends Cubit<XiaoConnectorState> {
}
// set the xiao sense name
if (r.device.advName == 'Go Bluetooth') {
if (r.device.advName == 'Trouble Example') {
await FlutterBluePlus.stopScan();
device = r.device;
@@ -100,6 +100,27 @@ class XiaoConnectorCubit extends Cubit<XiaoConnectorState> {
);
}
Future<void> debug() async {
print('DEBUG!');
final accelService = _services
.where(
(s) => s.serviceUuid == Guid('19B10000-E8F2-537E-4F6C-D104768A1214'),
)
.first
.characteristics
.where(
(c) =>
c.characteristicUuid ==
Guid('19B10000-E8F2-537E-4F6C-D104768A1217'),
)
.first;
final data = await accelService.read();
print(data);
// accelService.onValueReceived((data) {});
}
Future<void> setCapturingOn() async {
final senseService = _services
.where(

View File

@@ -42,6 +42,15 @@ class ConnectedView extends StatelessWidget {
},
child: const Text('Disconnect'),
),
const SizedBox(
height: 48,
),
ElevatedButton(
onPressed: () {
context.read<XiaoConnectorCubit>().debug();
},
child: const Text('DEBUG'),
),
],
),
),