RichieBooksBook

Objective-C

@interface RichieBooksBook : NSObject

-(nonnull instancetype) init NS_UNAVAILABLE;

@property (nonatomic, readonly, nonnull) MaggioGuid *guid;
@property (nonatomic, readonly) NSInteger version; //!< Version number of downloaded book instance. Book can be modified on server and that will increment version number. The version number is zero when book hasn't been downloaded. Zero is not a valid version number.

@property (nonatomic, readonly) RichieBooksBookPresentationState presentationState;
@property (nonatomic, readonly) RichieBooksBookDiskState diskState;
@property (nonatomic, readonly, nullable) RichieBooksBookLoadingState *loadingState; //!< @p nil if loading is not in progress.

@property (nonatomic, readonly, nullable) NSDate *modificationDate;
-(BOOL) touchMetadata;

-(void) addListener:(nonnull id<RichieBooksBookListener>)listener; //!< @note Listeners are held weakly.
-(void) removeListener:(nonnull id<RichieBooksBookListener>)listener;

@end

Swift

class RichieBooksBook : NSObject

Undocumented

Loading

Presentation

  • If presentationState is Presentable, this method will call completion block immediately.

    @returns NO if presentation cannot be started, otherwise YES.

    Declaration

    Objective-C

    - (BOOL)prepareForPresentationInWindowSize:(CGSize)windowSize
                                    completion:
                                        (void (^_Nonnull)(BOOL, NSError *_Nullable))
                                            completion;

    Swift

    func prepareForPresentation(inWindowSize windowSize: CGSize, completion: @escaping (Bool, (any Error)?) -> Void) -> Bool
  • Presents a view controller (from @p presentingViewController ) for reading this book.

    If @p transitionStartSourceView is given, transition animation tries to animate nicely from the view to the presented state. @p currentlyDisplayedImage can be given, if one exists naturally (for example, @p transitionStartSourceView is a UIImageView with correct aspect ratio), to avoid explicit snapshot of the view. @p transitionStartSourceView must be in presentingViewController.view’s view hiearchy.

    Declaration

    Objective-C

    - (BOOL)
        presentFromViewController:
            (nonnull UIViewController *)presentingViewController
                       adSlotName:(nullable NSString *)adSlotName
                   eventListeners:
                       (nullable NSArray<id<RichieBooksReaderUiEventListener>> *)
                           eventListeners
                         animated:(BOOL)animated
                         fromView:(nullable UIView *)transitionStartSourceView
               withDisplayedImage:(nullable UIImage *)currentlyDisplayedImage
                       completion:(void (^_Nullable)(void))completion;

    Swift

    func present(from presentingViewController: UIViewController, adSlotName: String?, eventListeners: [any RichieBooksReaderUiEventListener]?, animated: Bool, from transitionStartSourceView: UIView?, withDisplayedImage currentlyDisplayedImage: UIImage?, completion: (() -> Void)? = nil) -> Bool

    Parameters

    presentingViewController

    View controller from which the book reading view controller is presented from.

    adSlotName

    Name of the ad slot from which slot ads are injected between book pages (according to slot placement rules).

    eventListeners

    Listeners for reading UI events. Useful for analytics logging, for example.

    animated

    Pass @p YES to animate the presentatation; otherwise, pass @p NO.

    transitionStartSourceView

    If animating the transition, this is the source view from which the transition begins. It should contain book cover image.

    currentlyDisplayedImage

    If animating the transition, use this image as the contents of @p transitionStartSourceView so a separate snapshot is not needed. If animating and nil, @p transitionStartSourceView is snapshotted to get image for transition.

    completion

    The block to execute after the presentation finishes. You may specify nil for this parameter.

    Return Value

    @p YES if view controller was presented, @p NO if failure prevented presentation (for example, presentingViewController is already presenting a view controller).

  • Undocumented

    Declaration

    Objective-C

    -(nullable RichieBooksReaderViewController *) presentableViewControllerWithAdSlotName:(nullable NSString *)adSlotName
    																	   eventListeners:(nullable NSArray<id<RichieBooksReaderUiEventListener>>*)eventListeners;

    Swift

    func presentableViewController(withAdSlotName adSlotName: String?, eventListeners: [any RichieBooksReaderUiEventListener]?) -> RichieBooksReaderViewController?