Kaynağa Gözat

Merge branch 'compdfkit_demo_flutter_beta_v1.x' into compdfkit_demo_flutter

# Conflicts:
#	README.md
#	android/build.gradle
#	example/android/app/build.gradle
#	example/lib/main.dart
#	example/pubspec.lock
#	example/pubspec.yaml
#	lib/util/extension/cpdf_color_extension.dart
#	pubspec.yaml
ComPDFKit-Youna 9 ay önce
ebeveyn
işleme
a3ef28b940
41 değiştirilmiş dosya ile 1330 ekleme ve 176 silme
  1. 44 9
      README.md
  2. 5 4
      android/build.gradle
  3. 3 1
      android/src/main/AndroidManifest.xml
  4. 10 2
      android/src/main/java/com/compdfkit/flutter/compdfkit_flutter/CompdfkitFlutterPlugin.java
  5. 42 0
      android/src/main/java/com/compdfkit/flutter/compdfkit_flutter/platformview/CPDFViewCtrlFactory.java
  6. 171 0
      android/src/main/java/com/compdfkit/flutter/compdfkit_flutter/platformview/CPDFViewCtrlFlutter.java
  7. 3 0
      android/src/main/java/com/compdfkit/flutter/compdfkit_flutter/plugin/BaseMethodChannelPlugin.java
  8. 22 19
      android/src/main/java/com/compdfkit/flutter/compdfkit_flutter/plugin/ComPDFKitSDKPlugin.java
  9. 20 12
      example/android/app/build.gradle
  10. 0 21
      example/android/app/proguard-rules.pro
  11. 10 6
      example/android/app/src/main/AndroidManifest.xml
  12. 11 2
      example/android/app/src/main/java/com/compdfkit/flutter/example/MainActivity.java
  13. 1 1
      example/android/app/src/main/res/values-night/styles.xml
  14. 11 2
      example/android/app/src/main/res/values/styles.xml
  15. 0 13
      example/android/build.gradle
  16. 1 1
      example/android/gradle.properties
  17. 1 1
      example/android/gradle/wrapper/gradle-wrapper.properties
  18. 26 8
      example/android/settings.gradle
  19. 6 0
      example/images/ic_home_setting.svg
  20. 7 0
      example/images/ic_home_viewer.svg
  21. 3 0
      example/images/ic_syasarrow.svg
  22. 10 0
      example/ios/Runner.xcworkspace/contents.xcworkspacedata
  23. 8 0
      example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
  24. 8 0
      example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
  25. 35 0
      example/lib/cpdf_reader_widget_example.dart
  26. 113 55
      example/lib/main.dart
  27. 121 0
      example/lib/page/settings_page.dart
  28. 62 0
      example/lib/theme/themes.dart
  29. 27 0
      example/lib/utils/file_util.dart
  30. 62 0
      example/lib/widgets/cpdf_fun_item.dart
  31. 225 7
      example/pubspec.lock
  32. 10 2
      example/pubspec.yaml
  33. 3 0
      ios/Classes/CompdfkitFlutterPlugin.swift
  34. 91 0
      ios/Classes/reader/CPDFViewCtrlFactory.swift
  35. 5 5
      ios/compdfkit_flutter.podspec
  36. 20 2
      lib/cpdf_configuration.dart
  37. 5 0
      lib/cpdf_options.dart
  38. 7 1
      lib/util/extension/cpdf_color_extension.dart
  39. 97 0
      lib/widgets/cpdf_reader_widget.dart
  40. 22 0
      lib/widgets/cpdf_reader_widget_controller.dart
  41. 2 2
      pubspec.yaml

+ 44 - 9
README.md

