Skip to content

Commit

Permalink
improve stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
pyrossh committed Aug 16, 2023
1 parent 3386df2 commit f5009ba
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 93 deletions.
25 changes: 0 additions & 25 deletions lib/dialog.dart
Original file line number Diff line number Diff line change
@@ -1,31 +1,6 @@
import "dart:ui";
import "package:flutter/material.dart";

Future<T?> showCustomDialog<T>(BuildContext context, Widget child) {
return showGeneralDialog<T>(
context: context,
barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
barrierDismissible: true,
barrierColor: Colors.black.withOpacity(0.5),
transitionDuration: Duration.zero,
transitionBuilder: (_, anim, __, child) {
return FadeTransition(
opacity: anim,
child: child,
);
},
pageBuilder: (_, __, ___) {
return Container(
// width: MediaQuery.of(context).size.width - 10,
// height: MediaQuery.of(context).size.height - 80,
color: Colors.white,
margin: const EdgeInsets.symmetric(horizontal: 250, vertical: 0),
child: child,
);
},
);
}

showAlert(BuildContext context, String title, String message) {
showDialog(
context: context,
Expand Down
28 changes: 20 additions & 8 deletions lib/state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import "package:only_bible_app/screens/chapter_view_screen.dart";
import 'package:only_bible_app/dialog.dart';
import "package:only_bible_app/models.dart";
import "package:only_bible_app/widgets/actions_sheet.dart";
import "package:only_bible_app/widgets/scaffold_menu.dart";
import "package:only_bible_app/widgets/settings_sheet.dart";
import "package:provider/provider.dart";
import "package:shared_preferences/shared_preferences.dart";
Expand Down Expand Up @@ -133,14 +134,25 @@ class AppModel extends ChangeNotifier {
}

showSettings(BuildContext context) {
showModalBottomSheet(
context: context,
isDismissible: true,
enableDrag: true,
showDragHandle: true,
useSafeArea: true,
builder: (context) => const SettingsSheet(),
);
// if (isWide(context)) {
// Navigator.of(context).push(
// createNoTransitionPageRoute(
// const ScaffoldMenu(
// backgroundColor: Color(0xFFF2F2F7),
// child: SettingsSheet(),
// ),
// ),
// );
// } else {
showModalBottomSheet(
context: context,
isDismissible: true,
enableDrag: true,
showDragHandle: true,
useSafeArea: true,
builder: (context) => const SettingsSheet(),
);
// }
}

showActions(BuildContext context) {
Expand Down
41 changes: 0 additions & 41 deletions lib/widgets/more_button.dart

This file was deleted.

5 changes: 3 additions & 2 deletions lib/widgets/scaffold_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import "package:only_bible_app/state.dart";

class ScaffoldMenu extends StatelessWidget {
final Widget child;
final Color? backgroundColor;

const ScaffoldMenu({super.key, required this.child});
const ScaffoldMenu({super.key, required this.child, this.backgroundColor});

@override
Widget build(BuildContext context) {
Expand All @@ -15,7 +16,7 @@ class ScaffoldMenu extends StatelessWidget {
color: Colors.black.withOpacity(0.7),
margin: EdgeInsets.only(left: isWide(context) ? 250 : 0),
child: Container(
color: Theme.of(context).colorScheme.background,
color: backgroundColor ?? Theme.of(context).colorScheme.background,
margin: EdgeInsets.only(right: isWide(context) ? 650 : 0),
child: child,
),
Expand Down
9 changes: 3 additions & 6 deletions lib/widgets/settings_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@ class SettingsSheet extends StatelessWidget {
final iconColor = Theme.of(context).textTheme.bodyMedium!.color;
return Column(
children: [
const Padding(
padding: EdgeInsets.only(bottom: 15),
Padding(
padding: const EdgeInsets.only(bottom: 20),
child: Text(
"Settings",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w500,
),
style: Theme.of(context).textTheme.headlineMedium,
),
),
Expanded(
Expand Down
35 changes: 24 additions & 11 deletions lib/widgets/sliver_tile_grid.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
import "package:flutter/material.dart";
import "package:only_bible_app/state.dart";

enum ListType { small, large }
enum ListType {
small,
large;

int crossAxisCount() {
switch (this) {
case ListType.small:
return 5;
case ListType.large:
return 2;
}
}

double childAspectRatio(bool isDesktop) {
switch (this) {
case ListType.small:
return isDesktop ? 2.33 : 1.4;
case ListType.large:
return isDesktop ? 5 : 4;
}
}
}

class SliverTileGrid extends StatelessWidget {
final ListType listType;
Expand All @@ -16,18 +37,10 @@ class SliverTileGrid extends StatelessWidget {
return SliverPadding(
padding: const EdgeInsets.symmetric(horizontal: 20),
sliver: SliverGrid.count(
crossAxisCount: listType == ListType.large
? 2
: isDesktop
? 6
: 5,
crossAxisCount: listType.crossAxisCount(),
crossAxisSpacing: spacing,
mainAxisSpacing: spacing,
childAspectRatio: listType == ListType.large
? 4
: isDesktop
? 1.6
: 1.5,
childAspectRatio: listType.childAspectRatio(isDesktop),
children: children,
),
);
Expand Down

0 comments on commit f5009ba

Please sign in to comment.