Skip to content

Commit

Permalink
Changes for opening bluetooth settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Codel1417 committed Jul 11, 2024
1 parent 2ee8b31 commit 27e2fd3
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 177 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

- Improve indicating when an action card controls multiple gear
- Fix opening links on IOS
- Support more android devices
- Fix connecting to gear on older android versions

### V 1.0.5

Expand Down
10 changes: 5 additions & 5 deletions lib/Frontend/pages/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ class _HomeState extends ConsumerState<Home> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const ListTile(
leading: Icon(Icons.bluetooth_disabled),
title: Text('Bluetooth is Unavailable'),
subtitle: Text('Bluetooth is required to connect to Gear'),
ListTile(
leading: const Icon(Icons.bluetooth_disabled),
title: Text(actionsNoBluetooth()),
subtitle: Text(actionsNoBluetoothDescription()),
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
Expand All @@ -125,7 +125,7 @@ class _HomeState extends ConsumerState<Home> {
onPressed: () async {
AppSettings.openAppSettings(type: AppSettingsType.bluetooth);
},
child: const Text('Open Settings'),
child: Text(onboardingBluetoothEnableButtonLabel()),
),
const SizedBox(width: 8),
],
Expand Down
326 changes: 155 additions & 171 deletions lib/Frontend/pages/intro.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:async';

import 'package:app_settings/app_settings.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
Expand Down Expand Up @@ -62,185 +61,170 @@ class OnBoardingPageState extends ConsumerState<OnBoardingPage> {
bodyFlex: 5,
safeArea: 0,
);
return ValueListenableBuilder(
valueListenable: isBluetoothEnabled,
builder: (BuildContext context, bool bluetoothEnabled, Widget? child) {
return IntroductionScreen(
key: introKey,
canProgress: (page) {
if (page == 2 && !bluetoothAccepted && bluetoothEnabled) {
return false;
} else if (page == 1 && !privacyAccepted) {
return false;
}
return true;
},
globalBackgroundColor: Theme.of(context).canvasColor,
allowImplicitScrolling: true,
globalHeader: Align(
alignment: Alignment.topRight,
child: SafeArea(
child: Padding(
padding: const EdgeInsets.only(top: 16, right: 16),
child: InkWell(
child: _buildImage(Assets.tCLogoTransparentNoText.path, 60),
onLongPress: () async {
_introLogger.info("Open Logs");
const LogsRoute().push(context);
},
),
),
return IntroductionScreen(
key: introKey,
canProgress: (page) {
if (page == 2 && !bluetoothAccepted) {
return false;
} else if (page == 1 && !privacyAccepted) {
return false;
}
return true;
},
globalBackgroundColor: Theme.of(context).canvasColor,
allowImplicitScrolling: true,
globalHeader: Align(
alignment: Alignment.topRight,
child: SafeArea(
child: Padding(
padding: const EdgeInsets.only(top: 16, right: 16),
child: InkWell(
child: _buildImage(Assets.tCLogoTransparentNoText.path, 60),
onLongPress: () async {
_introLogger.info("Open Logs");
const LogsRoute().push(context);
},
),
),
pages: [
PageViewModel(
title: homeWelcomeMessageTitle(),
body: homeWelcomeMessage(),
image: Builder(
builder: (context) {
if (Theme.of(context).colorScheme.brightness == Brightness.light) {
return _buildImage(Assets.splashLightTransparent.path, MediaQuery.of(context).size.width);
} else {
return _buildImage(Assets.splashDarkTransparent.path, MediaQuery.of(context).size.width);
}
},
),
decoration: pageDecoration,
),
PageViewModel(
title: morePrivacyPolicyLinkTitle(),
body: onboardingPrivacyPolicyDescription(),
image: LottieLazyLoad(
asset: Assets.tailcostickers.tailCoStickersFile144834359,
width: MediaQuery.of(context).size.width,
),
footer: ButtonBar(
alignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () async {
MarkdownViewerRoute(
$extra: MarkdownInfo(
content: await rootBundle.loadString(Assets.privacy),
title: morePrivacyPolicyLinkTitle(),
),
).push(context);
},
child: Text(
onboardingPrivacyPolicyViewButtonLabel(),
),
),
FilledButton(
onPressed: privacyAccepted
? null
: () async {
setState(() {
_introLogger.info("Accepted Privacy Policy");
privacyAccepted = true;
HiveProxy
..put(settings, allowErrorReporting, true)
..put(settings, allowAnalytics, true);
introKey.currentState?.next();
});
},
child: Text(
onboardingPrivacyPolicyAcceptButtonLabel(),
),
),
],
),
decoration: pageDecoration,
),
PageViewModel(
title: onboardingBluetoothTitle(),
body: onboardingBluetoothDescription(),
image: LottieLazyLoad(
asset: Assets.tailcostickers.tailCoStickersFile144834357,
width: MediaQuery.of(context).size.width,
),
footer: ButtonBar(
alignment: MainAxisAlignment.center,
children: [
FilledButton(
onPressed: bluetoothEnabled
? null
: () async {
AppSettings.openAppSettings(type: AppSettingsType.bluetooth);
},
child: Text(
onboardingBluetoothEnableButtonLabel(),
),
),
FilledButton(
onPressed: bluetoothAccepted
? null
: () async {
if (await getBluetoothPermission(_introLogger)) {
setState(
() {
// Start FlutterBluePlus
if (!ref.exists(initFlutterBluePlusProvider)) {
ref.read(initFlutterBluePlusProvider);
}
bluetoothAccepted = true;
},
);
introKey.currentState?.next();
}
},
child: Text(
onboardingBluetoothRequestButtonLabel(),
),
),
pages: [
PageViewModel(
title: homeWelcomeMessageTitle(),
body: homeWelcomeMessage(),
image: Builder(
builder: (context) {
if (Theme.of(context).colorScheme.brightness == Brightness.light) {
return _buildImage(Assets.splashLightTransparent.path, MediaQuery.of(context).size.width);
} else {
return _buildImage(Assets.splashDarkTransparent.path, MediaQuery.of(context).size.width);
}
},
),
decoration: pageDecoration,
),
PageViewModel(
title: morePrivacyPolicyLinkTitle(),
body: onboardingPrivacyPolicyDescription(),
image: LottieLazyLoad(
asset: Assets.tailcostickers.tailCoStickersFile144834359,
width: MediaQuery.of(context).size.width,
),
footer: ButtonBar(
alignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () async {
MarkdownViewerRoute(
$extra: MarkdownInfo(
content: await rootBundle.loadString(Assets.privacy),
title: morePrivacyPolicyLinkTitle(),
),
),
],
).push(context);
},
child: Text(
onboardingPrivacyPolicyViewButtonLabel(),
),
),
decoration: pageDecoration,
),
PageViewModel(
title: onboardingCompletedTitle(),
body: "",
image: LottieLazyLoad(
asset: Assets.tailcostickers.tailCoStickersFile144834338,
width: MediaQuery.of(context).size.width,
FilledButton(
onPressed: privacyAccepted
? null
: () async {
setState(() {
_introLogger.info("Accepted Privacy Policy");
privacyAccepted = true;
HiveProxy
..put(settings, allowErrorReporting, true)
..put(settings, allowAnalytics, true);
introKey.currentState?.next();
});
},
child: Text(
onboardingPrivacyPolicyAcceptButtonLabel(),
),
),
decoration: pageDecoration.copyWith(
bodyFlex: 2,
imageFlex: 4,
bodyAlignment: Alignment.bottomCenter,
imageAlignment: Alignment.topCenter,
imagePadding: const EdgeInsets.symmetric(vertical: 32),
contentMargin: const EdgeInsets.only(top: 32),
],
),
decoration: pageDecoration,
),
PageViewModel(
title: onboardingBluetoothTitle(),
body: onboardingBluetoothDescription(),
image: LottieLazyLoad(
asset: Assets.tailcostickers.tailCoStickersFile144834357,
width: MediaQuery.of(context).size.width,
),
footer: ButtonBar(
alignment: MainAxisAlignment.center,
children: [
FilledButton(
onPressed: bluetoothAccepted
? null
: () async {
if (await getBluetoothPermission(_introLogger)) {
setState(
() {
// Start FlutterBluePlus
if (!ref.exists(initFlutterBluePlusProvider)) {
ref.read(initFlutterBluePlusProvider);
}
bluetoothAccepted = true;
},
);
introKey.currentState?.next();
}
},
child: Text(
onboardingBluetoothRequestButtonLabel(),
),
),
reverse: true,
),
],
onDone: () => _onIntroEnd(context),
onSkip: () => _onIntroEnd(context),
// You can override onSkip callback
//rtl: true, // Display as right-to-left
back: const Icon(Icons.arrow_back),
next: const Icon(
Icons.arrow_forward,
key: Key('nextPage'),
],
),
done: FilledButton(
onPressed: () {
_onIntroEnd(context);
},
child: Text(onboardingDoneButtonLabel(), style: const TextStyle(fontWeight: FontWeight.w600)),
decoration: pageDecoration,
),
PageViewModel(
title: onboardingCompletedTitle(),
body: "",
image: LottieLazyLoad(
asset: Assets.tailcostickers.tailCoStickersFile144834338,
width: MediaQuery.of(context).size.width,
),
dotsFlex: 1,
controlsPadding: const EdgeInsets.symmetric(vertical: 32),
dotsDecorator: DotsDecorator(
size: const Size.square(10.0),
activeSize: const Size(40.0, 10.0),
activeColor: Theme.of(context).colorScheme.primary,
color: Theme.of(context).colorScheme.tertiary,
spacing: const EdgeInsets.symmetric(horizontal: 3.0),
activeShape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(50.0)),
decoration: pageDecoration.copyWith(
bodyFlex: 2,
imageFlex: 4,
bodyAlignment: Alignment.bottomCenter,
imageAlignment: Alignment.topCenter,
imagePadding: const EdgeInsets.symmetric(vertical: 32),
contentMargin: const EdgeInsets.only(top: 32),
),
);
},
reverse: true,
),
],
onDone: () => _onIntroEnd(context),
onSkip: () => _onIntroEnd(context),
// You can override onSkip callback
//rtl: true, // Display as right-to-left
back: const Icon(Icons.arrow_back),
next: const Icon(
Icons.arrow_forward,
key: Key('nextPage'),
),
done: FilledButton(
onPressed: () {
_onIntroEnd(context);
},
child: Text(onboardingDoneButtonLabel(), style: const TextStyle(fontWeight: FontWeight.w600)),
),
dotsFlex: 1,
controlsPadding: const EdgeInsets.symmetric(vertical: 32),
dotsDecorator: DotsDecorator(
size: const Size.square(10.0),
activeSize: const Size(40.0, 10.0),
activeColor: Theme.of(context).colorScheme.primary,
color: Theme.of(context).colorScheme.tertiary,
spacing: const EdgeInsets.symmetric(horizontal: 3.0),
activeShape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(50.0)),
),
);
}
}
5 changes: 4 additions & 1 deletion lib/Frontend/translation_string_definitions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ String sequenceEditListDelayLabel(int howMany) => Intl.message(
//Actions Page
String actionsNoBluetooth() => Intl.message('Bluetooth is unavailable', name: 'actionsNoBluetooth', desc: 'Label on the actions page when bluetooth is unavailable');

String actionsNoBluetoothDescription() =>
Intl.message('Bluetooth is required to connect to Gear. Please turn on bluetooth in settings. Do not connect to gear while in your devices bluetooth settings.', name: 'actionsNoBluetoothDescription', desc: 'description on the actions page when bluetooth is unavailable');

String actionsCategoryCalm() => Intl.message('Calm and Relaxed', name: 'actionsCategoryCalm', desc: 'calm action group label');

String actionsCategoryFast() => Intl.message('Fast and Excited', name: 'actionsCategoryFast', desc: 'fast action group label');
Expand Down Expand Up @@ -310,7 +313,7 @@ String onboardingBluetoothDescription() => Intl.message("Bluetooth permission is

String onboardingBluetoothRequestButtonLabel() => Intl.message("Grant Permission", name: 'onboardingBluetoothRequestButtonLabel', desc: 'Label for the button to request bluetooth permission on the onboarding screen');

String onboardingBluetoothEnableButtonLabel() => Intl.message("Turn On Bluetooth", name: 'onboardingBluetoothEnableButtonLabel', desc: 'Label for the button to open bluetooth settings on the onboarding screen');
String onboardingBluetoothEnableButtonLabel() => Intl.message("Open Settings to turn On Bluetooth", name: 'onboardingBluetoothEnableButtonLabel', desc: 'Label for the button to open bluetooth settings on the onboarding screen');

String onboardingDoneButtonLabel() => Intl.message("Done", name: 'onboardingDoneButtonLabel', desc: 'Label for the button to close the onboarding screen');

Expand Down

0 comments on commit 27e2fd3

Please sign in to comment.