FLUTTER ECOSYSTEM

dvd-bnc/monet

안드로이드에서 monet을 사용하여 배경화면 색상을 가져오거나 주요 색상으로 생성하는 플러터 라이브러리입니다.

monet 프로젝트 이미지
Stars
20
Forks
0
최근 푸시(UTC)
2021. 8. 13.
프로젝트 상태
활성
Davide Bianco GitHub avatar
GITHUB User

Davide Bianco ↗

Developer and designer from Italy, probably working on flutter or dart related stuff atm.

Italy
언어C++DartCMakeHTMLKotlinCSwiftObjective-C

사용 중인 의존성

의존성 목록 3 개
  • flutter{"sdk":"flutter"}
  • flutter_test개발 의존성{"sdk":"flutter"}
  • flutter_lints개발 의존성^1.0.0

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

README 펼치기 / 접기

Flutter monet

A library to get wallpaper colors using monet on Android or generate them using a primary color.

The Android platform implementation uses MonetCompat to get the colors and to handle older Android versions. The library also provides a dart implementation of kdrag0n monet engine to derive colors from a provided color.

Getting Started

For Android apps targeting version 8.0 and up no setup is required, however if you wish to support lower versions some steps are required.

  1. Create a new class, call it however you want (possibly something Application related) and extend MonetApplication. This is the application class from the example, you can use it as is easily enough.

    . . .
    import hrx.plugin.monet.MonetApplication
    
    class CustomApplication : MonetApplication()
    
  2. Use the new application class in the AndroidManifest. To do so, just add android:name to the manifest application entry. This snippet is derived from the example app as before.

        <application
            android:name=".CustomApplication"
            ...>
    
  3. (Optional) Request the READ_EXTERNAL_STORAGE permission. In some older version of Android sometimes it was required to have the READ_EXTERNAL_STORAGE permission in order to get the wallpaper. If you omit said permission, nothing terribly bad will happen as the underlying lib will use default colors, so it will not error out. To add the permission, add <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> to the AndroidManifest

Using the library

You should use MonetProvider to get a working monet implementation.

First of all, get a new instance:

final MonetProvider monet = await MonetProvider.newInstance();

It's recommended to store this instance somewhere accessible in the entire app.

After you've got the instance, you can get the colors by calling getColors

// The color parameter is needed to handle cases where there are no platform colors available, such as unsupported platforms.
final MonetColors colors = monet.getColors(Colors.blue);

Once you got the colors, you can use them as you wish to. MonetColors contains five palettes as required by the monet specification. Each shade is derived from the base color with slight variations. For example, you can get the palette directly derived from the primary color by calling colors.accent1.

final MonetPalette accent1 = colors.accent1;

From the palette you can access a total of 13 shades, varying in lightness. You can use these in combination with a ColorScheme for example.

ColorScheme.light(
    secondary: accent1.shade500,
    background: accent1.shade200,
    surface: accent1.shade100,
);

You can find a simple example on the example folder and some docs on the class definitions themselves