@@ -119,22 +119,48 @@ open android/app/build.gradle
  }
 ```
 
-6. Add the ComPDFKit dependency in `pubspec.yaml`
+6. Open the project’s main activity class, `android/app/src/main/java/com/example/compdfkit/flutter/example/MainActivity.java`, Change the base `Activity` to extend `FlutterFragmentActivity`:
+
+```diff
+- import io.flutter.embedding.android.FlutterActivity;
++ import io.flutter.embedding.android.FlutterFragmentActivity;
+
+- public class MainActivity extends FlutterActivity {
++ public class MainActivity extends FlutterFragmentActivity {
+}
+```
+
+Alternatively you can update the `AndroidManifest.xml` file to use `FlutterFragmentActivity` as the launcher activity:
+
+```diff
+<activity
+-     android:name=".MainActivity" 
++     android:name="io.flutter.embedding.android.FlutterFragmentActivity"
+      android:exported="true"
+      android:hardwareAccelerated="true"
+      android:launchMode="singleTop"
+      android:theme="@style/LaunchTheme"
+      android:windowSoftInputMode="adjustPan">
+```
+
+> **Note:** `FlutterFragmentActivity` is not an official part of the Flutter SDK. If you need to use `CPDFReaderWidget` in ComPDFKit for Flutter, you need to use this part of the code. You can skip this step if you don't need to use.
+
+7. Add the ComPDFKit dependency in `pubspec.yaml`
 
 ```diff
  dependencies:
    flutter:
      sdk: flutter
-+  compdfkit_flutter: ^2.0.1
++  compdfkit_flutter: ^2.0.2
 ```
 
-7. From the terminal app, run the following command to get all the packages:
+8. From the terminal app, run the following command to get all the packages:
 
 ```bash
 flutter pub get
 ```
 
-8. Open `lib/main.dart` and replace the entire content with the following code. And fill in the license provided to you in the `ComPDFKit.init` method, this simple example will load a PDF document from the local device file system.
+9. Open `lib/main.dart` and replace the entire content with the following code. And fill in the license provided to you in the `ComPDFKit.init` method, this simple example will load a PDF document from the local device file system.
 
 ```dart
 import 'dart:io';
@@ -281,7 +307,7 @@ cd example
  dependencies:
    flutter:
      sdk: flutter
-+  compdfkit_flutter: ^2.0.1
++  compdfkit_flutter: ^2.0.2
 ```
 
 4. From the terminal app, run the following command to get all the packages:
@@ -310,8 +336,8 @@ open ios/Podfile
    use_modular_headers!`
 
    flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
-+  pod 'ComPDFKit_Tools', podspec:'https://www.compdf.com/download/ios/cocoapods/xcframeworks/compdfkit_tools/2.0.1.podspec'
-+  pod 'ComPDFKit', podspec:'https://www.compdf.com/download/ios/cocoapods/xcframeworks/compdfkit/2.0.1.podspec'
++  pod 'ComPDFKit_Tools', podspec:'https://www.compdf.com/download/ios/cocoapods/xcframeworks/compdfkit_tools/2.0.2.podspec'
++  pod 'ComPDFKit', podspec:'https://www.compdf.com/download/ios/cocoapods/xcframeworks/compdfkit/2.0.2.podspec'
 
  end
 ```
@@ -527,8 +553,8 @@ target 'PDFView_RN' do
     # Pods for testing
   end
 
-+  pod 'ComPDFKit', :git => 'https://github.com/ComPDFKit/compdfkit-pdf-sdk-ios-swift.git', :tag => '2.0.1'
-+  pod 'ComPDFKit_Tools', :git => 'https://github.com/ComPDFKit/compdfkit-pdf-sdk-ios-swift.git', :tag => '2.0.1'
++  pod 'ComPDFKit', :git => 'https://github.com/ComPDFKit/compdfkit-pdf-sdk-ios-swift.git', :tag => '2.0.2'
++  pod 'ComPDFKit_Tools', :git => 'https://github.com/ComPDFKit/compdfkit-pdf-sdk-ios-swift.git', :tag => '2.0.2'
 
   # Enables Flipper.
   #
@@ -604,6 +630,15 @@ ComPDFKit.init('your compdfkit key')
 
 /// open pdf document
 ComPDFKit.openDocument(tempDocumentPath, password: '', configuration:  CPDFConfiguration());
+
+/// Here’s how you can open a PDF document using CPDFReaderWidget:
+Scaffold(
+        resizeToAvoidBottomInset: false,
+        appBar: AppBar(title: const Text('CPDFReaderWidget Example'),),
+        body: CPDFReaderWidget(
+          document: widget.documentPath,
+          configuration: CPDFConfiguration()
+        ));
 ```
 
 ## Support

+ 5 - 4
android/build.gradle

@@ -37,14 +37,15 @@ android {
     }
 
     dependencies {
-        compileOnly fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
+        compileOnly fileTree(include: ['*.jar','*.aar'], dir: 'libs')
         implementation 'com.google.android.material:material:1.8.0'
         implementation 'androidx.appcompat:appcompat:1.6.1'
         implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
-        api 'com.compdf:compdfkit:2.0.1'
-        api 'com.compdf:compdfkit-ui:2.0.1'
-        api 'com.compdf:compdfkit-tools:2.0.1'
+//        api 'com.compdf:compdfkit:2.0.1'
+//        api 'com.compdf:compdfkit-ui:2.0.1'
+        api 'com.compdf:compdfkit-tools:2.0.2-SNAPSHOT'
 
+//        api project(":ComPDFKit_Tools")
         testImplementation 'junit:junit:4.13.2'
         testImplementation 'org.mockito:mockito-core:5.0.0'
         api 'com.github.bumptech.glide:glide:4.15.1'

+ 3 - 1
android/src/main/AndroidManifest.xml

@@ -1,5 +1,7 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-  package="com.compdfkit.flutter.compdfkit_flutter">
+    xmlns:tools="http://schemas.android.com/tools"
+    package="com.compdfkit.flutter.compdfkit_flutter">
+
     <application>
 
     </application>

+ 10 - 2
android/src/main/java/com/compdfkit/flutter/compdfkit_flutter/CompdfkitFlutterPlugin.java

@@ -12,6 +12,7 @@ package com.compdfkit.flutter.compdfkit_flutter;
 import androidx.annotation.NonNull;
 
 import com.compdfkit.flutter.compdfkit_flutter.plugin.ComPDFKitSDKPlugin;
+import com.compdfkit.flutter.compdfkit_flutter.platformview.CPDFViewCtrlFactory;
 
 import io.flutter.embedding.engine.plugins.FlutterPlugin;
 import io.flutter.embedding.engine.plugins.activity.ActivityAware;
@@ -24,10 +25,15 @@ public class CompdfkitFlutterPlugin implements FlutterPlugin, ActivityAware {
 
     private BinaryMessenger mMessenger;
 
+    private PlatformViewRegistry mRegistry;
+
+    private static final String PDF_DOCUMENT_VIEW_TYPE_ID = "com.compdfkit.flutter.ui.pdfviewer";
+
     @Override
     public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) {
         mMessenger = flutterPluginBinding.getBinaryMessenger();
-        new ComPDFKitSDKPlugin(flutterPluginBinding.getApplicationContext(), mMessenger);
+        mRegistry = flutterPluginBinding.getPlatformViewRegistry();
+        new ComPDFKitSDKPlugin(flutterPluginBinding.getApplicationContext(), mMessenger, mRegistry);
     }
 
     @Override
@@ -36,6 +42,9 @@ public class CompdfkitFlutterPlugin implements FlutterPlugin, ActivityAware {
 
     @Override
     public void onAttachedToActivity(@NonNull ActivityPluginBinding binding) {
+        if (mRegistry != null) {
+            mRegistry.registerViewFactory(PDF_DOCUMENT_VIEW_TYPE_ID,new CPDFViewCtrlFactory(mMessenger));
+        }
     }
 
     @Override
@@ -45,7 +54,6 @@ public class CompdfkitFlutterPlugin implements FlutterPlugin, ActivityAware {
 
     @Override
     public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) {
-
     }
 
     @Override

+ 42 - 0
android/src/main/java/com/compdfkit/flutter/compdfkit_flutter/platformview/CPDFViewCtrlFactory.java

@@ -0,0 +1,42 @@
+/*
+ * Copyright © 2014-2024 PDF Technologies, Inc. All Rights Reserved.
+ *
+ * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
+ * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
+ * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
+ * This notice may not be removed from this file.
+ *
+ */
+
+package com.compdfkit.flutter.compdfkit_flutter.platformview;
+
+
+import android.content.Context;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import java.util.Map;
+
+import io.flutter.plugin.common.BinaryMessenger;
+import io.flutter.plugin.common.StandardMessageCodec;
+import io.flutter.plugin.platform.PlatformView;
+import io.flutter.plugin.platform.PlatformViewFactory;
+
+public class CPDFViewCtrlFactory extends PlatformViewFactory {
+
+    private final BinaryMessenger binaryMessenger;
+
+    public CPDFViewCtrlFactory(BinaryMessenger binaryMessenger) {
+        super(StandardMessageCodec.INSTANCE);
+        this.binaryMessenger = binaryMessenger;
+    }
+
+    @NonNull
+    @Override
+    public PlatformView create(Context context, int viewId, @Nullable Object args) {
+        @SuppressWarnings("unchecked")
+        Map<String, Object> creationParams = (Map<String, Object>) args;
+        return new CPDFViewCtrlFlutter(context, binaryMessenger, viewId, creationParams);
+    }
+}

+ 171 - 0
android/src/main/java/com/compdfkit/flutter/compdfkit_flutter/platformview/CPDFViewCtrlFlutter.java

@@ -0,0 +1,171 @@
+/*
+ * Copyright © 2014-2024 PDF Technologies, Inc. All Rights Reserved.
+ *
+ * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
+ * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
+ * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
+ * This notice may not be removed from this file.
+ *
+ */
+
+package com.compdfkit.flutter.compdfkit_flutter.platformview;
+
+
+import android.content.Context;
+import android.content.MutableContextWrapper;
+import android.util.Log;
+import android.view.View;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.FragmentActivity;
+import androidx.fragment.app.FragmentContainerView;
+
+
+import com.compdfkit.tools.common.pdf.CPDFConfigurationUtils;
+import com.compdfkit.tools.common.pdf.CPDFDocumentFragment;
+import com.compdfkit.tools.common.pdf.config.CPDFConfiguration;
+import com.compdfkit.tools.common.utils.CLog;
+
+import java.util.Map;
+
+import io.flutter.plugin.common.BinaryMessenger;
+import io.flutter.plugin.common.MethodCall;
+import io.flutter.plugin.common.MethodChannel;
+import io.flutter.plugin.platform.PlatformView;
+
+public class CPDFViewCtrlFlutter implements PlatformView, MethodChannel.MethodCallHandler {
+
+    public static final String LOG_TAG = "ComPDFKit-Plugin";
+    private FragmentContainerView fragmentContainerView;
+
+    private CPDFDocumentFragment documentFragment;
+
+    private BinaryMessenger binaryMessenger;
+
+    private int viewId;
+
+    private MethodChannel methodChannel;
+
+    public CPDFViewCtrlFlutter(Context context, BinaryMessenger binaryMessenger, int viewId, Map<String, Object> creationParams) {
+        this.binaryMessenger = binaryMessenger;
+        this.viewId = viewId;
+
+        // Initialize CPDFViewCtrl and initialize related configuration information
+        Log.e(LOG_TAG, "CPDFViewCtrlFlutter:Create CPDFDocumentFragment");
+        initCPDFViewCtrl(context, creationParams);
+
+        String channelName = "com.compdfkit.flutter.ui.pdfviewer." + viewId;
+        Log.e(LOG_TAG, "CPDFViewCtrlFlutter: create MethodChannel:" + channelName);
+        methodChannel = new MethodChannel(binaryMessenger, channelName);
+        methodChannel.setMethodCallHandler(this);
+    }
+
+
+    private void initCPDFViewCtrl(Context context, Map<String, Object> creationParams) {
+        fragmentContainerView = new FragmentContainerView(context);
+        fragmentContainerView.setId(View.generateViewId());
+        String filePath = (String) creationParams.get("document");
+        String password = (String) creationParams.get("password");
+
+        String configurationJson = (String) creationParams.get("configuration");
+        CPDFConfiguration configuration = CPDFConfigurationUtils.fromJson(configurationJson);
+        documentFragment = CPDFDocumentFragment.newInstance(filePath, password, configuration);
+
+        fragmentContainerView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
+            @Override
+            public void onViewAttachedToWindow(@NonNull View v) {
+                Log.e(LOG_TAG, "CPDFViewCtrlFlutter: Attached CPDFDocumentFragment to window");
+                FragmentActivity fragmentActivity = getFragmentActivity(context);
+                if (fragmentActivity != null) {
+                    fragmentActivity.getSupportFragmentManager()
+                            .beginTransaction()
+                            .add(fragmentContainerView.getId(), documentFragment)
+                            .setReorderingAllowed(true)
+                            .commitNow();
+                }
+            }
+
+            @Override
+            public void onViewDetachedFromWindow(@NonNull View v) {
+                documentFragment.pdfView.savePDF((s, uri) -> {
+                    Log.e(LOG_TAG, "CPDFViewCtrlFlutter: pdfView.savePDF Success");
+                    detachedFragment(context);
+                }, e -> {
+                    Log.e(LOG_TAG, "CPDFViewCtrlFlutter: pdfView.savePDF Fail");
+                    e.printStackTrace();
+                    detachedFragment(context);
+                });
+
+            }
+        });
+    }
+
+    private void detachedFragment(Context context){
+        Log.e(LOG_TAG, "CPDFViewCtrlFlutter: Detached CPDFDocumentFragment from window");
+        FragmentActivity fragmentActivity = getFragmentActivity(context);
+        if (fragmentActivity != null) {
+            fragmentActivity.getSupportFragmentManager()
+                    .beginTransaction()
+                    .remove(documentFragment)
+                    .setReorderingAllowed(true)
+                    .commit();
+        }
+    }
+
+    @Nullable
+    @Override
+    public View getView() {
+        return fragmentContainerView;
+    }
+
+    @Override
+    public void onFlutterViewAttached(@NonNull View flutterView) {
+        PlatformView.super.onFlutterViewAttached(flutterView);
+    }
+
+    @Override
+    public void onFlutterViewDetached() {
+        PlatformView.super.onFlutterViewDetached();
+    }
+
+    @Override
+    public void dispose() {
+        Log.e(LOG_TAG, "CPDFViewCtrlFlutter: dispose()");
+        fragmentContainerView = null;
+    }
+
+    @Override
+    public void onInputConnectionLocked() {
+        PlatformView.super.onInputConnectionLocked();
+    }
+
+    @Override
+    public void onInputConnectionUnlocked() {
+        PlatformView.super.onInputConnectionUnlocked();
+    }
+
+    private FragmentActivity getFragmentActivity(Context context) {
+        if (context instanceof FragmentActivity) {
+            return (FragmentActivity) context;
+        } else if (context instanceof MutableContextWrapper) {
+            return getFragmentActivity(((MutableContextWrapper) context).getBaseContext());
+        } else {
+            return null;
+        }
+    }
+
+    @Override
+    public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
+        Log.e(LOG_TAG, "CPDFViewCtrlFlutter:onMethodCall:" + call.method);
+        switch (call.method) {
+            case "pdfviewer":
+                result.success("rick");
+                break;
+            default:
+                Log.e(LOG_TAG, "CPDFViewCtrlFlutter:onMethodCall:notImplemented");
+                result.notImplemented();
+                break;
+        }
+    }
+}

