added swiping
add swiping
This commit is contained in:
parent
2ff4d44d25
commit
127a09b597
10 changed files with 154 additions and 82 deletions
|
@ -7,6 +7,7 @@ abstract class ConstColours {
|
|||
|
||||
static const white = Colors.white;
|
||||
static const black = Colors.black;
|
||||
static const transparent = Colors.transparent;
|
||||
}
|
||||
|
||||
abstract class ConstThemes {
|
||||
|
|
|
@ -4,11 +4,12 @@ import 'dart:io';
|
|||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:internet_connection_checker/internet_connection_checker.dart';
|
||||
import 'package:mc_gallery/features/core/services/logging_service.dart';
|
||||
|
||||
import '/locator.dart';
|
||||
|
||||
/// Used to observe the current connection type.
|
||||
class ConnectionService {
|
||||
class ConnectionService with LoggingService {
|
||||
ConnectionService({
|
||||
required Connectivity connectivity,
|
||||
required InternetConnectionChecker internetConnectionChecker,
|
||||
|
@ -80,7 +81,9 @@ class ConnectionService {
|
|||
}
|
||||
});
|
||||
_isInitialized.complete();
|
||||
} catch (error, stackTrace) {}
|
||||
} catch (error, stackTrace) {
|
||||
handle(error, stackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> dispose() async {
|
||||
|
@ -109,7 +112,9 @@ class ConnectionService {
|
|||
await listener(
|
||||
connectivityResult: connectivityResult, hasInternet: await hasInternetConnection);
|
||||
});
|
||||
} catch (error, stackTrace) {}
|
||||
} catch (error, stackTrace) {
|
||||
handle(error, stackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> removeListener({required String tag}) async {
|
||||
|
@ -118,13 +123,17 @@ class ConnectionService {
|
|||
if (subscription != null) {
|
||||
await subscription.cancel();
|
||||
} else {}
|
||||
} catch (error, stackTrace) {}
|
||||
} catch (error, stackTrace) {
|
||||
handle(error, stackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onConnectivityChanged(ConnectivityResult connectivityResult) async {
|
||||
try {
|
||||
_connectivityResult = connectivityResult;
|
||||
} catch (error, stackTrace) {}
|
||||
} catch (error, stackTrace) {
|
||||
handle(error, stackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
static ConnectionService get locate => Locator.locate();
|
||||
|
|
|
@ -1,36 +1,33 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:mc_gallery/features/core/services/logging_service.dart';
|
||||
import 'package:mc_gallery/locator.dart';
|
||||
|
||||
class OverlayService {
|
||||
const OverlayService({
|
||||
OverlayService({
|
||||
required LoggingService loggingService,
|
||||
}) : _loggingService = loggingService;
|
||||
|
||||
final LoggingService _loggingService;
|
||||
|
||||
final Map<int, OverlayEntry> _overlayEntryMap = const {};
|
||||
final Map<int, OverlayEntry> _overlayEntryMap = {};
|
||||
|
||||
Future<void> playOverlayEntry({
|
||||
required BuildContext context,
|
||||
void insertOverlayEntry(
|
||||
BuildContext context, {
|
||||
required String tag,
|
||||
required OverlayEntry overlayEntry,
|
||||
}) async {
|
||||
try {
|
||||
_overlayEntryMap[overlayEntry.hashCode] = overlayEntry;
|
||||
Overlay.of(
|
||||
context,
|
||||
rootOverlay: true,
|
||||
)!
|
||||
.insert(overlayEntry);
|
||||
}) {
|
||||
_overlayEntryMap.addEntries([MapEntry(tag.hashCode, overlayEntry)]);
|
||||
|
||||
if (overlayEntry.mounted) overlayEntry.remove();
|
||||
Overlay.of(context, rootOverlay: true)?.insert(overlayEntry);
|
||||
_loggingService.info('Overlay inserted with tag: $tag');
|
||||
}
|
||||
|
||||
_overlayEntryMap.remove(overlayEntry.hashCode);
|
||||
} catch (error, stackTrace) {
|
||||
_loggingService.handle(error, stackTrace);
|
||||
}
|
||||
void removeOverlayEntry({
|
||||
required String tag,
|
||||
}) {
|
||||
_overlayEntryMap[tag.hashCode]?.remove();
|
||||
_overlayEntryMap.remove(tag.hashCode);
|
||||
_loggingService.info('Overlay removed with tag: $tag');
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue