Skip to content

Commit

Permalink
Merge pull request #67 from trilliumlab/feature/material-only
Browse files Browse the repository at this point in the history
Remove platform widgets
  • Loading branch information
elliotnash authored Aug 13, 2024
2 parents e699d20 + 263f421 commit 45462c5
Show file tree
Hide file tree
Showing 49 changed files with 392 additions and 872 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ rendered icon, and [background.png](assets/icon/background.png) and
[foreground.png](assets/icon/foreground.png) are separated bg/fg layers
(used by android adaptive icons).

Custom icon symbols go in the [assets/icons](assets/icons) directory (svgs only). The icons are
Custom icon symbols go in the [assets/icons](assets/svg_icons) directory (svgs only). The icons are
loaded in flutter using a font file. To generate the font file and the dart icon class, run:

```bash
Expand Down
Binary file added assets/icons/compass.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
14 changes: 0 additions & 14 deletions lib/consts.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:forest_park_reports/model/camera_position.dart';
Expand All @@ -11,14 +10,7 @@ const kApiUrl = "https://forestpark.cecs.pdx.edu/staging/v1";
// const kApiUrl = "http://192.168.0.247:8000";
// const kApiUrl = "http://localhost:8000/";

// This is for development only.
// TODO Maybe move this over to the settings page or only set on debug
const kPlatformOverride = null;
// const kPlatformOverride = TargetPlatform.android;
// const kPlatformOverride = TargetPlatform.iOS;

final kMaterialAppPrimaryColor = Colors.green.shade700;
final kCupertinoAppPrimaryColor = CupertinoColors.systemGreen.highContrastColor;

// Allows a user to submit hazards and updates without appropriate proximity.
const bool kLocationOverrideEnabled = true;
Expand Down Expand Up @@ -58,9 +50,3 @@ const kBackgroundRequestPortName = "backgroundRequestPort";

// Uuid generator
const kUuidGen = Uuid();

// Colors
const kDialogColor = CupertinoDynamicColor.withBrightness(
color: Color(0xCCF2F2F2),
darkColor: Color(0xBF1E1E1E),
);
81 changes: 15 additions & 66 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
import 'package:forest_park_reports/provider/settings_provider.dart';
import 'package:forest_park_reports/util/offline_uploader.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
Expand Down Expand Up @@ -77,75 +74,27 @@ class _AppState extends ConsumerState<App> with WidgetsBindingObserver {
));
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);

// PlatformProvider is flutter_platform_widgets' provider, allowing us
// to use widgets that render in the style of the device's platform.
// Eg. cupertino on ios, and material 3 on android
return PlatformProvider(
initialPlatform: kDebugMode ? kPlatformOverride : null,
builder: (context) {
return _theme(
builder: (context) => PlatformApp(
title: 'Forest Park Reports',
home: HomeScreen(key: homeKey),
),
);
},
);
}

// here we build the apps theme
Widget _theme({required Widget Function(BuildContext context) builder}) {
// DynamicColorBuilder allows us to get the system theme on android, macos, and windows.
// On android the colorScheme will be the material you color palette,
// on macos and windows, this will be derived from the system accent color.
final materialLightTheme = ThemeData.from(
colorScheme: ColorScheme.fromSeed(
seedColor: kMaterialAppPrimaryColor,
brightness: Brightness.light,
)
);
final materialDarkTheme = ThemeData.from(
colorScheme: ColorScheme.fromSeed(
seedColor: kMaterialAppPrimaryColor,
brightness: Brightness.dark,
)
);

// Cupertino themes
final lightDefaultCupertinoTheme = CupertinoThemeData(brightness: Brightness.light, primaryColor: kCupertinoAppPrimaryColor);
final cupertinoLightTheme = MaterialBasedCupertinoThemeData(
materialTheme: materialLightTheme.copyWith(
cupertinoOverrideTheme: CupertinoThemeData(
final lightTheme = ThemeData.from(
colorScheme: ColorScheme.fromSeed(
seedColor: kMaterialAppPrimaryColor,
brightness: Brightness.light,
barBackgroundColor: lightDefaultCupertinoTheme.barBackgroundColor,
primaryColor: kCupertinoAppPrimaryColor,
textTheme: CupertinoTextThemeData(
navActionTextStyle: lightDefaultCupertinoTheme.textTheme.navActionTextStyle.copyWith(color: kCupertinoAppPrimaryColor)
),
),
),
dynamicSchemeVariant: DynamicSchemeVariant.rainbow,
)
);
final darkDefaultCupertinoTheme = CupertinoThemeData(brightness: Brightness.dark, primaryColor: kCupertinoAppPrimaryColor);
final cupertinoDarkTheme = MaterialBasedCupertinoThemeData(
materialTheme: materialDarkTheme.copyWith(
cupertinoOverrideTheme: CupertinoThemeData(
final darkTheme = ThemeData.from(
colorScheme: ColorScheme.fromSeed(
seedColor: kMaterialAppPrimaryColor,
brightness: Brightness.dark,
primaryColor: kCupertinoAppPrimaryColor,
barBackgroundColor: darkDefaultCupertinoTheme.barBackgroundColor,
textTheme: CupertinoTextThemeData(
navActionTextStyle: darkDefaultCupertinoTheme.textTheme.navActionTextStyle.copyWith(color: kCupertinoAppPrimaryColor)
),
),
),
dynamicSchemeVariant: DynamicSchemeVariant.rainbow,
)
);

return PlatformTheme(
return MaterialApp(
title: 'Trail Eyes',
themeMode: ref.watch(settingsProvider.select((s) => s.colorTheme)).value,
materialLightTheme: materialLightTheme,
materialDarkTheme: materialDarkTheme,
cupertinoLightTheme: cupertinoLightTheme,
cupertinoDarkTheme: cupertinoDarkTheme,
builder: builder,
theme: lightTheme,
darkTheme: darkTheme,
home: HomeScreen(key: homeKey),
);
}
}
5 changes: 2 additions & 3 deletions lib/model/hazard_type.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

enum HazardType {
tree("Fallen Tree", CupertinoIcons.tree),
tree("Fallen Tree", Icons.park_outlined),
flood("Flooded Trail", Icons.flood_rounded),
other("Other Hazard", CupertinoIcons.question_diamond_fill);
other("Other Hazard", Icons.help_outline_outlined);

const HazardType(this.displayName, this.icon);
final String displayName;
Expand Down
30 changes: 2 additions & 28 deletions lib/page/common/alert_banner.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/physics.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
import 'package:forest_park_reports/consts.dart';
import 'package:forest_park_reports/main.dart';
import 'package:forest_park_reports/util/outline_box_shadow.dart';
Expand Down Expand Up @@ -153,7 +151,7 @@ class _AlertBannerState extends State<_AlertBanner> with SingleTickerProviderSta
}
}

class _AlertBannerBackground extends PlatformWidgetBase {
class _AlertBannerBackground extends StatelessWidget {
final Widget child;

const _AlertBannerBackground({
Expand All @@ -162,31 +160,7 @@ class _AlertBannerBackground extends PlatformWidgetBase {
});

@override
Widget createCupertinoWidget(BuildContext context) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(kCupertinoAlertCornerRadius),
boxShadow: [
OutlineBoxShadow(
color: Colors.black.withOpacity(0.3),
blurRadius: 4,
),
],
),
child: CupertinoPopupSurface(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: kFabPadding,
vertical: kFabPadding,
),
child: child,
),
),
);
}

@override
Widget createMaterialWidget(BuildContext context) {
Widget build(BuildContext context) {
return Card(
child: Padding(
padding: const EdgeInsets.symmetric(
Expand Down
107 changes: 0 additions & 107 deletions lib/page/common/animated_app_bar_scaffold.dart

This file was deleted.

16 changes: 8 additions & 8 deletions lib/page/common/confirmation.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';

import 'package:flutter/material.dart';

/// Holds information for showing a confirmation dialog.
class ConfirmationInfo {
Expand All @@ -21,20 +21,20 @@ class ConfirmationInfo {
}

Future<bool> showConfirmationDialog(BuildContext context, ConfirmationInfo confirmation) async {
return await showPlatformDialog(
return await showDialog(
context: context,
builder: (context) => PlatformAlertDialog(
builder: (context) => AlertDialog(
title: Text(confirmation.title),
content: Text(confirmation.content),
actions: [
PlatformDialogAction(
child: PlatformText(confirmation.negative),
TextButton(
child: Text(confirmation.negative),
onPressed: () {
Navigator.of(context).pop(false);
},
),
PlatformDialogAction(
child: PlatformText(confirmation.affirmative),
TextButton(
child: Text(confirmation.affirmative),
onPressed: () {
Navigator.of(context).pop(true);
},
Expand Down
Loading

0 comments on commit 45462c5

Please sign in to comment.