+ 3 - 0
android/src/main/java/com/compdfkit/flutter/compdfkit_flutter/plugin/BaseMethodChannelPlugin.java

@@ -23,8 +23,11 @@ public abstract class BaseMethodChannelPlugin implements MethodChannel.MethodCal
 
     protected Context context;
 
+    protected BinaryMessenger binaryMessenger;
+
     public BaseMethodChannelPlugin(Context context, BinaryMessenger binaryMessenger) {
         this.context = context;
+        this.binaryMessenger = binaryMessenger;
         methodChannel = new MethodChannel(binaryMessenger, methodName());
         methodChannel.setMethodCallHandler(this);
     }

+ 22 - 19
android/src/main/java/com/compdfkit/flutter/compdfkit_flutter/plugin/ComPDFKitSDKPlugin.java

@@ -11,6 +11,7 @@ package com.compdfkit.flutter.compdfkit_flutter.plugin;
 
 import android.content.Context;
 import android.content.Intent;
+import android.util.Log;
 
 import androidx.annotation.NonNull;
 
@@ -18,15 +19,14 @@ import com.compdfkit.core.document.CPDFSdk;
 import com.compdfkit.tools.common.pdf.CPDFConfigurationUtils;
 import com.compdfkit.tools.common.pdf.CPDFDocumentActivity;
 import com.compdfkit.tools.common.pdf.config.CPDFConfiguration;
-import com.compdfkit.tools.common.utils.CToastUtil;
-
-import org.json.JSONObject;
+import com.compdfkit.tools.common.utils.CLog;
 
 import java.util.Map;
 
 import io.flutter.plugin.common.BinaryMessenger;
 import io.flutter.plugin.common.MethodCall;
 import io.flutter.plugin.common.MethodChannel;
