nank1ro / flutter-shadcn-ui

shadcn-ui ported in Flutter. Awesome UI components for Flutter, fully customizable.
https://mariuti.com/shadcn-ui
MIT License
657 stars 42 forks source link

How to custome fontFamily global? #64

Closed leavky closed 1 month ago

leavky commented 1 month ago

In materialTheme, we can set fontFamily, but there not have fontFamily in ShadThemeData.

leavky commented 1 month ago

if dont't have fontFamily, the font look not good. image

nank1ro commented 1 month ago

See https://mariuti.com/shadcn-ui/typography/#custom-font-family

leavky commented 1 month ago

I want to change the gloal, and I can't change the font of the button. image

image

image

leavky commented 1 month ago

Because there is a problem with the default Chinese font, so must specify the font family

nank1ro commented 1 month ago

Don't you see the custom font in the buttons? Did you add it to the pubspec? My side I can change the font correctly.

Screenshot 2024-05-13 at 18 20 10
leavky commented 1 month ago

yes, i add font in pubsec, but the button font not change image

leavky commented 1 month ago

but the material theme button font changed

leavky commented 1 month ago

Maybe I should create a new project to test

nank1ro commented 1 month ago

Can you try adding all the other font assets (regular, light, etc.) and specify the font weights like in the documentation?

leavky commented 1 month ago

It may be that the theme of another package does not take effect in my project, but I found a problem that I could not launch in Windows after using this package.

nank1ro commented 1 month ago

Can you share the error?

leavky commented 1 month ago

use flutter-shadcn-ui\example.

➜ flutter run
Connected devices:
Windows (desktop) • windows • windows-x64    • Microsoft Windows [版本 10.0.22631.3447]
Chrome (web)      • chrome  • web-javascript • Google Chrome 124.0.6367.202
Edge (web)        • edge    • web-javascript • Microsoft Edge 124.0.2478.80
[1]: Windows (windows)
[2]: Chrome (chrome)
[3]: Edge (edge)
Please choose one (or "q" to quit): 1
Launching lib\main.dart on Windows in debug mode...
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(456,5): error MSB8020: �޷��ҵ� ClangCL �����ɹ���(ƽ̨���߼� =��ClangCL��)����Ҫʹ�� ClangCL ���ɹ��߽������ɣ��밲װ ClangCL ���ɹ��ߡ����ߣ�������������ǰ Visual Studio ���ߣ���ʽ��ͨ��ѡ����Ŀ���˵����Ҽ������ý��������Ȼ��ѡ���ض��������Ŀ�ꡱ�� [C:\Users\flowray\Desktop\flutter-shadcn-ui\example\build\windows\x64\plugins\rive_common\rive_common_plugin.vcxproj]
Building Windows application...                                     5.8s
Error: Build process failed.
leavky commented 1 month ago

look because rive package image

nank1ro commented 1 month ago

Please try with the latest commit on main, I removed rive because it caused many issue to a lot of people

dickermoshe commented 1 month ago

Does this issue happen without shadcn too?

On Tue, May 14, 2024, 5:24 AM Alexandru Mariuti @.***> wrote:

Please try with the latest commit on main, I removed rive because it caused many issue to a lot of people

— Reply to this email directly, view it on GitHub https://github.com/nank1ro/flutter-shadcn-ui/issues/64#issuecomment-2109709769, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASDJ6267IBT4AHTUYSYJCF3ZCHJ6BAVCNFSM6AAAAABHUOCFNGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBZG4YDSNZWHE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

nank1ro commented 1 month ago

Does this issue happen without shadcn too? On Tue, May 14, 2024, 5:24 AM Alexandru Mariuti @.> wrote: Please try with the latest commit on main, I removed rive because it caused many issue to a lot of people — Reply to this email directly, view it on GitHub <#64 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASDJ6267IBT4AHTUYSYJCF3ZCHJ6BAVCNFSM6AAAAABHUOCFNGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBZG4YDSNZWHE . You are receiving this because you are subscribed to this thread.Message ID: @.>

Many people who have tried to add shadcn_ui as a package have encountered the error. Especially on Windows. there is some problem with the rive_common library. Since the feature it brought was quite small (supporting riv in the ShadImage component) I decided to remove the dependency. If one then wants a riv it integrates rive in the pubspec.

leavky commented 1 month ago

Thanks, i have solve this problem by https://github.com/rive-app/rive-flutter/issues/308, rive need install clang.

leavky commented 1 month ago

After test, In riverpod and go_router, the global setting font does not take effect. In this example, https://github.com/lucavenir/go_router_riverpod.

set ShadApp textTheme image

image

nank1ro commented 1 month ago

Be aware that in the materialThemeBuilder you should copy the theme provided to you, not providing a new instance.

(context, theme) {
  return theme.copyWith(primarySwatch: Colors.cyan)
}

I would try your font and let you know

leavky commented 1 month ago

but ShadButton text font is not right, My font can download in https://github.com/lxgw/LxgwWenKai

image

I guess it's not a matter of fonts

nank1ro commented 1 month ago
Screenshot 2024-05-14 at 18 02 05

To me seems working fine. To the pubpec.yaml I added this:

  fonts:
    - family: LXGW
      fonts:
        - asset: fonts/LXGWWenKai-Bold.ttf
          weight: 700
        - asset: fonts/LXGWWenKai-Light.ttf
          weight: 300
        - asset: fonts/LXGWWenKai-Regular.ttf

My ShadApp

ShadApp(
          debugShowCheckedModeBanner: false,
          themeMode: themeMode,
          routes: routes,
          theme: ShadThemeData(
            brightness: Brightness.light,
            colorScheme: const ShadZincColorScheme.light(),
            textTheme: ShadTextTheme(
              colorScheme: const ShadZincColorScheme.light(),
              family: 'LXGW',
            ),
          ),
          home: const MainPage(),
        )
leavky commented 1 month ago

Thanks, It's normal now, and I understand what's wrong, because i set darkTheme.

Thank you very much for developing this package~