Skip to content

Commit

Permalink
Reload actions when glowtip detected
Browse files Browse the repository at this point in the history
  • Loading branch information
Codel1417 committed Jun 9, 2024
1 parent 78fb9ca commit 7d8df92
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 77 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ Theres so many improvements over our old app - heres the headlines
- Added warnings for outdated gear to Custom Actions and Joystick
- UI/UX changes to selecting actions for triggers to reduce confusion
- Fix bug where trigger doesn't activate after accepting permission

### V 1.0.3

- Changed trigger select button to be more visible
- Reload actions when glowtip is found
159 changes: 82 additions & 77 deletions lib/Frontend/pages/actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,88 +49,93 @@ class _ActionPageBuilderState extends ConsumerState<ActionPageBuilder> {
return MultiValueListenableBuilder(
valueListenables: knownDevices.isEmpty ? [ValueNotifier(ConnectivityState.disconnected)] : knownDevices.values.map((e) => e.deviceConnectionState).toList(),
builder: (BuildContext context, List<dynamic> values, Widget? child) {
Map<ActionCategory, Set<BaseAction>> actionsCatMap = ref.read(getAvailableActionsProvider);
List<ActionCategory> catList = actionsCatMap.keys.toList();
return AnimatedCrossFade(
firstChild: const Home(),
secondChild: MultiListenableBuilder(
builder: (BuildContext context, Widget? child) {
return ListView(
shrinkWrap: true,
children: [
AnimatedCrossFade(
firstChild: PageInfoCard(
text: actionsFavoriteTip(),
),
secondChild: GridView.builder(
return MultiValueListenableBuilder(
builder: (context, values, child) {
Map<ActionCategory, Set<BaseAction>> actionsCatMap = ref.read(getAvailableActionsProvider);
List<ActionCategory> catList = actionsCatMap.keys.toList();
return AnimatedCrossFade(
firstChild: const Home(),
secondChild: MultiListenableBuilder(
builder: (BuildContext context, Widget? child) {
return ListView(
shrinkWrap: true,
children: [
AnimatedCrossFade(
firstChild: PageInfoCard(
text: actionsFavoriteTip(),
),
secondChild: GridView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(maxCrossAxisExtent: largerCards ? 250 : 125),
itemCount: actionsCatMap.values.flattened
.where(
(element) => ref.watch(favoriteActionsProvider).any((favorite) => favorite.actionUUID == element.uuid),
)
.length,
itemBuilder: (BuildContext context, int index) {
BaseAction baseAction = actionsCatMap.values.flattened
.where(
(element) => ref.watch(favoriteActionsProvider).any((favorite) => favorite.actionUUID == element.uuid),
)
.toList()[index];
return getActionCard(index, knownDevices, baseAction, largerCards);
},
),
crossFadeState: actionsCatMap.values.flattened.where((element) => ref.read(favoriteActionsProvider.notifier).contains(element)).isEmpty ? CrossFadeState.showFirst : CrossFadeState.showSecond,
duration: animationTransitionDuration),
ListView.builder(
shrinkWrap: true,
itemCount: catList.length,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(maxCrossAxisExtent: largerCards ? 250 : 125),
itemCount: actionsCatMap.values.flattened
.where(
(element) => ref.watch(favoriteActionsProvider).any((favorite) => favorite.actionUUID == element.uuid),
)
.length,
itemBuilder: (BuildContext context, int index) {
BaseAction baseAction = actionsCatMap.values.flattened
.where(
(element) => ref.watch(favoriteActionsProvider).any((favorite) => favorite.actionUUID == element.uuid),
)
.toList()[index];
return getActionCard(index, knownDevices, baseAction, largerCards);
},
),
crossFadeState: actionsCatMap.values.flattened.where((element) => ref.read(favoriteActionsProvider.notifier).contains(element)).isEmpty ? CrossFadeState.showFirst : CrossFadeState.showSecond,
duration: animationTransitionDuration),
ListView.builder(
shrinkWrap: true,
itemCount: catList.length,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (BuildContext context, int categoryIndex) {
List<BaseAction> actionsForCat = actionsCatMap.values.toList()[categoryIndex].toList();
return FadeIn(
delay: Duration(milliseconds: 100 * categoryIndex),
child: ListView(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
children: [
Center(
child: Text(
catList[categoryIndex].friendly,
style: Theme.of(context).textTheme.titleLarge,
),
),
GridView.builder(
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(maxCrossAxisExtent: largerCards ? 250 : 125),
itemBuilder: (BuildContext context, int categoryIndex) {
List<BaseAction> actionsForCat = actionsCatMap.values.toList()[categoryIndex].toList();
return FadeIn(
delay: Duration(milliseconds: 100 * categoryIndex),
child: ListView(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: actionsForCat.length,
itemBuilder: (BuildContext context, int actionIndex) {
return MultiValueListenableBuilder(
valueListenables: knownDevices.values
.where(
(element) => actionsForCat[actionIndex].deviceCategory.contains(element.baseDeviceDefinition.deviceType),
)
.map((e) => e.deviceState)
.toList(),
builder: (BuildContext context, List<dynamic> values, Widget? child) {
return getActionCard(actionIndex, knownDevices, actionsForCat[actionIndex], largerCards);
children: [
Center(
child: Text(
catList[categoryIndex].friendly,
style: Theme.of(context).textTheme.titleLarge,
),
),
GridView.builder(
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(maxCrossAxisExtent: largerCards ? 250 : 125),
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: actionsForCat.length,
itemBuilder: (BuildContext context, int actionIndex) {
return MultiValueListenableBuilder(
valueListenables: knownDevices.values
.where(
(element) => actionsForCat[actionIndex].deviceCategory.contains(element.baseDeviceDefinition.deviceType),
)
.map((e) => e.deviceState)
.toList(),
builder: (BuildContext context, List<dynamic> values, Widget? child) {
return getActionCard(actionIndex, knownDevices, actionsForCat[actionIndex], largerCards);
},
);
},
);
},
)
],
),
);
},
),
],
);
},
notifiers: knownDevices.isNotEmpty ? knownDevices.values.map((e) => e.baseStoredDevice).toList() : [ChangeNotifier()],
),
crossFadeState: actionsCatMap.isNotEmpty ? CrossFadeState.showSecond : CrossFadeState.showFirst,
duration: animationTransitionDuration,
)
],
),
);
},
),
],
);
},
notifiers: knownDevices.isNotEmpty ? knownDevices.values.map((e) => e.baseStoredDevice).toList() : [ChangeNotifier()],
),
crossFadeState: actionsCatMap.isNotEmpty ? CrossFadeState.showSecond : CrossFadeState.showFirst,
duration: animationTransitionDuration,
);
},
valueListenables: knownDevices.isEmpty ? [ValueNotifier(false)] : knownDevices.values.map((e) => e.hasGlowtip).toList(),
);
},
);
Expand Down

0 comments on commit 7d8df92

Please sign in to comment.