+import io.flutter.plugin.platform.PlatformViewRegistry;
 
 
 public class ComPDFKitSDKPlugin extends BaseMethodChannelPlugin {
@@ -39,34 +39,40 @@ public class ComPDFKitSDKPlugin extends BaseMethodChannelPlugin {
 
     public static final String SDK_BUILD_TAG = "sdk_build_tag";
 
-    public ComPDFKitSDKPlugin(Context context, BinaryMessenger binaryMessenger) {
+    public ComPDFKitSDKPlugin(Context context, BinaryMessenger binaryMessenger, PlatformViewRegistry registry) {
         super(context, binaryMessenger);
     }
 
+    @Override
+    public String methodName() {
+        return "com.compdfkit.flutter.plugin";
+    }
+
     @Override
     public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
         switch (call.method) {
             case INIT_SDK:
-                Map<String, Object> map = (Map<String, Object>) call.arguments;
-                String key = (String) map.get("key");
-                CPDFSdk.init(context, key, true);
+                String key = call.argument("key");
+                CPDFSdk.init(context, key, true, (code, msg) -> {
+                    Log.e("ComPDFKit-Plugin", "INIT_SDK: code:" + code + ", msg:" + msg);
+                });
                 break;
             case INIT_SDK_KEYS:
-                Map<String, Object> map1 = (Map<String, Object>) call.arguments;
-                String androidLicenseKey = (String) map1.get("androidOnlineLicense");
-                CPDFSdk.init(context, androidLicenseKey, false);
+                String androidLicenseKey = call.argument("androidOnlineLicense");
+                CPDFSdk.init(context, androidLicenseKey, false, (code, msg) -> {
+                    Log.e("ComPDFKit-Plugin", "INIT_SDK_KEYS: code:" + code + ", msg:" + msg);
+                });
                 break;
             case SDK_VERSION_CODE:
-                result.success(CPDFSdk.getSDKVersion());
+                result.success("ComPDFKit " + CPDFSdk.getSDKVersion() + " for Android");
                 break;
             case SDK_BUILD_TAG:
                 result.success(CPDFSdk.getSDKBuildTag());
                 break;
             case "openDocument":
-                Map<String, Object> arguments = (Map<String, Object>) call.arguments;
-                String filePath = (String) arguments.get("document");
-                String password = (String) arguments.get("password");
-                String configurationJson = (String) arguments.get("configuration");
+                String filePath = call.argument("document");
+                String password = call.argument("password");
+                String configurationJson = call.argument("configuration");
                 CPDFConfiguration configuration = CPDFConfigurationUtils.fromJson(configurationJson);
                 Intent intent = new Intent(context, CPDFDocumentActivity.class);
                 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -83,8 +89,5 @@ public class ComPDFKitSDKPlugin extends BaseMethodChannelPlugin {
         }
     }
 
-    @Override
-    public String methodName() {
-        return "com.compdfkit.flutter.plugin";
-    }
+
 }

+ 20 - 12
example/android/app/build.gradle

@@ -1,3 +1,9 @@
+plugins {
+    id "com.android.application"
+    id "kotlin-android"
+    id "dev.flutter.flutter-gradle-plugin"
+}
+
 def localProperties = new Properties()
 def localPropertiesFile = rootProject.file('local.properties')
 if (localPropertiesFile.exists()) {
@@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) {
     }
 }
 
-def flutterRoot = localProperties.getProperty('flutter.sdk')
-if (flutterRoot == null) {
-    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
-}
-
 def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
 if (flutterVersionCode == null) {
     flutterVersionCode = '1'
@@ -21,13 +22,9 @@ if (flutterVersionName == null) {
     flutterVersionName = '1.0'
 }
 
-apply plugin: 'com.android.application'
-apply plugin: 'kotlin-android'
-apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
-
 android {
     namespace "com.compdfkit.flutter.example"
-    compileSdkVersion 33
+    compileSdk flutter.compileSdkVersion
     ndkVersion flutter.ndkVersion
     signingConfigs {
         release {
@@ -51,11 +48,18 @@ android {
         targetCompatibility JavaVersion.VERSION_1_8
     }
 
+    kotlinOptions {
+        jvmTarget = '1.8'
+    }
+
+
     defaultConfig {
         applicationId "com.compdfkit.flutter.example"
+        // You can update the following values to match your application needs.
+        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
         minSdkVersion 21
-        targetSdkVersion 33
-        versionCode 6
+        targetSdkVersion flutter.targetSdkVersion
+        versionCode flutterVersionCode.toInteger()
         versionName flutterVersionName
     }
 
@@ -74,4 +78,8 @@ flutter {
 dependencies {
 
     api fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
+    implementation 'com.google.android.material:material:1.8.0'
+    implementation 'androidx.appcompat:appcompat:1.6.1'
+    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
+
 }

+ 0 - 21
example/android/app/proguard-rules.pro

@@ -1,21 +0,0 @@
-# Add project specific ProGuard rules here.
-# You can control the set of applied configuration files using the
-# proguardFiles setting in build.gradle.
-#
-# For more details, see
-#   http://developer.android.com/guide/developing/tools/proguard.html
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-#   public *;
-#}
-
-# Uncomment this to preserve the line number information for
-# debugging stack traces.
-#-keepattributes SourceFile,LineNumberTable
-
-# If you keep the line number information, uncomment this to
-# hide the original source file name.
-#-renamesourcefileattribute SourceFile

+ 10 - 6
example/android/app/src/main/AndroidManifest.xml

@@ -4,7 +4,7 @@
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
-    <uses-permission android:name="android.permission.INTERNET"/>
+    <uses-permission android:name="android.permission.INTERNET" />
 
     <application
         android:name="${applicationName}"
@@ -18,8 +18,8 @@
             android:exported="true"
             android:hardwareAccelerated="true"
             android:launchMode="singleTop"
-            android:theme="@style/LaunchTheme"
-            android:windowSoftInputMode="adjustResize">
+            android:theme="@style/ComPDFKit.Theme.Light"
+            android:windowSoftInputMode="adjustPan">
             <meta-data
                 android:name="io.flutter.embedding.android.NormalTheme"
                 android:resource="@style/NormalTheme" />
@@ -28,11 +28,15 @@
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
-        <!-- Don't delete the meta-data below.
-             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
         <meta-data
             android:name="flutterEmbedding"
             android:value="2" />
+    </application>
 
-</application>
+    <queries>
+        <intent>
+            <action android:name="android.intent.action.PROCESS_TEXT" />
+            <data android:mimeType="text/plain" />
+        </intent>
+    </queries>
 </manifest>

+ 11 - 2
example/android/app/src/main/java/com/compdfkit/flutter/example/MainActivity.java

@@ -9,7 +9,16 @@
 
 package com.compdfkit.flutter.example;
 
-import io.flutter.embedding.android.FlutterActivity;
+import android.os.Bundle;
 
-public class MainActivity extends FlutterActivity {
+import androidx.annotation.Nullable;
+
+import io.flutter.embedding.android.FlutterFragmentActivity;
+
+public class MainActivity extends FlutterFragmentActivity {
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+    }
 }

+ 1 - 1
example/android/app/src/main/res/values-night/styles.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
     <!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
-    <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
+    <style name="LaunchTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
         <!-- Show a splash screen on the activity. Automatically removed when
              the Flutter engine draws its first frame -->
         <item name="android:windowBackground">@drawable/launch_background</item>

+ 11 - 2
example/android/app/src/main/res/values/styles.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
-<resources>
+<resources xmlns:tools="http://schemas.android.com/tools">
     <!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
-    <style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
+    <style name="LaunchTheme" parent="Theme.AppCompat.Light.NoActionBar">
         <!-- Show a splash screen on the activity. Automatically removed when
              the Flutter engine draws its first frame -->
         <item name="android:windowBackground">@drawable/launch_background</item>
@@ -15,4 +15,13 @@
     <style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
         <item name="android:windowBackground">?android:colorBackground</item>
     </style>
+
+
+    <style name="Basic_Theme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
+        <item name="android:statusBarColor">@color/tools_color_primary</item>
+        <item name="android:windowLightStatusBar" tools:targetApi="m">true</item>
+        <item name="android:colorAccent">@color/tools_color_accent</item>
+        <item name="android:colorPrimary">@color/tools_color_accent</item>
+    </style>
+
 </resources>

+ 0 - 13
example/android/build.gradle

@@ -1,16 +1,3 @@
-buildscript {
-    ext.kotlin_version = '1.7.10'
-    repositories {
-        google()
-        mavenCentral()
-    }
-
-    dependencies {
-        classpath 'com.android.tools.build:gradle:7.3.0'
-        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
-    }
-}
-
 allprojects {
     repositories {
         google()

+ 1 - 1
example/android/gradle.properties

@@ -1,4 +1,4 @@
-org.gradle.jvmargs=-Xmx1536M
+org.gradle.jvmargs=-Xmx4G
 android.useAndroidX=true
 android.enableJetifier=true
 Keystore.properties=./key.properties

+ 1 - 1
example/android/gradle/wrapper/gradle-wrapper.properties

@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip

+ 26 - 8
example/android/settings.gradle

@@ -1,11 +1,29 @@
-include ':app'
+pluginManagement {
+    def flutterSdkPath = {
+        def properties = new Properties()
+        file("local.properties").withInputStream { properties.load(it) }
+        def flutterSdkPath = properties.getProperty("flutter.sdk")
+        assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
+        return flutterSdkPath
+    }
+    settings.ext.flutterSdkPath = flutterSdkPath()
 
-def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
-def properties = new Properties()
+    includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
 
-assert localPropertiesFile.exists()
-localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
+    repositories {
+        google()
+        mavenCentral()
+        gradlePluginPortal()
+    }
+}
 
-def flutterSdkPath = properties.getProperty("flutter.sdk")
-assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
-apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
+plugins {
+    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
+    id "com.android.application" version "7.3.0" apply false
+    id "org.jetbrains.kotlin.android" version "1.7.10" apply false
+}
+
+include ":app"
+
+//include ":ComPDFKit_Tools"
+//project(':ComPDFKit_Tools').projectDir = file('/Users/kdan/git_work/kdan/compdfkit_demo_android/ComPDFKit_Tools')

Dosya farkı çok büyük olduğundan ihmal edildi
+ 6 - 0
example/images/ic_home_setting.svg


+ 7 - 0
example/images/ic_home_viewer.svg

@@ -0,0 +1,7 @@
+<svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
+<rect width="30" height="30" rx="4" fill="#F2F3F5"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M18.2071 6.5H7.5V23.5H22.5V10.7929L18.2071 6.5Z" fill="#477EDE" fill-opacity="0.5"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M9.5 8.5H17.5L20.5 11.5V21.5H9.5L9.5 8.5Z" fill="#477EDE"/>
+<path d="M14.9583 17.75C16.6763 17.75 18.1387 16.2833 18.6862 15.6551C18.8279 15.4925 18.8279 15.2575 18.6862 15.0949C18.1387 14.4667 16.6763 13 14.9583 13C13.2404 13 11.778 14.4667 11.2305 15.0949C11.0888 15.2575 11.0888 15.4925 11.2305 15.6551C11.778 16.2833 13.2404 17.75 14.9583 17.75Z" fill="white"/>
+<path d="M14.9583 16.3649C15.5049 16.3649 15.9479 15.9219 15.9479 15.3753C15.9479 14.8288 15.5049 14.3857 14.9583 14.3857C14.4118 14.3857 13.9688 14.8288 13.9688 15.3753C13.9688 15.9219 14.4118 16.3649 14.9583 16.3649Z" stroke="#477EDE" stroke-linejoin="round"/>
+</svg>

+ 3 - 0
example/images/ic_syasarrow.svg

@@ -0,0 +1,3 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M9.77832 4L17.5565 11.7782L9.77832 19.5563" stroke="#999999" stroke-width="1.5"/>
+</svg>

+ 10 - 0
example/ios/Runner.xcworkspace/contents.xcworkspacedata

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace
+   version = "1.0">
+   <FileRef
+      location = "group:Runner.xcodeproj">
+   </FileRef>
+   <FileRef
+      location = "group:Pods/Pods.xcodeproj">
+   </FileRef>
+</Workspace>

+ 8 - 0
example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>IDEDidComputeMac32BitWarning</key>
+	<true/>
+</dict>
+</plist>

+ 8 - 0
example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>PreviewsEnabled</key>
+	<false/>
+</dict>
+</plist>

+ 35 - 0
example/lib/cpdf_reader_widget_example.dart

@@ -0,0 +1,35 @@
+///  Copyright © 2014-2024 PDF Technologies, Inc. All Rights Reserved.
+///
+///  THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
+///  AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
+///  UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
+///  This notice may not be removed from this file.
+///
+
+
+import 'package:compdfkit_flutter/cpdf_configuration.dart';
+import 'package:compdfkit_flutter/widgets/cpdf_reader_widget.dart';
+import 'package:flutter/material.dart';
+
+
+class CPDFReaderWidgetExample extends StatefulWidget {
+  final String documentPath;
+
+  const CPDFReaderWidgetExample({super.key, required this.documentPath});
+
+  @override
+  State<CPDFReaderWidgetExample> createState() => _CPDFReaderWidgetExampleState();
+}
+
+class _CPDFReaderWidgetExampleState extends State<CPDFReaderWidgetExample> {
+  @override
+  Widget build(BuildContext context) {
+    return Scaffold(
+        resizeToAvoidBottomInset: false,
+        appBar: AppBar(title: const Text('CPDFReaderWidget Example'),),
+        body: CPDFReaderWidget(
+          document: widget.documentPath,
+          configuration: CPDFConfiguration()
+        ));
+  }
+}

Dosya farkı çok büyük olduğundan ihmal edildi
+ 113 - 55
example/lib/main.dart


+ 121 - 0
example/lib/page/settings_page.dart

@@ -0,0 +1,121 @@
+///  Copyright © 2014-2024 PDF Technologies, Inc. All Rights Reserved.
+///
+///  THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
+///  AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
+///  UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
+///  This notice may not be removed from this file.
+///
+import 'package:compdfkit_flutter/compdfkit.dart';
+import 'package:flutter/gestures.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_svg/flutter_svg.dart';
+import 'package:url_launcher/url_launcher.dart';
+
+class SettingsPage extends StatelessWidget {
+  const SettingsPage({super.key});
+
+  @override
+  Widget build(BuildContext context) {
+    return Scaffold(
+        appBar: AppBar(
+          elevation: 4,
+          excludeHeaderSemantics: true,
+          titleSpacing: 0,
+          title: const Text('Settings'),
+        ),
+        body: Column(
+          children: [
+            Column(
+              children: [
+                head(context, 'SDK Information'),
+                item(context, 'Versions',
+                    trailing: FutureBuilder(
+                        future: ComPDFKit.getVersionCode(),
+                        builder: (context, snap) {
+                          return Text(snap.data ?? "",
+                              style: Theme.of(context).textTheme.bodyMedium);
+                        })),
+                head(context, 'Company Information'),
+                item(context,
+                    'https://www.compdf.com/',
+                    onTap: () => launchUrl(Uri.parse('https://www.compdf.com/'))),
+                item(context, 'About ComPDFKit',
+                    onTap: () => launchUrl(Uri.parse(
+                        'https://www.compdf.com/company/about'))),
+                item(context, 'Technical Support',
+                    onTap: () => launchUrl(Uri.parse('https://www.compdf.com/support'))),
+                item(context, 'Contact Sales',
+                    onTap: () => launchUrl(Uri.parse('https://www.compdf.com/contact-sales'))),
+                item(context, 'support@compdf.com',
+                    onTap: () {
+                  launchUrl(Uri.parse(
+                      'mailto:support@compdf.com?subject=Technical Support'));
+                }),
+              ],
+            ),
+            Expanded(
+                child: SafeArea(
+                    child: Padding(
+              padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
+              child: Column(
+                mainAxisAlignment: MainAxisAlignment.end,
+                children: [
+                  Text(
+                    '© 2014-2024 PDF Technologies, Inc. All Rights Reserved.',
+                    style: Theme.of(context)
+                        .textTheme
+                        .bodySmall
+                        ?.copyWith(fontSize: 11),
+                    textAlign: TextAlign.center,
+                  ),
+                  const Padding(padding: EdgeInsets.only(top: 8)),
+                  Text.rich(TextSpan(children: [
+                    TextSpan(
+                        text: 'Privacy Policy',
+                        style: Theme.of(context).textTheme.bodySmall?.copyWith(
+                            fontSize: 11, color: const Color(0xFF1460F3)),
+                        recognizer: TapGestureRecognizer()
+                          ..onTap = () => launchUrl(
+                                Uri.parse('https://www.compdf.com/privacy-policy'),
+                              )),
+                    const TextSpan(text: ' | '),
+                    TextSpan(
+                        text: 'Terms of Service',
+                        style: Theme.of(context).textTheme.bodySmall?.copyWith(
+                            fontSize: 11, color: const Color(0xFF1460F3)),
+                        recognizer: TapGestureRecognizer()
+                          ..onTap = () => launchUrl(
+                                Uri.parse('https://www.compdf.com/terms-of-service'),
+                              )),
+                  ])),
+                ],
+              ),
+            )))
+          ],
+        ));
+  }
+
+  Widget head(BuildContext context, String title) {
+    return Container(
+      width: double.infinity,
+      padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
+      color: Theme.of(context).brightness == Brightness.dark
+          ? const Color(0xFF303238)
+          : const Color(0xFFF2F2F2),
+      child: Text(title, style: Theme.of(context).textTheme.bodySmall),
+    );
+  }
+
+  Widget item(BuildContext context, String title,
+      {Widget? trailing, GestureTapCallback? onTap}) {
+    return ListTile(
+        onTap: onTap,
+        title: Text(title, style: Theme.of(context).textTheme.bodyMedium),
+        trailing: trailing ??
+            SvgPicture.asset(
+              'images/ic_syasarrow.svg',
+              color: Theme.of(context).colorScheme.onPrimary,
+            ));
+  }
+
+}

+ 62 - 0
example/lib/theme/themes.dart

@@ -0,0 +1,62 @@
+///  Copyright © 2014-2024 PDF Technologies, Inc. All Rights Reserved.
+///
+///  THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
+///  AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
+///  UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
+///  This notice may not be removed from this file.
+
+
+import 'package:flutter/material.dart';
+
+final ThemeData lightTheme = ThemeData(
+    useMaterial3: true,
+    brightness: Brightness.light,
+    colorScheme: const ColorScheme.light(
+        primary: Color(0xFFFAFCFF),
+        background: Color(0xFFFFFFFF),
+        surface: Color(0xFFFAFCFF),
+        onPrimary: Color(0xFF43474D),
+        onSecondary: Color(0xFF666666)),
+    textTheme: const TextTheme(
+            bodyMedium: TextStyle(),
+            bodyLarge: TextStyle(),
+            bodySmall: TextStyle(),
+            titleMedium: TextStyle())
+        .apply(
+            displayColor: const Color(0xFF43474D),
+            bodyColor: const Color(0xFF43474D)),
+    appBarTheme: const AppBarTheme(
+        elevation: 4.0,
+        titleTextStyle: TextStyle(
+            fontSize: 18,
+            fontWeight: FontWeight.bold,
+            color: Color(0xFF43474D)),
+        backgroundColor: Color(0xFFFAFCFF),
+        foregroundColor: Color(0xFF43474D)),
+    elevatedButtonTheme: ElevatedButtonThemeData(
+        style: ElevatedButton.styleFrom(foregroundColor: Colors.blue)));
+
+final ThemeData darkTheme = ThemeData(
+    useMaterial3: true,
+    brightness: Brightness.dark,
+    scaffoldBackgroundColor: Colors.black,
+    colorScheme: const ColorScheme.dark(
+        primary: Color(0xFF222429),
+        background: Color(0xFF414347),
+        surface: Color(0xFF222429),
+        onPrimary: Colors.white,
+        onSecondary: Colors.white),
+    textTheme: const TextTheme(
+            bodyMedium: TextStyle(),
+            bodyLarge: TextStyle(),
+            bodySmall: TextStyle(),
+            titleMedium: TextStyle())
+        .apply(displayColor: Colors.white, bodyColor: Colors.white),
+    appBarTheme: const AppBarTheme(
+        elevation: 2.0,
+        titleTextStyle: TextStyle(
+            fontSize: 18, fontWeight: FontWeight.bold, color: Colors.white),
+        backgroundColor: Color(0xFF222429),
+        foregroundColor: Colors.white),
+    elevatedButtonTheme: ElevatedButtonThemeData(
+        style: ElevatedButton.styleFrom(foregroundColor: Colors.blue)));

+ 27 - 0
example/lib/utils/file_util.dart

@@ -0,0 +1,27 @@
+///  Copyright © 2014-2024 PDF Technologies, Inc. All Rights Reserved.
+///
+///  THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
+///  AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
+///  UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
+///  This notice may not be removed from this file.
+
+import 'dart:io';
+
+import 'package:compdfkit_flutter/compdfkit.dart';
+import 'package:flutter/material.dart';
+
+Future<File> extractAsset(BuildContext context, String assetPath,
+    {bool shouldOverwrite = true, String prefix = ''}) async {
+  final bytes = await DefaultAssetBundle.of(context).load(assetPath);
+  final list = bytes.buffer.asUint8List();
+
+  final tempDir = await ComPDFKit.getTemporaryDirectory();
+  final tempDocumentPath = '${tempDir.path}/$prefix$assetPath';
+  final file = File(tempDocumentPath);
+
+  if (shouldOverwrite || !file.existsSync()) {
+    await file.create(recursive: true);
+    file.writeAsBytesSync(list);
+  }
+  return file;
+}

+ 62 - 0
example/lib/widgets/cpdf_fun_item.dart

@@ -0,0 +1,62 @@
+///  Copyright © 2014-2024 PDF Technologies, Inc. All Rights Reserved.
+///
+///  THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
+///  AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
+///  UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
+///  This notice may not be removed from this file.
+
+
+import 'package:flutter/material.dart';
+import 'package:flutter_svg/flutter_svg.dart';
+
+class FeatureItem extends StatelessWidget {
+  final String title;
+
+  final String description;
+
+  final GestureTapCallback onTap;
+
+  const FeatureItem(
+      {super.key,
+      required this.title,
+      required this.description,
+      required this.onTap});
+
+  @override
+  Widget build(BuildContext context) {
+    return Ink(
+      child: InkWell(
+        borderRadius: BorderRadius.circular(8),
+        onTap: onTap,
+        child: Padding(padding: const EdgeInsets.symmetric(vertical: 12), child: Row(
+          mainAxisSize: MainAxisSize.min,
+          children: [
+            SvgPicture.asset(
+              'images/ic_home_viewer.svg',
+              width: 38,
+              height: 38,
+            ),
+            const Padding(padding: EdgeInsets.only(left: 8.0)),
+            Expanded(
+                child: Column(
+                  crossAxisAlignment: CrossAxisAlignment.start,
+                  children: [
+                    Text(title, style: Theme.of(context).textTheme.titleSmall),
+                    Text(
+                      description,
+                      style: const TextStyle(fontSize: 12.0),
+                    )
+                  ],
+                )),
+            SvgPicture.asset(
+              'images/ic_syasarrow.svg',
+              width: 24,
+              height: 24,
+              color: Theme.of(context).colorScheme.onPrimary,
+            )
+          ],
+        )),
+      ),
+    );
+  }
+}

+ 225 - 7
example/pubspec.lock

@@ -1,6 +1,14 @@
 # Generated by pub
 # See https://dart.dev/tools/pub/glossary#lockfile
 packages:
+  args:
+    dependency: transitive
+    description:
+      name: args
+      sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
+      url: "https://pub.dev"
+    source: hosted
+    version: "2.4.2"
   async:
     dependency: transitive
     description:
@@ -47,7 +55,15 @@ packages:
       path: ".."
       relative: true
     source: path
-    version: "2.0.1"
+    version: "2.0.2-dev.1"
+  cross_file:
+    dependency: transitive
+    description:
+      name: cross_file
+      sha256: "55d7b444feb71301ef6b8838dbc1ae02e63dd48c8773f3810ff53bb1e2945b32"
+      url: "https://pub.dev"
+    source: hosted
+    version: "0.3.4+1"
   cupertino_icons:
     dependency: "direct main"
     description:
@@ -64,6 +80,14 @@ packages:
       url: "https://pub.dev"
     source: hosted
     version: "1.3.1"
+  ffi:
+    dependency: transitive
+    description:
+      name: ffi
+      sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21"
+      url: "https://pub.dev"
+    source: hosted
+    version: "2.1.2"
   file:
     dependency: transitive
     description:
@@ -72,6 +96,14 @@ packages:
       url: "https://pub.dev"
     source: hosted
     version: "7.0.0"
+  file_picker:
+    dependency: "direct main"
+    description:
+      name: file_picker
+      sha256: "29c90806ac5f5fb896547720b73b17ee9aed9bba540dc5d91fe29f8c5745b10a"
+      url: "https://pub.dev"
+    source: hosted
+    version: "8.0.3"
   flutter:
     dependency: "direct main"
     description: flutter
@@ -86,25 +118,75 @@ packages:
     dependency: "direct dev"
     description:
       name: flutter_lints
-      sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04
+      sha256: "3f41d009ba7172d5ff9be5f6e6e6abb4300e263aab8866d2a0842ed2a70f8f0c"
+      url: "https://pub.dev"
+    source: hosted
+    version: "4.0.0"
+  flutter_localizations:
+    dependency: "direct main"
+    description: flutter
+    source: sdk
+    version: "0.0.0"
+  flutter_plugin_android_lifecycle:
+    dependency: transitive
+    description:
+      name: flutter_plugin_android_lifecycle
+      sha256: b068ffc46f82a55844acfa4fdbb61fad72fa2aef0905548419d97f0f95c456da
+      url: "https://pub.dev"
+    source: hosted
+    version: "2.0.17"
+  flutter_svg:
+    dependency: "direct main"
+    description:
+      name: flutter_svg
+      sha256: "7b4ca6cf3304575fe9c8ec64813c8d02ee41d2afe60bcfe0678bcb5375d596a2"
       url: "https://pub.dev"
     source: hosted
-    version: "2.0.3"
+    version: "2.0.10+1"
   flutter_test:
     dependency: "direct dev"
     description: flutter
     source: sdk
     version: "0.0.0"
+  flutter_web_plugins:
+    dependency: transitive
+    description: flutter
+    source: sdk
+    version: "0.0.0"
   fuchsia_remote_debug_protocol:
     dependency: transitive
     description: flutter
     source: sdk
     version: "0.0.0"
+  http:
+    dependency: transitive
+    description:
+      name: http
+      sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938"
+      url: "https://pub.dev"
+    source: hosted
+    version: "1.2.1"
+  http_parser:
+    dependency: transitive
+    description:
+      name: http_parser
+      sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
+      url: "https://pub.dev"
+    source: hosted
+    version: "4.0.2"
   integration_test:
     dependency: "direct dev"
     description: flutter
     source: sdk
     version: "0.0.0"
+  intl:
+    dependency: transitive
+    description:
+      name: intl
+      sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d"
+      url: "https://pub.dev"
+    source: hosted
+    version: "0.18.1"
   leak_tracker:
     dependency: transitive
     description:
@@ -133,10 +215,10 @@ packages:
     dependency: transitive
     description:
       name: lints
-      sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452"
+      sha256: "976c774dd944a42e83e2467f4cc670daef7eed6295b10b36ae8c85bcbf828235"
       url: "https://pub.dev"
     source: hosted
-    version: "2.1.1"
+    version: "4.0.0"
   matcher:
     dependency: transitive
     description:
@@ -169,6 +251,22 @@ packages:
       url: "https://pub.dev"
     source: hosted
     version: "1.9.0"
+  path_parsing:
+    dependency: transitive
+    description:
+      name: path_parsing
+      sha256: e3e67b1629e6f7e8100b367d3db6ba6af4b1f0bb80f64db18ef1fbabd2fa9ccf
+      url: "https://pub.dev"
+    source: hosted
+    version: "1.0.1"
+  petitparser:
+    dependency: transitive
+    description:
+      name: petitparser
+      sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27
+      url: "https://pub.dev"
+    source: hosted
+    version: "6.0.2"
   platform:
     dependency: transitive
     description:
@@ -254,6 +352,102 @@ packages:
       url: "https://pub.dev"
     source: hosted
     version: "0.6.1"
+  typed_data:
+    dependency: transitive
+    description:
+      name: typed_data
+      sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
+      url: "https://pub.dev"
+    source: hosted
+    version: "1.3.2"
+  url_launcher:
+    dependency: "direct main"
+    description:
+      name: url_launcher
+      sha256: "0ecc004c62fd3ed36a2ffcbe0dd9700aee63bd7532d0b642a488b1ec310f492e"
+      url: "https://pub.dev"
+    source: hosted
+    version: "6.2.5"
+  url_launcher_android:
+    dependency: transitive
+    description:
+      name: url_launcher_android
+      sha256: d4ed0711849dd8e33eb2dd69c25db0d0d3fdc37e0a62e629fe32f57a22db2745
+      url: "https://pub.dev"
+    source: hosted
+    version: "6.3.0"
+  url_launcher_ios:
+    dependency: transitive
+    description:
+      name: url_launcher_ios
+      sha256: "9149d493b075ed740901f3ee844a38a00b33116c7c5c10d7fb27df8987fb51d5"
+      url: "https://pub.dev"
+    source: hosted
+    version: "6.2.5"
+  url_launcher_linux:
+    dependency: transitive
+    description:
+      name: url_launcher_linux
+      sha256: ab360eb661f8879369acac07b6bb3ff09d9471155357da8443fd5d3cf7363811
+      url: "https://pub.dev"
+    source: hosted
+    version: "3.1.1"
+  url_launcher_macos:
+    dependency: transitive
+    description:
+      name: url_launcher_macos
+      sha256: b7244901ea3cf489c5335bdacda07264a6e960b1c1b1a9f91e4bc371d9e68234
+      url: "https://pub.dev"
+    source: hosted
+    version: "3.1.0"
+  url_launcher_platform_interface:
+    dependency: transitive
+    description:
+      name: url_launcher_platform_interface
+      sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029"
+      url: "https://pub.dev"
+    source: hosted
+    version: "2.3.2"
+  url_launcher_web:
+    dependency: transitive
+    description:
+      name: url_launcher_web
+      sha256: "3692a459204a33e04bc94f5fb91158faf4f2c8903281ddd82915adecdb1a901d"
+      url: "https://pub.dev"
+    source: hosted
+    version: "2.3.0"
+  url_launcher_windows:
+    dependency: transitive
+    description:
+      name: url_launcher_windows
+      sha256: ecf9725510600aa2bb6d7ddabe16357691b6d2805f66216a97d1b881e21beff7
+      url: "https://pub.dev"
+    source: hosted
+    version: "3.1.1"
+  vector_graphics:
+    dependency: transitive
+    description:
+      name: vector_graphics
+      sha256: "32c3c684e02f9bc0afb0ae0aa653337a2fe022e8ab064bcd7ffda27a74e288e3"
+      url: "https://pub.dev"
+    source: hosted
+    version: "1.1.11+1"
+  vector_graphics_codec:
+    dependency: transitive
+    description:
+      name: vector_graphics_codec
+      sha256: c86987475f162fadff579e7320c7ddda04cd2fdeffbe1129227a85d9ac9e03da
+      url: "https://pub.dev"
+    source: hosted
+    version: "1.1.11+1"
+  vector_graphics_compiler:
+    dependency: transitive
+    description:
+      name: vector_graphics_compiler
+      sha256: "12faff3f73b1741a36ca7e31b292ddeb629af819ca9efe9953b70bd63fc8cd81"
+      url: "https://pub.dev"
+    source: hosted
+    version: "1.1.11+1"
   vector_math:
     dependency: transitive
     description:
@@ -270,6 +464,14 @@ packages:
       url: "https://pub.dev"
     source: hosted
     version: "13.0.0"
+  web:
+    dependency: transitive
+    description:
+      name: web
+      sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27"
+      url: "https://pub.dev"
+    source: hosted
+    version: "0.5.1"
   webdriver:
     dependency: transitive
     description:
@@ -278,6 +480,22 @@ packages:
       url: "https://pub.dev"
     source: hosted
     version: "3.0.3"
+  win32:
+    dependency: transitive
+    description:
+      name: win32
+      sha256: "8cb58b45c47dcb42ab3651533626161d6b67a2921917d8d429791f76972b3480"
+      url: "https://pub.dev"
+    source: hosted
+    version: "5.3.0"
+  xml:
+    dependency: transitive
+    description:
+      name: xml
+      sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226
+      url: "https://pub.dev"
+    source: hosted
+    version: "6.5.0"
 sdks:
-  dart: ">=3.2.0-0 <4.0.0"
-  flutter: ">=3.3.0"
+  dart: ">=3.3.0 <4.0.0"
+  flutter: ">=3.19.0"

+ 10 - 2
example/pubspec.yaml

@@ -1,6 +1,6 @@
 name: compdfkit_flutter_example
 description: Demonstrates how to use the compdfkit_flutter plugin.
-version: 2.0.1
+version: 2.0.2
 homepage: https://www.compdf.com
 repository: https://github.com/ComPDFKit/compdfkit-pdf-sdk-flutter
 issue_tracker: https://www.compdf.com/support
@@ -25,6 +25,12 @@ dependencies:
   # The following adds the Cupertino Icons font to your application.
   # Use with the CupertinoIcons class for iOS style icons.
   cupertino_icons: ^1.0.2
+  flutter_svg: ^2.0.9
+  file_picker: ^8.0.3
+  url_launcher: ^6.2.3
+  flutter_localizations:
+    sdk: flutter
+
 
 
 dev_dependencies:
@@ -38,7 +44,7 @@ dev_dependencies:
   # activated in the `analysis_options.yaml` file located at the root of your
   # package. See that file for information about deactivating specific lint
   # rules and activating additional ones.
-  flutter_lints: ^2.0.0
+  flutter_lints: ^4.0.0
 
 # For information on the generic Dart part of this file, see the
 # following page: https://dart.dev/tools/pub/pubspec
@@ -50,8 +56,10 @@ flutter:
   # included with your application, so that you can use the icons in
   # the material Icons class.
   uses-material-design: true
+  generate: true
   assets:
     - pdfs/
+    - images/
   # To add assets to your application, add an assets section, like this:
   # assets:
   #   - images/a_dot_burr.jpeg

+ 3 - 0
ios/Classes/CompdfkitFlutterPlugin.swift

@@ -8,6 +8,9 @@ public class CompdfkitFlutterPlugin: NSObject, FlutterPlugin, CPDFViewBaseContro
         let channel = FlutterMethodChannel(name: "com.compdfkit.flutter.plugin", binaryMessenger: registrar.messenger())
         let instance = CompdfkitFlutterPlugin()
         registrar.addMethodCallDelegate(instance, channel: channel)
+
+        let factory = CPDFViewCtrlFactory(messenger: registrar.messenger())
+        registrar.register(factory, withId: "com.compdfkit.flutter.ui.pdfviewer")
     }
     
     public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {

+ 91 - 0
ios/Classes/reader/CPDFViewCtrlFactory.swift

@@ -0,0 +1,91 @@
+//
+//  CPDFViewCtrlFactory.swift
+//
+//  Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
+//
+//  THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
+//  AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
+//  UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
+//  This notice may not be removed from this file.
+
+
+import Flutter
+import UIKit
+import ComPDFKit
+import ComPDFKit_Tools
+
+class CPDFViewCtrlFactory: NSObject, FlutterPlatformViewFactory {
+    private let messenger: FlutterBinaryMessenger
+
+    init(messenger: FlutterBinaryMessenger) {
+        self.messenger = messenger
+        super.init()
+    }
+
+    func create(
+        withFrame frame: CGRect,
+        viewIdentifier viewId: Int64,
+        arguments args: Any?
+    ) -> FlutterPlatformView {
+        return CPDFViewCtrlFlutter(
+            frame: frame,
+            viewIdentifier: viewId,
+            arguments: args,
+            binaryMessenger: messenger)
+    }
+    
+    func createArgsCodec() -> FlutterMessageCodec & NSObjectProtocol {
+        return FlutterStandardMessageCodec.sharedInstance()
+    }
+}
+
+class CPDFViewCtrlFlutter: NSObject, FlutterPlatformView,CPDFViewBaseControllerDelete {
+    
+    private var _pdfViewController : CPDFViewController
+    
+    private var _navigationController : CNavigationController
+    
+
+    init(
+        frame: CGRect,
+        viewIdentifier viewId: Int64,
+        arguments args: Any?,
+        binaryMessenger messenger: FlutterBinaryMessenger?
+    ) {
+        
+        // 解析 文档路径、密码、配置信息
+        let initInfo = args as? [String: Any]
+        let jsonString = initInfo?["configuration"] ?? ""
+        let password = initInfo?["password"] ?? ""
+        let path = initInfo?["document"] as? String ?? ""
+        
+        let jsonDataParse = CPDFJSONDataParse(String: jsonString as! String)
+        let configuration = jsonDataParse.configuration
+        
+        // 创建pdfview controller视图
+        _pdfViewController = CPDFViewController(filePath: path, password: password as! String, configuration: configuration!)
+        
+        _navigationController = CNavigationController(rootViewController: _pdfViewController)
+        _navigationController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+        _navigationController.view.frame = frame
+        
+        super.init()
+        
+        // 设置代理,但是未生效
+        _pdfViewController.delegate = self
+        
+        _navigationController.setViewControllers([_pdfViewController], animated: false)
+
+    }
+
+    func view() -> UIView {
+        return _navigationController.view
+    }
+        
+    public func PDFViewBaseControllerDissmiss(_ baseControllerDelete: CPDFViewBaseController) {
+        baseControllerDelete.dismiss(animated: true)
+    }
+}
+
+
+

+ 5 - 5
ios/compdfkit_flutter.podspec

@@ -4,14 +4,14 @@
 #
 Pod::Spec.new do |s|
   s.name             = 'compdfkit_flutter'
-  s.version          = '0.0.1'
-  s.summary          = 'A new Flutter plugin project.'
+  s.version          = '2.0.2'
+  s.summary          = 'Flutter PDF Library by ComPDFKit'
   s.description      = <<-DESC
 A new Flutter plugin project.
                        DESC
-  s.homepage         = 'http://example.com'
-  s.license          = { :file => '../LICENSE' }
-  s.author           = { 'Your Company' => 'email@example.com' }
+  s.homepage         = 'https://www.compdf.com'
+  s.license          = { type:'Commercial', file: '../LICENSE' }
+  s.author           = { 'ComPDFKit' => 'compdfkit@gmail.com' }
   s.source           = { :path => '.' }
   s.source_files = 'Classes/**/*'
   s.dependency 'Flutter'

+ 20 - 2
lib/cpdf_configuration.dart

@@ -43,13 +43,16 @@ class CPDFConfiguration {
 
   CPDFFormsConfig formsConfig;
 
+  CPDFGlobalConfig globalConfig;
+
   CPDFConfiguration(
       {this.modeConfig = const ModeConfig(initialViewMode: CPreviewMode.viewer),
       this.toolbarConfig = const ToolbarConfig(),
       this.readerViewConfig = const ReaderViewConfig(),
       this.annotationsConfig = const CPDFAnnotationsConfig(),
       this.contentEditorConfig = const CPDFContentEditorConfig(),
-      this.formsConfig = const CPDFFormsConfig()});
+      this.formsConfig = const CPDFFormsConfig(),
+      this.globalConfig = const CPDFGlobalConfig()});
 
   String toJson() => jsonEncode({
         'modeConfig': modeConfig.toJson(),
@@ -57,7 +60,8 @@ class CPDFConfiguration {
         'readerViewConfig': readerViewConfig.toJson(),
         'annotationsConfig': annotationsConfig.toJson(),
         'contentEditorConfig': contentEditorConfig.toJson(),
-        'formsConfig': formsConfig.toJson()
+        'formsConfig': formsConfig.toJson(),
+        'global': globalConfig.toJson()
       });
 }
 
@@ -66,12 +70,16 @@ class ModeConfig {
 
   final List<CPreviewMode> availableViewModes;
 
+  final bool readerOnly;
+
   const ModeConfig(
       {this.initialViewMode = CPreviewMode.viewer,
+      this.readerOnly = false,
       this.availableViewModes = CPreviewMode.values});
 
   Map<String, dynamic> toJson() => {
         'initialViewMode': initialViewMode.name,
+      'readerOnly': readerOnly,
         'availableViewModes': availableViewModes.map((e) => e.name).toList()
       };
 }
@@ -852,3 +860,13 @@ class CPDFFormAttr {
     }
   }
 }
+
+class CPDFGlobalConfig {
+  /// Only supports Android platform in version 2.0.2
+  //  Set the view theme mode except the PDF area, the default value is [CPDFThemeMode.system]
+  final CPDFThemeMode themeMode;
+
+  const CPDFGlobalConfig({this.themeMode = CPDFThemeMode.system});
+
+  Map<String, dynamic> toJson() => {"themeMode": themeMode.name};
+}

+ 5 - 0
lib/cpdf_options.dart

@@ -117,3 +117,8 @@ enum CPDFFormType {
 }
 
 enum CPDFCheckStyle { check, circle, cross, diamond, square, star }
+
+
+enum CPDFThemeMode {
+  light, dark, system
+}

+ 7 - 1
lib/util/extension/cpdf_color_extension.dart

@@ -11,13 +11,19 @@ import 'dart:ui';
 
 import 'package:flutter/material.dart';
 
-extension HexColor on Color {
+/// extension [Color] class
+/// toHex: Colors.white.toHex() => '#FFFFFFFF'
+/// formHex: '#FFFFFF' => Colors.white
+extension HexColor on Color{
+
+  /// Colors.white.toHex() => '#FFFFFFFF'
   String toHex({bool leadingHashSign = true}) => '${leadingHashSign ? '#' : ''}'
       '${alpha.toRadixString(16).padLeft(2, '0')}'
       '${red.toRadixString(16).padLeft(2, '0')}'
       '${green.toRadixString(16).padLeft(2, '0')}'
       '${blue.toRadixString(16).padLeft(2, '0')}';
 
+  /// formHex: '#FFFFFF' => Colors.white
   static Color fromHex(String hexString) {
     final buffer = StringBuffer();
     if (hexString.length == 6 || hexString.length == 7) buffer.write('ff');

+ 97 - 0
lib/widgets/cpdf_reader_widget.dart

@@ -0,0 +1,97 @@
+///  Copyright © 2014-2024 PDF Technologies, Inc. All Rights Reserved.
+///
+///  THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
+///  AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
+///  UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
+///  This notice may not be removed from this file.
+
+import 'dart:io';
+
+import 'package:compdfkit_flutter/cpdf_configuration.dart';
+import 'package:compdfkit_flutter/widgets/cpdf_reader_widget_controller.dart';
+import 'package:flutter/foundation.dart';
+import 'package:flutter/gestures.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter/rendering.dart';
+import 'package:flutter/services.dart';
+
+typedef CPDFReaderWidgetCreatedCallback = void Function(
+    CPDFReaderWidgetController controller);
+
+class CPDFReaderWidget extends StatefulWidget {
+  /// pdf file path
+  final String document;
+
+  final String? password;
+
+  /// init ComPDFKit SDK configuration
+  final CPDFConfiguration configuration;
+
+  // final CPDFReaderWidgetCreatedCallback onCreated;
+
+  /// init callback
+  const CPDFReaderWidget(
+      {Key? key,
+      required this.document,
+      this.password = '',
+      required this.configuration})
+      : super(key: key);
+
+  @override
+  State<CPDFReaderWidget> createState() => _CPDFReaderWidgetState();
+}
+
+class _CPDFReaderWidgetState extends State<CPDFReaderWidget> {
+
+  @override
+  Widget build(BuildContext context) {
+    const String viewType = 'com.compdfkit.flutter.ui.pdfviewer';
+    final Map<String, dynamic> creationParams = <String, dynamic>{
+      'document': widget.document,
+      'password': widget.password,
+      'configuration': widget.configuration.toJson()
+    };
+
+    if (Platform.isAndroid) {
+      return PlatformViewLink(
+          surfaceFactory:
+              (BuildContext context, PlatformViewController controller) {
+            return AndroidViewSurface(
+                controller: controller as AndroidViewController,
+                hitTestBehavior: PlatformViewHitTestBehavior.opaque,
+                gestureRecognizers: const <Factory<
+                    OneSequenceGestureRecognizer>>{});
+          },
+          onCreatePlatformView: (PlatformViewCreationParams params) {
+            return PlatformViewsService.initSurfaceAndroidView(
+                id: params.id,
+                viewType: viewType,
+                creationParams: creationParams,
+                creationParamsCodec: const StandardMessageCodec(),
+                layoutDirection: TextDirection.ltr)
+              ..addOnPlatformViewCreatedListener(params.onPlatformViewCreated)
+              ..addOnPlatformViewCreatedListener(_onPlatformViewCreated)
+              ..create();
+          },
+          viewType: viewType);
+    } else if (Platform.isIOS) {
+      return UiKitView(
+        viewType: viewType,
+        layoutDirection: TextDirection.ltr,
+        hitTestBehavior: PlatformViewHitTestBehavior.opaque,
+        creationParams: creationParams,
+        creationParamsCodec: const StandardMessageCodec(),
+        onPlatformViewCreated: (id) {
+          _onPlatformViewCreated(id);
+        },
+      );
+    } else {
+      return const Center(child: Text('only support android and ios'));
+    }
+  }
+
+  Future<void> _onPlatformViewCreated(int id) async {
+    debugPrint('ComPDFKit-Flutter: CPDFReaderWidget created');
+    // widget.onCreated(CPDFReaderWidgetController(id));
+  }
+}

+ 22 - 0
lib/widgets/cpdf_reader_widget_controller.dart

@@ -0,0 +1,22 @@
+/*
+ * Copyright © 2014-2024 PDF Technologies, Inc. All Rights Reserved.
+ *
+ * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
+ * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
+ * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
+ * This notice may not be removed from this file.
+ *
+ */
+
+import 'package:flutter/services.dart';
+
+class CPDFReaderWidgetController {
+  late MethodChannel _channel;
+
+  CPDFReaderWidgetController(int id) {
+    _channel = MethodChannel('com.compdfkit.flutter.ui.pdfviewer.$id');
+    _channel.setMethodCallHandler((call) async {
+    });
+  }
+
+}

+ 2 - 2
pubspec.yaml

@@ -1,6 +1,6 @@
 name: compdfkit_flutter
 description: ComPDFKit for Flutter is a comprehensive SDK that allows you to quickly add PDF functionality to Android and iOS Flutter applications.
-version: 2.0.1
+version: 2.0.2-dev.1
 homepage: https://www.compdf.com
 repository: https://github.com/ComPDFKit/compdfkit-pdf-sdk-flutter
 issue_tracker: https://www.compdf.com/support
@@ -18,7 +18,7 @@ dependencies:
 dev_dependencies:
   flutter_test:
     sdk: flutter
-  flutter_lints: ^2.0.0
+  flutter_lints: ^2.0.3
 
 
 flutter: