Skip to content

Commit

Permalink
fix: unknown font glyph boxes
Browse files Browse the repository at this point in the history
by setting global and per-style fallback
closes #183
  • Loading branch information
MSOB7YY committed May 8, 2024
1 parent d7afa9a commit 4af9640
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 93 deletions.
11 changes: 11 additions & 0 deletions lib/core/themes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class AppThemes {
light ? const Color.fromARGB(255, 255, 255, 255) : pitchGrey,
);

const fontFallback = ['sans-serif', 'Roboto'];

return ThemeData(
brightness: light ? Brightness.light : Brightness.dark,
useMaterial3: true,
Expand Down Expand Up @@ -142,41 +144,50 @@ class AppThemes {
bodyMedium: TextStyle(
fontSize: 14.0.multipliedFontScale,
fontWeight: FontWeight.normal,
fontFamilyFallback: fontFallback,
),
bodySmall: TextStyle(
fontSize: 14.0.multipliedFontScale,
fontWeight: FontWeight.normal,
fontFamilyFallback: fontFallback,
),
titleSmall: TextStyle(
fontSize: 14.0.multipliedFontScale,
fontWeight: FontWeight.w600,
fontFamilyFallback: fontFallback,
),
titleLarge: TextStyle(
fontSize: 20.0.multipliedFontScale,
fontWeight: FontWeight.w600,
fontFamilyFallback: fontFallback,
),
displayLarge: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 17.0.multipliedFontScale,
color: light ? Colors.black.withAlpha(160) : Colors.white.withAlpha(210),
fontFamilyFallback: fontFallback,
),
displayMedium: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 15.0.multipliedFontScale,
color: light ? Colors.black.withAlpha(150) : Colors.white.withAlpha(180),
fontFamilyFallback: fontFallback,
),
displaySmall: TextStyle(
fontWeight: FontWeight.w400,
fontSize: 13.0.multipliedFontScale,
color: light ? Colors.black.withAlpha(120) : Colors.white.withAlpha(170),
fontFamilyFallback: fontFallback,
),
headlineMedium: TextStyle(
fontWeight: FontWeight.normal,
fontSize: 14.0.multipliedFontScale,
fontFamilyFallback: fontFallback,
),
headlineSmall: TextStyle(
fontWeight: FontWeight.normal,
fontSize: 14.0.multipliedFontScale,
fontFamilyFallback: fontFallback,
),
),
);
Expand Down
191 changes: 98 additions & 93 deletions lib/ui/pages/main_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,108 +91,113 @@ class MainPage extends StatelessWidget {
},
),
),
body: Stack(
alignment: Alignment.bottomCenter,
children: [
Obx(() {
return !settings.enableMiniplayerParallaxEffect.value
? main
: AnimatedBuilder(
animation: animation,
child: main,
builder: (context, child) {
return Visibility(
maintainState: true,
visible: animation.value < 1, // not expanded/queue
child: Transform.scale(
scale: 1 - (animation.value * 0.05),
child: child,
),
);
},
);
}),

/// Search Box
Positioned.fill(
child: Obx(
() => AnimatedSwitcher(
duration: const Duration(milliseconds: 400),
child: ScrollSearchController.inst.isGlobalSearchMenuShown.value ? const SearchPage() : null,
),
),
),
body: DefaultTextStyle(
style: const TextStyle(
fontFamilyFallback: ['sans-serif', 'Roboto'],
),
child: Stack(
alignment: Alignment.bottomCenter,
children: [
Obx(() {
return !settings.enableMiniplayerParallaxEffect.value
? main
: AnimatedBuilder(
animation: animation,
child: main,
builder: (context, child) {
return Visibility(
maintainState: true,
visible: animation.value < 1, // not expanded/queue
child: Transform.scale(
scale: 1 - (animation.value * 0.05),
child: child,
),
);
},
);
}),

// -- Settings Search Box
Positioned.fill(
child: Obx(
() => AnimatedSwitcher(
duration: const Duration(milliseconds: 400),
child: SettingsSearchController.inst.canShowSearch ? const SettingsSearchPage() : null,
/// Search Box
Positioned.fill(
child: Obx(
() => AnimatedSwitcher(
duration: const Duration(milliseconds: 400),
child: ScrollSearchController.inst.isGlobalSearchMenuShown.value ? const SearchPage() : null,
),
),
),
),

Obx(
() {
final shouldHide = Dimensions.inst.shouldHideFAB;
return AnimatedPositioned(
key: const Key('fab_active'),
right: 12.0,
bottom: (MediaQuery.viewInsetsOf(context).bottom - MediaQuery.viewPaddingOf(context).bottom - kBottomNavigationBarHeight + 8.0)
.withMinimum(Dimensions.inst.globalBottomPaddingEffective),
duration: const Duration(milliseconds: 300),
curve: Curves.fastEaseInToSlowEaseOut,
child: AnimatedSwitcher(
// -- Settings Search Box
Positioned.fill(
child: Obx(
() => AnimatedSwitcher(
duration: const Duration(milliseconds: 400),
child: shouldHide
? const SizedBox(key: Key('fab_dummy'))
: FloatingActionButton(
tooltip: ScrollSearchController.inst.isGlobalSearchMenuShown.value ? lang.CLEAR : settings.floatingActionButton.value.toText(),
backgroundColor: Color.alphaBlend(CurrentColor.inst.currentColorScheme.withOpacity(0.7), context.theme.cardColor),
onPressed: () {
final fab = settings.floatingActionButton.value;
final forceSearch = ScrollSearchController.inst.isGlobalSearchMenuShown.value;
if (forceSearch || fab == FABType.search) {
ScrollSearchController.inst.toggleSearchMenu();
ScrollSearchController.inst.searchBarKey.currentState?.openCloseSearchBar();
} else if (fab == FABType.shuffle || fab == FABType.play) {
Player.inst.playOrPause(0, SelectedTracksController.inst.currentAllTracks, QueueSource.allTracks, shuffle: fab == FABType.shuffle);
}
},
child: Icon(
ScrollSearchController.inst.isGlobalSearchMenuShown.value ? Broken.search_status_1 : settings.floatingActionButton.value.toIcon(),
color: const Color.fromRGBO(255, 255, 255, 0.8),
),
),
child: SettingsSearchController.inst.canShowSearch ? const SettingsSearchPage() : null,
),
);
},
),
),
),

/// Bottom Glow/Shadow
Obx(
() => AnimatedSwitcher(
duration: const Duration(milliseconds: 600),
child: Player.inst.currentQueue.isNotEmpty || (Player.inst.currentQueueYoutube.isNotEmpty && !settings.youtubeStyleMiniplayer.value)
? Container(
key: const Key('actualglow'),
height: 28.0,
transform: Matrix4.translationValues(0, 8.0, 0),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: context.theme.scaffoldBackgroundColor,
spreadRadius: 4.0,
blurRadius: 8.0,
Obx(
() {
final shouldHide = Dimensions.inst.shouldHideFAB;
return AnimatedPositioned(
key: const Key('fab_active'),
right: 12.0,
bottom: (MediaQuery.viewInsetsOf(context).bottom - MediaQuery.viewPaddingOf(context).bottom - kBottomNavigationBarHeight + 8.0)
.withMinimum(Dimensions.inst.globalBottomPaddingEffective),
duration: const Duration(milliseconds: 300),
curve: Curves.fastEaseInToSlowEaseOut,
child: AnimatedSwitcher(
duration: const Duration(milliseconds: 400),
child: shouldHide
? const SizedBox(key: Key('fab_dummy'))
: FloatingActionButton(
tooltip: ScrollSearchController.inst.isGlobalSearchMenuShown.value ? lang.CLEAR : settings.floatingActionButton.value.toText(),
backgroundColor: Color.alphaBlend(CurrentColor.inst.currentColorScheme.withOpacity(0.7), context.theme.cardColor),
onPressed: () {
final fab = settings.floatingActionButton.value;
final forceSearch = ScrollSearchController.inst.isGlobalSearchMenuShown.value;
if (forceSearch || fab == FABType.search) {
ScrollSearchController.inst.toggleSearchMenu();
ScrollSearchController.inst.searchBarKey.currentState?.openCloseSearchBar();
} else if (fab == FABType.shuffle || fab == FABType.play) {
Player.inst.playOrPause(0, SelectedTracksController.inst.currentAllTracks, QueueSource.allTracks, shuffle: fab == FABType.shuffle);
}
},
child: Icon(
ScrollSearchController.inst.isGlobalSearchMenuShown.value ? Broken.search_status_1 : settings.floatingActionButton.value.toIcon(),
color: const Color.fromRGBO(255, 255, 255, 0.8),
),
),
],
),
)
: const SizedBox(key: Key('emptyglow')),
),
);
},
),
)
],

/// Bottom Glow/Shadow
Obx(
() => AnimatedSwitcher(
duration: const Duration(milliseconds: 600),
child: Player.inst.currentQueue.isNotEmpty || (Player.inst.currentQueueYoutube.isNotEmpty && !settings.youtubeStyleMiniplayer.value)
? Container(
key: const Key('actualglow'),
height: 28.0,
transform: Matrix4.translationValues(0, 8.0, 0),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: context.theme.scaffoldBackgroundColor,
spreadRadius: 4.0,
blurRadius: 8.0,
),
],
),
)
: const SizedBox(key: Key('emptyglow')),
),
)
],
),
),
bottomNavigationBar: Obx(
() => !settings.enableBottomNavBar.value
Expand Down

0 comments on commit 4af9640

Please sign in to comment.