Skip to content
This repository has been archived by the owner on Dec 21, 2024. It is now read-only.

Commit

Permalink
formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
lewislarsen committed Aug 23, 2024
1 parent 4267ba0 commit 7a6ce90
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 34 deletions.
5 changes: 3 additions & 2 deletions lib/lock_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ class LockProvider with ChangeNotifier {
} else {
return {
'success': false,
'message': 'Biometric authentication is not available on this device'
'message':
'Biometric authentication is not available on this device'
};
}
} on PlatformException catch (e) {
Expand Down Expand Up @@ -126,4 +127,4 @@ class LockProvider with ChangeNotifier {
await prefs.setInt('lockDurationMinutes', minutes);
notifyListeners();
}
}
}
30 changes: 20 additions & 10 deletions lib/lock_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ class LockScreen extends StatefulWidget {
final Widget child;
final AuthManager authManager;

const LockScreen({Key? key, required this.child, required this.authManager}) : super(key: key);
const LockScreen({Key? key, required this.child, required this.authManager})
: super(key: key);

@override
_LockScreenState createState() => _LockScreenState();
}

class _LockScreenState extends State<LockScreen> with WidgetsBindingObserver, TickerProviderStateMixin {
class _LockScreenState extends State<LockScreen>
with WidgetsBindingObserver, TickerProviderStateMixin {
bool _isChecking = true;
late AnimationController _lockIconController;
late Animation<double> _lockIconAnimation;
Expand All @@ -32,7 +34,8 @@ class _LockScreenState extends State<LockScreen> with WidgetsBindingObserver, Ti
duration: const Duration(milliseconds: 300),
vsync: this,
);
_lockIconAnimation = Tween<double>(begin: 0, end: 1).animate(_lockIconController);
_lockIconAnimation =
Tween<double>(begin: 0, end: 1).animate(_lockIconController);
}

@override
Expand Down Expand Up @@ -68,7 +71,9 @@ class _LockScreenState extends State<LockScreen> with WidgetsBindingObserver, Ti
if (_isChecking) {
return _buildLoadingScreen();
}
if (widget.authManager.isLoggedIn && lockProvider.isLockEnabled && lockProvider.isAppLocked) {
if (widget.authManager.isLoggedIn &&
lockProvider.isLockEnabled &&
lockProvider.isAppLocked) {
return _buildLockScreen(context, lockProvider);
}
return widget.child;
Expand Down Expand Up @@ -129,7 +134,9 @@ class _LockScreenState extends State<LockScreen> with WidgetsBindingObserver, Ti
return Transform.rotate(
angle: _lockIconAnimation.value * 2 * 3.14159,
child: HeroIcon(
_lockIconAnimation.value < 0.5 ? HeroIcons.lockClosed : HeroIcons.lockOpen,
_lockIconAnimation.value < 0.5
? HeroIcons.lockClosed
: HeroIcons.lockOpen,
size: 48,
color: theme.colorScheme.primary,
),
Expand All @@ -156,9 +163,11 @@ class _LockScreenState extends State<LockScreen> with WidgetsBindingObserver, Ti
backgroundColor: theme.colorScheme.primary.withOpacity(0.1),
child: user?.personalInfo.avatarUrl == null
? Text(
user?.personalInfo.firstName.substring(0, 1).toUpperCase() ?? 'U',
style: TextStyle(fontSize: 48, color: theme.colorScheme.primary),
)
user?.personalInfo.firstName.substring(0, 1).toUpperCase() ??
'U',
style:
TextStyle(fontSize: 48, color: theme.colorScheme.primary),
)
: null,
),
);
Expand Down Expand Up @@ -267,7 +276,8 @@ class _LockScreenState extends State<LockScreen> with WidgetsBindingObserver, Ti
);
}

