IOS_Boss/IOS_study/Extension/View+Style.swift
2025-07-27 12:33:06 +08:00

137 lines
4.6 KiB
Swift

//
// View+Style.swift
// style
//
// Created by CC-star on 2025/6/12.
//
import SwiftUI
extension View{
func btnStyle() -> some View{ size15().buttonStyle(.borderless).accent() }
func textStyle() -> some View{ size15().tc().lineSpacing(6) }
func textStyle2() -> some View{ size15().tc2().lineSpacing(6) }
func oneLineStyleMiddle() -> some View{ lineLimit(1).truncationMode(.middle) }
func explainStyle() -> some View { size15sb().frame(maxWidth: .infinity, maxHeight: .infinity).padding() }//
//navi
func naviBarStyle() -> some View {
navigationBarTitleDisplayMode(.inline)
.toolbarBackground(.visible, for: .navigationBar)
.toolbarBackground(.aBG, for: .navigationBar) }
//
func labelStyleOF() -> some View { tc2().size15semib() }
func badgeStyle() -> some View { size13().semib().white().padding(6).bgA()//
.clipShape(Circle())//clipShape
}
@ViewBuilder func selectBtnStyle(_ selected: Bool) -> some View {//ViewBuilder
if selected {
buttonStyle(.borderedProminent)
} else {
tint(Color.aTC).buttonStyle(.bordered)
}
}
//List西
func subTStyle() -> some View{
size16semib().tc()
}
func subTStyleL() -> some View{
headline().tc()
}
//cell
func cellPaddingRadius() -> some View{//radius
padding(.vertical)
.padding(.horizontal,12)
.bg()
.radius(8)
}
func cellOutPadding() -> some View{
padding([.top,.horizontal],9)
//.padding(.bottom,10)
}
//list
func listRowStyle() -> some View{
listRowInsets(EdgeInsets())
.listRowSeparator(.hidden)
.listRowBackground(Color.clear)
}
func listStyle() -> some View{
listStyle(.inset)
.scrollContentBackground(.hidden)
.bg2()
.environment(\.defaultMinListRowHeight,0) }
func listRowStyleLoading2() -> some View {//
padding(.top).padding(.bottom,100).size13sb().push(to: .center).bg2().listRowStyle()
}
//
func cellStyle() -> some View{
cellPaddingRadius().cellOutPadding().listRowStyle()
}
//Form
func littleTStyle() -> some View{
size13().tc2().fontWeight(.light)
}
func pStyle() -> some View{
frame(height: kTFAndPHeight).border(borderColor: Color(.systemGray4))
}
func tfStyle() -> some View{//
frame(height: kTFAndPHeight).padding(.horizontal,9).border(borderColor: Color(.systemGray4)).submitLabel(.done)
}
func tfStyleMultiS() -> some View{
lineLimit(1...4).frame(minHeight: kTFAndPHeight).padding(.horizontal,9).border(borderColor: Color(.systemGray4)).lineSpacing(4)
.fixedSize(horizontal: false, vertical: true)
}
func tfStyleMultiM() -> some View{
lineLimit(3...8).frame(minHeight: kTFAndPHeight).padding(.horizontal,9).border(borderColor: Color(.systemGray4)).lineSpacing(4)
.fixedSize(horizontal: false, vertical: true)
}
func tfStyleMultiL() -> some View{
lineLimit(4...10).frame(minHeight: kTFAndPHeight).padding(.horizontal,9).border(borderColor: Color(.systemGray4)).lineSpacing(4)
.fixedSize(horizontal: false, vertical: true)
}
func conlonStyle() -> some View{
bold().padding(.horizontal,2).offset(y: -1)
}
func toggleStyle(isTap: Bool) -> some View{
size15().foregroundStyle(isTap ? .white : .aTC).padding(.horizontal,10).frame(height: kTFAndPHeight)
.background(isTap ? Color.accent.gradient : Color.bg.gradient).radius()
.border(borderColor: isTap ? .clear : .accent)
}
func appleStyleS() -> some View{ font(.body).frame(maxWidth: .infinity).padding(.vertical, 6) }
func appleStyle(disabled: Bool = false) -> some View{
headline().white().frame(height: 55).frame(maxWidth: .infinity)
.background(disabled ? Color.secondary.gradient : Color.accent.gradient).radius() }
func appleStyleP() -> some View{ tint(.white).frame(height: 55).frame(maxWidth: .infinity).background(.accent.gradient).radius() }
//
//
func loadingJobStyle() -> some View { size13().white().frame(width: 150, height: 25).background(Color.accent.gradient).radius(6) }
//progress
func loadingJobStyleP() -> some View { tint(.white).frame(width: 150, height: 25).background(Color.accent.gradient).radius(6) }
func settingsStyle() -> some View { tc().size16() }
}
extension Image{
func iconStyle() -> some View {
resizable().frame(width: 16, height: 16)
}
}