Future<void> _verifyPin(BuildContext context, LockProvider lockProvider, String enteredPin) async {
Future<void> _verifyPin(BuildContext context, LockProvider lockProvider,
String enteredPin) async {
if (await lockProvider.checkPin(enteredPin)) {
await _animateUnlock();
lockProvider.unlockApp();
Expand All @@ -284,4 +294,4 @@ class _LockScreenState extends State<LockScreen> with WidgetsBindingObserver, Ti
await Future.delayed(const Duration(milliseconds: 300));
_lockIconController.reset();
}
}
}
39 changes: 26 additions & 13 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class ThemeProvider with ChangeNotifier {

Future<void> _loadPreferences() async {
_prefs = await SharedPreferences.getInstance();
_themeMode = ThemeMode.values[_prefs.getInt(_themeAutoKey) ?? ThemeMode.auto.index];
_themeMode =
ThemeMode.values[_prefs.getInt(_themeAutoKey) ?? ThemeMode.auto.index];
_updateThemeMode();
}

Expand All @@ -71,7 +72,8 @@ class ThemeProvider with ChangeNotifier {
if (_themeMode == ThemeMode.auto) {
setThemeMode(_isDarkMode ? ThemeMode.light : ThemeMode.dark);
} else {
setThemeMode(_themeMode == ThemeMode.light ? ThemeMode.dark : ThemeMode.light);
setThemeMode(
_themeMode == ThemeMode.light ? ThemeMode.dark : ThemeMode.light);
}
}

Expand All @@ -84,9 +86,12 @@ class ThemeProvider with ChangeNotifier {
cardColor: Colors.grey[900],
fontFamily: 'Poppins',
textTheme: const TextTheme(
displayLarge: TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold, color: Colors.white),
titleLarge: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500, color: Colors.white),
bodyMedium: TextStyle(fontSize: 14.0, fontFamily: 'Poppins', color: Colors.white70),
displayLarge: TextStyle(
fontSize: 24.0, fontWeight: FontWeight.bold, color: Colors.white),
titleLarge: TextStyle(
fontSize: 20.0, fontWeight: FontWeight.w500, color: Colors.white),
bodyMedium: TextStyle(
fontSize: 14.0, fontFamily: 'Poppins', color: Colors.white70),
),
colorScheme: const ColorScheme.dark(
primary: Colors.white,
Expand Down Expand Up @@ -125,9 +130,12 @@ class ThemeProvider with ChangeNotifier {
cardColor: Colors.grey[100],
fontFamily: 'Poppins',
textTheme: const TextTheme(
displayLarge: TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold, color: Colors.black),
titleLarge: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500, color: Colors.black),
bodyMedium: TextStyle(fontSize: 14.0, fontFamily: 'Poppins', color: Colors.black87),
displayLarge: TextStyle(
fontSize: 24.0, fontWeight: FontWeight.bold, color: Colors.black),
titleLarge: TextStyle(
fontSize: 20.0, fontWeight: FontWeight.w500, color: Colors.black),
bodyMedium: TextStyle(
fontSize: 14.0, fontFamily: 'Poppins', color: Colors.black87),
),
colorScheme: const ColorScheme.light(
primary: Colors.black,
Expand Down Expand Up @@ -210,8 +218,10 @@ void main() async {
final backupTaskLogProvider = BackupTaskLogProvider(authManager: authManager);
final lockProvider = LockProvider();
final remoteServerProvider = RemoteServerProvider(authManager: authManager);
final backupDestinationProvider = BackupDestinationProvider(authManager: authManager);
final notificationStreamProvider = NotificationStreamProvider(authManager: authManager);
final backupDestinationProvider =
BackupDestinationProvider(authManager: authManager);
final notificationStreamProvider =
NotificationStreamProvider(authManager: authManager);
final tagProvider = TagProvider(authManager: authManager);

await deviceInfoProvider.initializeDeviceInfo();
Expand Down Expand Up @@ -344,13 +354,16 @@ class _MainNavigationWrapperState extends State<MainNavigationWrapper> {
icon: Icon(
themeProvider.themeMode == ThemeMode.auto
? Icons.brightness_auto
: (themeProvider.isDarkMode ? Icons.dark_mode : Icons.light_mode),
: (themeProvider.isDarkMode
? Icons.dark_mode
: Icons.light_mode),
color: Colors.white,
),
onSelected: (ThemeMode result) {
themeProvider.setThemeMode(result);
},
itemBuilder: (BuildContext context) => <PopupMenuEntry<ThemeMode>>[
itemBuilder: (BuildContext context) =>
<PopupMenuEntry<ThemeMode>>[
const PopupMenuItem<ThemeMode>(
value: ThemeMode.light,
child: Text('Light Mode'),
Expand Down Expand Up @@ -380,4 +393,4 @@ class _MainNavigationWrapperState extends State<MainNavigationWrapper> {
},
);
}
}
}
26 changes: 17 additions & 9 deletions lib/theme_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class ThemeProvider with ChangeNotifier {

Future<void> _loadPreferences() async {
_prefs = await SharedPreferences.getInstance();
_themeMode = ThemeMode.values[_prefs.getInt(_themeAutoKey) ?? ThemeMode.auto.index];
_themeMode =
ThemeMode.values[_prefs.getInt(_themeAutoKey) ?? ThemeMode.auto.index];
_updateThemeMode();
}

Expand All @@ -46,7 +47,8 @@ class ThemeProvider with ChangeNotifier {
if (_themeMode == ThemeMode.auto) {
setThemeMode(_isDarkMode ? ThemeMode.light : ThemeMode.dark);
} else {
setThemeMode(_themeMode == ThemeMode.light ? ThemeMode.dark : ThemeMode.light);
setThemeMode(
_themeMode == ThemeMode.light ? ThemeMode.dark : ThemeMode.light);
}
}

Expand All @@ -63,9 +65,12 @@ class ThemeProvider with ChangeNotifier {
cardColor: Colors.grey[900],
fontFamily: 'Poppins',
textTheme: const TextTheme(
displayLarge: TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold, color: Colors.white),
titleLarge: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500, color: Colors.white),
bodyMedium: TextStyle(fontSize: 14.0, fontFamily: 'Poppins', color: Colors.white70),
displayLarge: TextStyle(
fontSize: 24.0, fontWeight: FontWeight.bold, color: Colors.white),
titleLarge: TextStyle(
fontSize: 20.0, fontWeight: FontWeight.w500, color: Colors.white),
bodyMedium: TextStyle(
fontSize: 14.0, fontFamily: 'Poppins', color: Colors.white70),
),
colorScheme: const ColorScheme.dark(
primary: Colors.white,
Expand Down Expand Up @@ -104,9 +109,12 @@ class ThemeProvider with ChangeNotifier {
cardColor: Colors.grey[100],
fontFamily: 'Poppins',
textTheme: const TextTheme(
displayLarge: TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold, color: Colors.black),
titleLarge: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500, color: Colors.black),
bodyMedium: TextStyle(fontSize: 14.0, fontFamily: 'Poppins', color: Colors.black87),
displayLarge: TextStyle(
fontSize: 24.0, fontWeight: FontWeight.bold, color: Colors.black),
titleLarge: TextStyle(
fontSize: 20.0, fontWeight: FontWeight.w500, color: Colors.black),
bodyMedium: TextStyle(
fontSize: 14.0, fontFamily: 'Poppins', color: Colors.black87),
),
colorScheme: const ColorScheme.light(
primary: Colors.black,
Expand Down Expand Up @@ -137,4 +145,4 @@ class ThemeProvider with ChangeNotifier {
hintStyle: const TextStyle(color: Colors.black54),
),
);
}
}

0 comments on commit 7a6ce90

Please sign in to comment.